@prisma-next/family-sql 0.3.0-pr.88.3 → 0.3.0-pr.88.6
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/{chunk-SQ2VWYDV.js → chunk-F27CR6XZ.js} +2 -2
- package/dist/{chunk-BHEGVBY7.js → chunk-XH2Y5NTD.js} +59 -116
- package/dist/chunk-XH2Y5NTD.js.map +1 -0
- package/dist/core/schema-verify/verify-helpers.d.ts +48 -2
- package/dist/core/schema-verify/verify-helpers.d.ts.map +1 -1
- package/dist/core/schema-verify/verify-sql-schema.d.ts.map +1 -1
- package/dist/exports/control.js +2 -2
- package/dist/exports/schema-verify.d.ts +1 -1
- package/dist/exports/schema-verify.d.ts.map +1 -1
- package/dist/exports/schema-verify.js +5 -1
- package/dist/exports/test-utils.js +2 -2
- package/package.json +16 -16
- package/src/core/schema-verify/verify-helpers.ts +140 -122
- package/src/core/schema-verify/verify-sql-schema.ts +4 -0
- package/src/exports/schema-verify.ts +6 -1
- package/dist/chunk-BHEGVBY7.js.map +0 -1
- /package/dist/{chunk-SQ2VWYDV.js.map → chunk-F27CR6XZ.js.map} +0 -0
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-SU7LN2UH.js";
|
|
5
5
|
import {
|
|
6
6
|
verifySqlSchema
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-XH2Y5NTD.js";
|
|
8
8
|
|
|
9
9
|
// src/core/assembly.ts
|
|
10
10
|
import { createOperationRegistry } from "@prisma-next/operations";
|
|
@@ -586,4 +586,4 @@ export {
|
|
|
586
586
|
convertOperationManifest,
|
|
587
587
|
createSqlFamilyInstance
|
|
588
588
|
};
|
|
589
|
-
//# sourceMappingURL=chunk-
|
|
589
|
+
//# sourceMappingURL=chunk-F27CR6XZ.js.map
|
|
@@ -10,6 +10,20 @@ function arraysEqual(a, b) {
|
|
|
10
10
|
}
|
|
11
11
|
return true;
|
|
12
12
|
}
|
|
13
|
+
function isUniqueConstraintSatisfied(uniques, indexes, columns) {
|
|
14
|
+
const hasConstraint = uniques.some((unique) => arraysEqual(unique.columns, columns));
|
|
15
|
+
if (hasConstraint) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
return indexes.some((index) => index.unique && arraysEqual(index.columns, columns));
|
|
19
|
+
}
|
|
20
|
+
function isIndexSatisfied(indexes, uniques, columns) {
|
|
21
|
+
const hasMatchingIndex = indexes.some((index) => arraysEqual(index.columns, columns));
|
|
22
|
+
if (hasMatchingIndex) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
return uniques.some((unique) => arraysEqual(unique.columns, columns));
|
|
26
|
+
}
|
|
13
27
|
function verifyPrimaryKey(contractPK, schemaPK, tableName, issues) {
|
|
14
28
|
if (!schemaPK) {
|
|
15
29
|
issues.push({
|
|
@@ -30,17 +44,6 @@ function verifyPrimaryKey(contractPK, schemaPK, tableName, issues) {
|
|
|
30
44
|
});
|
|
31
45
|
return "fail";
|
|
32
46
|
}
|
|
33
|
-
if (contractPK.name && schemaPK.name && contractPK.name !== schemaPK.name) {
|
|
34
|
-
issues.push({
|
|
35
|
-
kind: "primary_key_mismatch",
|
|
36
|
-
table: tableName,
|
|
37
|
-
indexOrConstraint: contractPK.name,
|
|
38
|
-
expected: contractPK.name,
|
|
39
|
-
actual: schemaPK.name,
|
|
40
|
-
message: `Table "${tableName}" has primary key name mismatch: expected "${contractPK.name}", got "${schemaPK.name}"`
|
|
41
|
-
});
|
|
42
|
-
return "fail";
|
|
43
|
-
}
|
|
44
47
|
return "pass";
|
|
45
48
|
}
|
|
46
49
|
function verifyForeignKeys(contractFKs, schemaFKs, tableName, tablePath, issues, strict) {
|
|
@@ -69,39 +72,17 @@ function verifyForeignKeys(contractFKs, schemaFKs, tableName, tablePath, issues,
|
|
|
69
72
|
children: []
|
|
70
73
|
});
|
|
71
74
|
} else {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
kind: "foreignKey",
|
|
84
|
-
name: `foreignKey(${contractFK.columns.join(", ")})`,
|
|
85
|
-
contractPath: fkPath,
|
|
86
|
-
code: "foreign_key_mismatch",
|
|
87
|
-
message: "Foreign key name mismatch",
|
|
88
|
-
expected: contractFK.name,
|
|
89
|
-
actual: matchingFK.name,
|
|
90
|
-
children: []
|
|
91
|
-
});
|
|
92
|
-
} else {
|
|
93
|
-
nodes.push({
|
|
94
|
-
status: "pass",
|
|
95
|
-
kind: "foreignKey",
|
|
96
|
-
name: `foreignKey(${contractFK.columns.join(", ")})`,
|
|
97
|
-
contractPath: fkPath,
|
|
98
|
-
code: "",
|
|
99
|
-
message: "",
|
|
100
|
-
expected: void 0,
|
|
101
|
-
actual: void 0,
|
|
102
|
-
children: []
|
|
103
|
-
});
|
|
104
|
-
}
|
|
75
|
+
nodes.push({
|
|
76
|
+
status: "pass",
|
|
77
|
+
kind: "foreignKey",
|
|
78
|
+
name: `foreignKey(${contractFK.columns.join(", ")})`,
|
|
79
|
+
contractPath: fkPath,
|
|
80
|
+
code: "",
|
|
81
|
+
message: "",
|
|
82
|
+
expected: void 0,
|
|
83
|
+
actual: void 0,
|
|
84
|
+
children: []
|
|
85
|
+
});
|
|
105
86
|
}
|
|
106
87
|
}
|
|
107
88
|
if (strict) {
|
|
@@ -131,14 +112,15 @@ function verifyForeignKeys(contractFKs, schemaFKs, tableName, tablePath, issues,
|
|
|
131
112
|
}
|
|
132
113
|
return nodes;
|
|
133
114
|
}
|
|
134
|
-
function verifyUniqueConstraints(contractUniques, schemaUniques, tableName, tablePath, issues, strict) {
|
|
115
|
+
function verifyUniqueConstraints(contractUniques, schemaUniques, schemaIndexes, tableName, tablePath, issues, strict) {
|
|
135
116
|
const nodes = [];
|
|
136
117
|
for (const contractUnique of contractUniques) {
|
|
137
118
|
const uniquePath = `${tablePath}.uniques[${contractUnique.columns.join(",")}]`;
|
|
138
119
|
const matchingUnique = schemaUniques.find(
|
|
139
120
|
(u) => arraysEqual(u.columns, contractUnique.columns)
|
|
140
121
|
);
|
|
141
|
-
|
|
122
|
+
const matchingUniqueIndex = !matchingUnique && schemaIndexes.find((idx) => idx.unique && arraysEqual(idx.columns, contractUnique.columns));
|
|
123
|
+
if (!matchingUnique && !matchingUniqueIndex) {
|
|
142
124
|
issues.push({
|
|
143
125
|
kind: "unique_constraint_mismatch",
|
|
144
126
|
table: tableName,
|
|
@@ -157,39 +139,17 @@ function verifyUniqueConstraints(contractUniques, schemaUniques, tableName, tabl
|
|
|
157
139
|
children: []
|
|
158
140
|
});
|
|
159
141
|
} else {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
kind: "unique",
|
|
172
|
-
name: `unique(${contractUnique.columns.join(", ")})`,
|
|
173
|
-
contractPath: uniquePath,
|
|
174
|
-
code: "unique_constraint_mismatch",
|
|
175
|
-
message: "Unique constraint name mismatch",
|
|
176
|
-
expected: contractUnique.name,
|
|
177
|
-
actual: matchingUnique.name,
|
|
178
|
-
children: []
|
|
179
|
-
});
|
|
180
|
-
} else {
|
|
181
|
-
nodes.push({
|
|
182
|
-
status: "pass",
|
|
183
|
-
kind: "unique",
|
|
184
|
-
name: `unique(${contractUnique.columns.join(", ")})`,
|
|
185
|
-
contractPath: uniquePath,
|
|
186
|
-
code: "",
|
|
187
|
-
message: "",
|
|
188
|
-
expected: void 0,
|
|
189
|
-
actual: void 0,
|
|
190
|
-
children: []
|
|
191
|
-
});
|
|
192
|
-
}
|
|
142
|
+
nodes.push({
|
|
143
|
+
status: "pass",
|
|
144
|
+
kind: "unique",
|
|
145
|
+
name: `unique(${contractUnique.columns.join(", ")})`,
|
|
146
|
+
contractPath: uniquePath,
|
|
147
|
+
code: "",
|
|
148
|
+
message: "",
|
|
149
|
+
expected: void 0,
|
|
150
|
+
actual: void 0,
|
|
151
|
+
children: []
|
|
152
|
+
});
|
|
193
153
|
}
|
|
194
154
|
}
|
|
195
155
|
if (strict) {
|
|
@@ -219,14 +179,15 @@ function verifyUniqueConstraints(contractUniques, schemaUniques, tableName, tabl
|
|
|
219
179
|
}
|
|
220
180
|
return nodes;
|
|
221
181
|
}
|
|
222
|
-
function verifyIndexes(contractIndexes, schemaIndexes, tableName, tablePath, issues, strict) {
|
|
182
|
+
function verifyIndexes(contractIndexes, schemaIndexes, schemaUniques, tableName, tablePath, issues, strict) {
|
|
223
183
|
const nodes = [];
|
|
224
184
|
for (const contractIndex of contractIndexes) {
|
|
225
185
|
const indexPath = `${tablePath}.indexes[${contractIndex.columns.join(",")}]`;
|
|
226
186
|
const matchingIndex = schemaIndexes.find(
|
|
227
|
-
(idx) => arraysEqual(idx.columns, contractIndex.columns)
|
|
187
|
+
(idx) => arraysEqual(idx.columns, contractIndex.columns)
|
|
228
188
|
);
|
|
229
|
-
|
|
189
|
+
const matchingUniqueConstraint = !matchingIndex && schemaUniques.find((u) => arraysEqual(u.columns, contractIndex.columns));
|
|
190
|
+
if (!matchingIndex && !matchingUniqueConstraint) {
|
|
230
191
|
issues.push({
|
|
231
192
|
kind: "index_mismatch",
|
|
232
193
|
table: tableName,
|
|
@@ -245,39 +206,17 @@ function verifyIndexes(contractIndexes, schemaIndexes, tableName, tablePath, iss
|
|
|
245
206
|
children: []
|
|
246
207
|
});
|
|
247
208
|
} else {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
kind: "index",
|
|
260
|
-
name: `index(${contractIndex.columns.join(", ")})`,
|
|
261
|
-
contractPath: indexPath,
|
|
262
|
-
code: "index_mismatch",
|
|
263
|
-
message: "Index name mismatch",
|
|
264
|
-
expected: contractIndex.name,
|
|
265
|
-
actual: matchingIndex.name,
|
|
266
|
-
children: []
|
|
267
|
-
});
|
|
268
|
-
} else {
|
|
269
|
-
nodes.push({
|
|
270
|
-
status: "pass",
|
|
271
|
-
kind: "index",
|
|
272
|
-
name: `index(${contractIndex.columns.join(", ")})`,
|
|
273
|
-
contractPath: indexPath,
|
|
274
|
-
code: "",
|
|
275
|
-
message: "",
|
|
276
|
-
expected: void 0,
|
|
277
|
-
actual: void 0,
|
|
278
|
-
children: []
|
|
279
|
-
});
|
|
280
|
-
}
|
|
209
|
+
nodes.push({
|
|
210
|
+
status: "pass",
|
|
211
|
+
kind: "index",
|
|
212
|
+
name: `index(${contractIndex.columns.join(", ")})`,
|
|
213
|
+
contractPath: indexPath,
|
|
214
|
+
code: "",
|
|
215
|
+
message: "",
|
|
216
|
+
expected: void 0,
|
|
217
|
+
actual: void 0,
|
|
218
|
+
children: []
|
|
219
|
+
});
|
|
281
220
|
}
|
|
282
221
|
}
|
|
283
222
|
if (strict) {
|
|
@@ -626,6 +565,7 @@ function verifySqlSchema(options) {
|
|
|
626
565
|
const uniqueStatuses = verifyUniqueConstraints(
|
|
627
566
|
contractTable.uniques,
|
|
628
567
|
schemaTable.uniques,
|
|
568
|
+
schemaTable.indexes,
|
|
629
569
|
tableName,
|
|
630
570
|
tablePath,
|
|
631
571
|
issues,
|
|
@@ -635,6 +575,7 @@ function verifySqlSchema(options) {
|
|
|
635
575
|
const indexStatuses = verifyIndexes(
|
|
636
576
|
contractTable.indexes,
|
|
637
577
|
schemaTable.indexes,
|
|
578
|
+
schemaTable.uniques,
|
|
638
579
|
tableName,
|
|
639
580
|
tablePath,
|
|
640
581
|
issues,
|
|
@@ -766,7 +707,9 @@ function collectDependenciesFromFrameworkComponents(components) {
|
|
|
766
707
|
|
|
767
708
|
export {
|
|
768
709
|
arraysEqual,
|
|
710
|
+
isUniqueConstraintSatisfied,
|
|
711
|
+
isIndexSatisfied,
|
|
769
712
|
verifyDatabaseDependencies,
|
|
770
713
|
verifySqlSchema
|
|
771
714
|
};
|
|
772
|
-
//# sourceMappingURL=chunk-
|
|
715
|
+
//# sourceMappingURL=chunk-XH2Y5NTD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/schema-verify/verify-helpers.ts","../src/core/schema-verify/verify-sql-schema.ts"],"sourcesContent":["/**\n * Pure verification helper functions for SQL schema verification.\n * These functions verify schema IR against contract requirements.\n */\n\nimport type { SchemaIssue, SchemaVerificationNode } from '@prisma-next/core-control-plane/types';\nimport type {\n ForeignKey,\n Index,\n PrimaryKey,\n UniqueConstraint,\n} from '@prisma-next/sql-contract/types';\nimport type {\n SqlForeignKeyIR,\n SqlIndexIR,\n SqlSchemaIR,\n SqlUniqueIR,\n} from '@prisma-next/sql-schema-ir/types';\nimport type { ComponentDatabaseDependency } from '../migrations/types';\n\n/**\n * Compares two arrays of strings for equality (order-sensitive).\n */\nexport function arraysEqual(a: readonly string[], b: readonly string[]): boolean {\n if (a.length !== b.length) {\n return false;\n }\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n return true;\n}\n\n// ============================================================================\n// Semantic Satisfaction Predicates\n// ============================================================================\n// These predicates implement the \"stronger satisfies weaker\" logic for storage\n// objects. They are used by both verification and migration planning to ensure\n// consistent behavior across the control plane.\n\n/**\n * Checks if a unique constraint requirement is satisfied by the given columns.\n *\n * Semantic satisfaction: a unique constraint requirement can be satisfied by:\n * - A unique constraint with the same columns, OR\n * - A unique index with the same columns\n *\n * @param uniques - The unique constraints in the schema table\n * @param indexes - The indexes in the schema table\n * @param columns - The columns required by the unique constraint\n * @returns true if the requirement is satisfied\n */\nexport function isUniqueConstraintSatisfied(\n uniques: readonly SqlUniqueIR[],\n indexes: readonly SqlIndexIR[],\n columns: readonly string[],\n): boolean {\n // Check for matching unique constraint\n const hasConstraint = uniques.some((unique) => arraysEqual(unique.columns, columns));\n if (hasConstraint) {\n return true;\n }\n // Check for matching unique index (semantic satisfaction)\n return indexes.some((index) => index.unique && arraysEqual(index.columns, columns));\n}\n\n/**\n * Checks if an index requirement is satisfied by the given columns.\n *\n * Semantic satisfaction: a non-unique index requirement can be satisfied by:\n * - Any index (unique or non-unique) with the same columns, OR\n * - A unique constraint with the same columns (stronger satisfies weaker)\n *\n * @param indexes - The indexes in the schema table\n * @param uniques - The unique constraints in the schema table\n * @param columns - The columns required by the index\n * @returns true if the requirement is satisfied\n */\nexport function isIndexSatisfied(\n indexes: readonly SqlIndexIR[],\n uniques: readonly SqlUniqueIR[],\n columns: readonly string[],\n): boolean {\n // Check for any matching index (unique or non-unique)\n const hasMatchingIndex = indexes.some((index) => arraysEqual(index.columns, columns));\n if (hasMatchingIndex) {\n return true;\n }\n // Check for matching unique constraint (semantic satisfaction)\n return uniques.some((unique) => arraysEqual(unique.columns, columns));\n}\n\n/**\n * Verifies primary key matches between contract and schema.\n * Returns 'pass' or 'fail'.\n *\n * Uses semantic satisfaction: identity is based on (table + kind + columns).\n * Name differences are ignored by default (names are for DDL/diagnostics, not identity).\n */\nexport function verifyPrimaryKey(\n contractPK: PrimaryKey,\n schemaPK: PrimaryKey | undefined,\n tableName: string,\n issues: SchemaIssue[],\n): 'pass' | 'fail' {\n if (!schemaPK) {\n issues.push({\n kind: 'primary_key_mismatch',\n table: tableName,\n expected: contractPK.columns.join(', '),\n message: `Table \"${tableName}\" is missing primary key`,\n });\n return 'fail';\n }\n\n if (!arraysEqual(contractPK.columns, schemaPK.columns)) {\n issues.push({\n kind: 'primary_key_mismatch',\n table: tableName,\n expected: contractPK.columns.join(', '),\n actual: schemaPK.columns.join(', '),\n message: `Table \"${tableName}\" has primary key mismatch: expected columns [${contractPK.columns.join(', ')}], got [${schemaPK.columns.join(', ')}]`,\n });\n return 'fail';\n }\n\n // Name differences are ignored for semantic satisfaction.\n // Names are persisted for deterministic DDL and diagnostics but are not identity.\n\n return 'pass';\n}\n\n/**\n * Verifies foreign keys match between contract and schema.\n * Returns verification nodes for the tree.\n *\n * Uses semantic satisfaction: identity is based on (table + columns + referenced table + referenced columns).\n * Name differences are ignored by default (names are for DDL/diagnostics, not identity).\n */\nexport function verifyForeignKeys(\n contractFKs: readonly ForeignKey[],\n schemaFKs: readonly SqlForeignKeyIR[],\n tableName: string,\n tablePath: string,\n issues: SchemaIssue[],\n strict: boolean,\n): SchemaVerificationNode[] {\n const nodes: SchemaVerificationNode[] = [];\n\n // Check each contract FK exists in schema\n for (const contractFK of contractFKs) {\n const fkPath = `${tablePath}.foreignKeys[${contractFK.columns.join(',')}]`;\n const matchingFK = schemaFKs.find((fk) => {\n return (\n arraysEqual(fk.columns, contractFK.columns) &&\n fk.referencedTable === contractFK.references.table &&\n arraysEqual(fk.referencedColumns, contractFK.references.columns)\n );\n });\n\n if (!matchingFK) {\n issues.push({\n kind: 'foreign_key_mismatch',\n table: tableName,\n expected: `${contractFK.columns.join(', ')} -> ${contractFK.references.table}(${contractFK.references.columns.join(', ')})`,\n message: `Table \"${tableName}\" is missing foreign key: ${contractFK.columns.join(', ')} -> ${contractFK.references.table}(${contractFK.references.columns.join(', ')})`,\n });\n nodes.push({\n status: 'fail',\n kind: 'foreignKey',\n name: `foreignKey(${contractFK.columns.join(', ')})`,\n contractPath: fkPath,\n code: 'foreign_key_mismatch',\n message: 'Foreign key missing',\n expected: contractFK,\n actual: undefined,\n children: [],\n });\n } else {\n // Name differences are ignored for semantic satisfaction.\n // Names are persisted for deterministic DDL and diagnostics but are not identity.\n nodes.push({\n status: 'pass',\n kind: 'foreignKey',\n name: `foreignKey(${contractFK.columns.join(', ')})`,\n contractPath: fkPath,\n code: '',\n message: '',\n expected: undefined,\n actual: undefined,\n children: [],\n });\n }\n }\n\n // Check for extra FKs in strict mode\n if (strict) {\n for (const schemaFK of schemaFKs) {\n const matchingFK = contractFKs.find((fk) => {\n return (\n arraysEqual(fk.columns, schemaFK.columns) &&\n fk.references.table === schemaFK.referencedTable &&\n arraysEqual(fk.references.columns, schemaFK.referencedColumns)\n );\n });\n\n if (!matchingFK) {\n issues.push({\n kind: 'extra_foreign_key',\n table: tableName,\n message: `Extra foreign key found in database (not in contract): ${schemaFK.columns.join(', ')} -> ${schemaFK.referencedTable}(${schemaFK.referencedColumns.join(', ')})`,\n });\n nodes.push({\n status: 'fail',\n kind: 'foreignKey',\n name: `foreignKey(${schemaFK.columns.join(', ')})`,\n contractPath: `${tablePath}.foreignKeys[${schemaFK.columns.join(',')}]`,\n code: 'extra_foreign_key',\n message: 'Extra foreign key found',\n expected: undefined,\n actual: schemaFK,\n children: [],\n });\n }\n }\n }\n\n return nodes;\n}\n\n/**\n * Verifies unique constraints match between contract and schema.\n * Returns verification nodes for the tree.\n *\n * Uses semantic satisfaction: identity is based on (table + kind + columns).\n * A unique constraint requirement can be satisfied by either:\n * - A unique constraint with the same columns, or\n * - A unique index with the same columns\n *\n * Name differences are ignored by default (names are for DDL/diagnostics, not identity).\n */\nexport function verifyUniqueConstraints(\n contractUniques: readonly UniqueConstraint[],\n schemaUniques: readonly SqlUniqueIR[],\n schemaIndexes: readonly SqlIndexIR[],\n tableName: string,\n tablePath: string,\n issues: SchemaIssue[],\n strict: boolean,\n): SchemaVerificationNode[] {\n const nodes: SchemaVerificationNode[] = [];\n\n // Check each contract unique exists in schema\n for (const contractUnique of contractUniques) {\n const uniquePath = `${tablePath}.uniques[${contractUnique.columns.join(',')}]`;\n\n // First check for a matching unique constraint\n const matchingUnique = schemaUniques.find((u) =>\n arraysEqual(u.columns, contractUnique.columns),\n );\n\n // If no matching constraint, check for a unique index with the same columns\n const matchingUniqueIndex =\n !matchingUnique &&\n schemaIndexes.find((idx) => idx.unique && arraysEqual(idx.columns, contractUnique.columns));\n\n if (!matchingUnique && !matchingUniqueIndex) {\n issues.push({\n kind: 'unique_constraint_mismatch',\n table: tableName,\n expected: contractUnique.columns.join(', '),\n message: `Table \"${tableName}\" is missing unique constraint: ${contractUnique.columns.join(', ')}`,\n });\n nodes.push({\n status: 'fail',\n kind: 'unique',\n name: `unique(${contractUnique.columns.join(', ')})`,\n contractPath: uniquePath,\n code: 'unique_constraint_mismatch',\n message: 'Unique constraint missing',\n expected: contractUnique,\n actual: undefined,\n children: [],\n });\n } else {\n // Name differences are ignored for semantic satisfaction.\n // Names are persisted for deterministic DDL and diagnostics but are not identity.\n nodes.push({\n status: 'pass',\n kind: 'unique',\n name: `unique(${contractUnique.columns.join(', ')})`,\n contractPath: uniquePath,\n code: '',\n message: '',\n expected: undefined,\n actual: undefined,\n children: [],\n });\n }\n }\n\n // Check for extra uniques in strict mode\n if (strict) {\n for (const schemaUnique of schemaUniques) {\n const matchingUnique = contractUniques.find((u) =>\n arraysEqual(u.columns, schemaUnique.columns),\n );\n\n if (!matchingUnique) {\n issues.push({\n kind: 'extra_unique_constraint',\n table: tableName,\n message: `Extra unique constraint found in database (not in contract): ${schemaUnique.columns.join(', ')}`,\n });\n nodes.push({\n status: 'fail',\n kind: 'unique',\n name: `unique(${schemaUnique.columns.join(', ')})`,\n contractPath: `${tablePath}.uniques[${schemaUnique.columns.join(',')}]`,\n code: 'extra_unique_constraint',\n message: 'Extra unique constraint found',\n expected: undefined,\n actual: schemaUnique,\n children: [],\n });\n }\n }\n }\n\n return nodes;\n}\n\n/**\n * Verifies indexes match between contract and schema.\n * Returns verification nodes for the tree.\n *\n * Uses semantic satisfaction: identity is based on (table + kind + columns).\n * A non-unique index requirement can be satisfied by either:\n * - A non-unique index with the same columns, or\n * - A unique index with the same columns (stronger satisfies weaker)\n *\n * Name differences are ignored by default (names are for DDL/diagnostics, not identity).\n */\nexport function verifyIndexes(\n contractIndexes: readonly Index[],\n schemaIndexes: readonly SqlIndexIR[],\n schemaUniques: readonly SqlUniqueIR[],\n tableName: string,\n tablePath: string,\n issues: SchemaIssue[],\n strict: boolean,\n): SchemaVerificationNode[] {\n const nodes: SchemaVerificationNode[] = [];\n\n // Check each contract index exists in schema\n for (const contractIndex of contractIndexes) {\n const indexPath = `${tablePath}.indexes[${contractIndex.columns.join(',')}]`;\n\n // Check for any matching index (unique or non-unique)\n // A unique index can satisfy a non-unique index requirement (stronger satisfies weaker)\n const matchingIndex = schemaIndexes.find((idx) =>\n arraysEqual(idx.columns, contractIndex.columns),\n );\n\n // Also check if a unique constraint satisfies the index requirement\n const matchingUniqueConstraint =\n !matchingIndex && schemaUniques.find((u) => arraysEqual(u.columns, contractIndex.columns));\n\n if (!matchingIndex && !matchingUniqueConstraint) {\n issues.push({\n kind: 'index_mismatch',\n table: tableName,\n expected: contractIndex.columns.join(', '),\n message: `Table \"${tableName}\" is missing index: ${contractIndex.columns.join(', ')}`,\n });\n nodes.push({\n status: 'fail',\n kind: 'index',\n name: `index(${contractIndex.columns.join(', ')})`,\n contractPath: indexPath,\n code: 'index_mismatch',\n message: 'Index missing',\n expected: contractIndex,\n actual: undefined,\n children: [],\n });\n } else {\n // Name differences are ignored for semantic satisfaction.\n // Names are persisted for deterministic DDL and diagnostics but are not identity.\n nodes.push({\n status: 'pass',\n kind: 'index',\n name: `index(${contractIndex.columns.join(', ')})`,\n contractPath: indexPath,\n code: '',\n message: '',\n expected: undefined,\n actual: undefined,\n children: [],\n });\n }\n }\n\n // Check for extra indexes in strict mode\n if (strict) {\n for (const schemaIndex of schemaIndexes) {\n // Skip unique indexes (they're handled as unique constraints)\n if (schemaIndex.unique) {\n continue;\n }\n\n const matchingIndex = contractIndexes.find((idx) =>\n arraysEqual(idx.columns, schemaIndex.columns),\n );\n\n if (!matchingIndex) {\n issues.push({\n kind: 'extra_index',\n table: tableName,\n message: `Extra index found in database (not in contract): ${schemaIndex.columns.join(', ')}`,\n });\n nodes.push({\n status: 'fail',\n kind: 'index',\n name: `index(${schemaIndex.columns.join(', ')})`,\n contractPath: `${tablePath}.indexes[${schemaIndex.columns.join(',')}]`,\n code: 'extra_index',\n message: 'Extra index found',\n expected: undefined,\n actual: schemaIndex,\n children: [],\n });\n }\n }\n }\n\n return nodes;\n}\n\n/**\n * Verifies database dependencies are installed using component-owned verification hooks.\n * Each dependency provides a pure verifyDatabaseDependencyInstalled function that checks\n * whether the dependency is satisfied based on the in-memory schema IR (no DB I/O).\n *\n * Returns verification nodes for the tree.\n */\nexport function verifyDatabaseDependencies(\n dependencies: ReadonlyArray<ComponentDatabaseDependency<unknown>>,\n schema: SqlSchemaIR,\n issues: SchemaIssue[],\n): SchemaVerificationNode[] {\n const nodes: SchemaVerificationNode[] = [];\n\n for (const dependency of dependencies) {\n const depIssues = dependency.verifyDatabaseDependencyInstalled(schema);\n const depPath = `dependencies.${dependency.id}`;\n\n if (depIssues.length > 0) {\n // Dependency is not satisfied\n issues.push(...depIssues);\n const issuesMessage = depIssues.map((i) => i.message).join('; ');\n const nodeMessage = issuesMessage ? `${dependency.id}: ${issuesMessage}` : dependency.id;\n nodes.push({\n status: 'fail',\n kind: 'databaseDependency',\n name: dependency.label,\n contractPath: depPath,\n code: 'dependency_missing',\n message: nodeMessage,\n expected: undefined,\n actual: undefined,\n children: [],\n });\n } else {\n // Dependency is satisfied\n nodes.push({\n status: 'pass',\n kind: 'databaseDependency',\n name: dependency.label,\n contractPath: depPath,\n code: '',\n message: '',\n expected: undefined,\n actual: undefined,\n children: [],\n });\n }\n }\n\n return nodes;\n}\n\n/**\n * Computes counts of pass/warn/fail nodes by traversing the tree.\n */\nexport function computeCounts(node: SchemaVerificationNode): {\n pass: number;\n warn: number;\n fail: number;\n totalNodes: number;\n} {\n let pass = 0;\n let warn = 0;\n let fail = 0;\n\n function traverse(n: SchemaVerificationNode): void {\n if (n.status === 'pass') {\n pass++;\n } else if (n.status === 'warn') {\n warn++;\n } else if (n.status === 'fail') {\n fail++;\n }\n\n if (n.children) {\n for (const child of n.children) {\n traverse(child);\n }\n }\n }\n\n traverse(node);\n\n return {\n pass,\n warn,\n fail,\n totalNodes: pass + warn + fail,\n };\n}\n","/**\n * Pure SQL schema verification function.\n *\n * This module provides a pure function that verifies a SqlSchemaIR against\n * a SqlContract without requiring a database connection. It can be reused\n * by migration planners and other tools that need to compare schema states.\n */\n\nimport type { TargetBoundComponentDescriptor } from '@prisma-next/contract/framework-components';\nimport type {\n OperationContext,\n SchemaIssue,\n SchemaVerificationNode,\n VerifyDatabaseSchemaResult,\n} from '@prisma-next/core-control-plane/types';\nimport type { SqlContract, SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport type { ComponentDatabaseDependency } from '../migrations/types';\nimport {\n computeCounts,\n verifyDatabaseDependencies,\n verifyForeignKeys,\n verifyIndexes,\n verifyPrimaryKey,\n verifyUniqueConstraints,\n} from './verify-helpers';\n\n/**\n * Options for the pure schema verification function.\n */\nexport interface VerifySqlSchemaOptions {\n /** The validated SQL contract to verify against */\n readonly contract: SqlContract<SqlStorage>;\n /** The schema IR from introspection (or another source) */\n readonly schema: SqlSchemaIR;\n /** Whether to run in strict mode (detects extra tables/columns) */\n readonly strict: boolean;\n /** Optional operation context for metadata */\n readonly context?: OperationContext;\n /** Type metadata registry for codec consistency warnings */\n readonly typeMetadataRegistry: ReadonlyMap<string, { nativeType?: string }>;\n /**\n * Active framework components participating in this composition.\n * All components must have matching familyId ('sql') and targetId.\n */\n readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;\n}\n\n/**\n * Verifies that a SqlSchemaIR matches a SqlContract.\n *\n * This is a pure function that does NOT perform any database I/O.\n * It takes an already-introspected schema IR and compares it against\n * the contract requirements.\n *\n * @param options - Verification options\n * @returns VerifyDatabaseSchemaResult with verification tree and issues\n */\nexport function verifySqlSchema(options: VerifySqlSchemaOptions): VerifyDatabaseSchemaResult {\n const { contract, schema, strict, context, typeMetadataRegistry } = options;\n const startTime = Date.now();\n\n // Extract contract hashes and target\n const contractCoreHash = contract.coreHash;\n const contractProfileHash =\n 'profileHash' in contract && typeof contract.profileHash === 'string'\n ? contract.profileHash\n : undefined;\n const contractTarget = contract.target;\n\n // Compare contract vs schema IR\n const issues: SchemaIssue[] = [];\n const rootChildren: SchemaVerificationNode[] = [];\n\n // Compare tables\n const contractTables = contract.storage.tables;\n const schemaTables = schema.tables;\n\n for (const [tableName, contractTable] of Object.entries(contractTables)) {\n const schemaTable = schemaTables[tableName];\n const tablePath = `storage.tables.${tableName}`;\n\n if (!schemaTable) {\n // Missing table\n issues.push({\n kind: 'missing_table',\n table: tableName,\n message: `Table \"${tableName}\" is missing from database`,\n });\n rootChildren.push({\n status: 'fail',\n kind: 'table',\n name: `table ${tableName}`,\n contractPath: tablePath,\n code: 'missing_table',\n message: `Table \"${tableName}\" is missing`,\n expected: undefined,\n actual: undefined,\n children: [],\n });\n continue;\n }\n\n // Table exists - compare columns, constraints, etc.\n const tableChildren: SchemaVerificationNode[] = [];\n const columnNodes: SchemaVerificationNode[] = [];\n\n // Compare columns\n for (const [columnName, contractColumn] of Object.entries(contractTable.columns)) {\n const schemaColumn = schemaTable.columns[columnName];\n const columnPath = `${tablePath}.columns.${columnName}`;\n\n if (!schemaColumn) {\n // Missing column\n issues.push({\n kind: 'missing_column',\n table: tableName,\n column: columnName,\n message: `Column \"${tableName}\".\"${columnName}\" is missing from database`,\n });\n columnNodes.push({\n status: 'fail',\n kind: 'column',\n name: `${columnName}: missing`,\n contractPath: columnPath,\n code: 'missing_column',\n message: `Column \"${columnName}\" is missing`,\n expected: undefined,\n actual: undefined,\n children: [],\n });\n continue;\n }\n\n // Column exists - compare type and nullability\n const columnChildren: SchemaVerificationNode[] = [];\n let columnStatus: 'pass' | 'warn' | 'fail' = 'pass';\n\n // Compare type using nativeType directly\n // Both contractColumn.nativeType and schemaColumn.nativeType are required by their types\n const contractNativeType = contractColumn.nativeType;\n const schemaNativeType = schemaColumn.nativeType;\n\n if (contractNativeType !== schemaNativeType) {\n // Compare native types directly\n issues.push({\n kind: 'type_mismatch',\n table: tableName,\n column: columnName,\n expected: contractNativeType,\n actual: schemaNativeType,\n message: `Column \"${tableName}\".\"${columnName}\" has type mismatch: expected \"${contractNativeType}\", got \"${schemaNativeType}\"`,\n });\n columnChildren.push({\n status: 'fail',\n kind: 'type',\n name: 'type',\n contractPath: `${columnPath}.nativeType`,\n code: 'type_mismatch',\n message: `Type mismatch: expected ${contractNativeType}, got ${schemaNativeType}`,\n expected: contractNativeType,\n actual: schemaNativeType,\n children: [],\n });\n columnStatus = 'fail';\n }\n\n // Optionally validate that codecId (if present) and nativeType agree with registry\n if (contractColumn.codecId) {\n const typeMetadata = typeMetadataRegistry.get(contractColumn.codecId);\n if (!typeMetadata) {\n // Warning: codecId not found in registry\n columnChildren.push({\n status: 'warn',\n kind: 'type',\n name: 'type_metadata_missing',\n contractPath: `${columnPath}.codecId`,\n code: 'type_metadata_missing',\n message: `codecId \"${contractColumn.codecId}\" not found in type metadata registry`,\n expected: contractColumn.codecId,\n actual: undefined,\n children: [],\n });\n } else if (typeMetadata.nativeType && typeMetadata.nativeType !== contractNativeType) {\n // Warning: codecId and nativeType don't agree with registry\n columnChildren.push({\n status: 'warn',\n kind: 'type',\n name: 'type_consistency',\n contractPath: `${columnPath}.codecId`,\n code: 'type_consistency_warning',\n message: `codecId \"${contractColumn.codecId}\" maps to nativeType \"${typeMetadata.nativeType}\" in registry, but contract has \"${contractNativeType}\"`,\n expected: typeMetadata.nativeType,\n actual: contractNativeType,\n children: [],\n });\n }\n }\n\n // Compare nullability\n if (contractColumn.nullable !== schemaColumn.nullable) {\n issues.push({\n kind: 'nullability_mismatch',\n table: tableName,\n column: columnName,\n expected: String(contractColumn.nullable),\n actual: String(schemaColumn.nullable),\n message: `Column \"${tableName}\".\"${columnName}\" has nullability mismatch: expected ${contractColumn.nullable ? 'nullable' : 'not null'}, got ${schemaColumn.nullable ? 'nullable' : 'not null'}`,\n });\n columnChildren.push({\n status: 'fail',\n kind: 'nullability',\n name: 'nullability',\n contractPath: `${columnPath}.nullable`,\n code: 'nullability_mismatch',\n message: `Nullability mismatch: expected ${contractColumn.nullable ? 'nullable' : 'not null'}, got ${schemaColumn.nullable ? 'nullable' : 'not null'}`,\n expected: contractColumn.nullable,\n actual: schemaColumn.nullable,\n children: [],\n });\n columnStatus = 'fail';\n }\n\n // Compute column status from children (fail > warn > pass)\n const computedColumnStatus = columnChildren.some((c) => c.status === 'fail')\n ? 'fail'\n : columnChildren.some((c) => c.status === 'warn')\n ? 'warn'\n : 'pass';\n // Use computed status if we have children, otherwise use the manually set status\n const finalColumnStatus = columnChildren.length > 0 ? computedColumnStatus : columnStatus;\n\n // Build column node\n const nullableText = contractColumn.nullable ? 'nullable' : 'not nullable';\n const columnTypeDisplay = contractColumn.codecId\n ? `${contractNativeType} (${contractColumn.codecId})`\n : contractNativeType;\n // Collect failure messages from children to create a summary message\n const failureMessages = columnChildren\n .filter((child) => child.status === 'fail' && child.message)\n .map((child) => child.message)\n .filter((msg): msg is string => typeof msg === 'string' && msg.length > 0);\n const columnMessage =\n finalColumnStatus === 'fail' && failureMessages.length > 0\n ? failureMessages.join('; ')\n : '';\n // Extract code from first child if status indicates an issue\n const columnCode =\n (finalColumnStatus === 'fail' || finalColumnStatus === 'warn') && columnChildren[0]\n ? columnChildren[0].code\n : '';\n columnNodes.push({\n status: finalColumnStatus,\n kind: 'column',\n name: `${columnName}: ${columnTypeDisplay} (${nullableText})`,\n contractPath: columnPath,\n code: columnCode,\n message: columnMessage,\n expected: undefined,\n actual: undefined,\n children: columnChildren,\n });\n }\n\n // Group columns under a \"columns\" header if we have any columns\n if (columnNodes.length > 0) {\n const columnsStatus = columnNodes.some((c) => c.status === 'fail')\n ? 'fail'\n : columnNodes.some((c) => c.status === 'warn')\n ? 'warn'\n : 'pass';\n tableChildren.push({\n status: columnsStatus,\n kind: 'columns',\n name: 'columns',\n contractPath: `${tablePath}.columns`,\n code: '',\n message: '',\n expected: undefined,\n actual: undefined,\n children: columnNodes,\n });\n }\n\n // Check for extra columns in strict mode\n if (strict) {\n for (const [columnName, { nativeType }] of Object.entries(schemaTable.columns)) {\n if (!contractTable.columns[columnName]) {\n issues.push({\n kind: 'extra_column',\n table: tableName,\n column: columnName,\n message: `Extra column \"${tableName}\".\"${columnName}\" found in database (not in contract)`,\n });\n columnNodes.push({\n status: 'fail',\n kind: 'column',\n name: `${columnName}: extra`,\n contractPath: `${tablePath}.columns.${columnName}`,\n code: 'extra_column',\n message: `Extra column \"${columnName}\" found`,\n expected: undefined,\n actual: nativeType,\n children: [],\n });\n }\n }\n }\n\n // Compare primary key\n if (contractTable.primaryKey) {\n const pkStatus = verifyPrimaryKey(\n contractTable.primaryKey,\n schemaTable.primaryKey,\n tableName,\n issues,\n );\n if (pkStatus === 'fail') {\n tableChildren.push({\n status: 'fail',\n kind: 'primaryKey',\n name: `primary key: ${contractTable.primaryKey.columns.join(', ')}`,\n contractPath: `${tablePath}.primaryKey`,\n code: 'primary_key_mismatch',\n message: 'Primary key mismatch',\n expected: contractTable.primaryKey,\n actual: schemaTable.primaryKey,\n children: [],\n });\n } else {\n tableChildren.push({\n status: 'pass',\n kind: 'primaryKey',\n name: `primary key: ${contractTable.primaryKey.columns.join(', ')}`,\n contractPath: `${tablePath}.primaryKey`,\n code: '',\n message: '',\n expected: undefined,\n actual: undefined,\n children: [],\n });\n }\n } else if (schemaTable.primaryKey && strict) {\n // Extra primary key in strict mode\n issues.push({\n kind: 'extra_primary_key',\n table: tableName,\n message: 'Extra primary key found in database (not in contract)',\n });\n tableChildren.push({\n status: 'fail',\n kind: 'primaryKey',\n name: `primary key: ${schemaTable.primaryKey.columns.join(', ')}`,\n contractPath: `${tablePath}.primaryKey`,\n code: 'extra_primary_key',\n message: 'Extra primary key found',\n expected: undefined,\n actual: schemaTable.primaryKey,\n children: [],\n });\n }\n\n // Compare foreign keys\n const fkStatuses = verifyForeignKeys(\n contractTable.foreignKeys,\n schemaTable.foreignKeys,\n tableName,\n tablePath,\n issues,\n strict,\n );\n tableChildren.push(...fkStatuses);\n\n // Compare unique constraints\n // Pass schemaIndexes so unique indexes can satisfy unique constraint requirements\n const uniqueStatuses = verifyUniqueConstraints(\n contractTable.uniques,\n schemaTable.uniques,\n schemaTable.indexes,\n tableName,\n tablePath,\n issues,\n strict,\n );\n tableChildren.push(...uniqueStatuses);\n\n // Compare indexes\n // Pass schemaUniques so unique constraints can satisfy index requirements\n const indexStatuses = verifyIndexes(\n contractTable.indexes,\n schemaTable.indexes,\n schemaTable.uniques,\n tableName,\n tablePath,\n issues,\n strict,\n );\n tableChildren.push(...indexStatuses);\n\n // Build table node\n const tableStatus = tableChildren.some((c) => c.status === 'fail')\n ? 'fail'\n : tableChildren.some((c) => c.status === 'warn')\n ? 'warn'\n : 'pass';\n // Collect failure messages from children to create a summary message\n const tableFailureMessages = tableChildren\n .filter((child) => child.status === 'fail' && child.message)\n .map((child) => child.message)\n .filter((msg): msg is string => typeof msg === 'string' && msg.length > 0);\n const tableMessage =\n tableStatus === 'fail' && tableFailureMessages.length > 0\n ? `${tableFailureMessages.length} issue${tableFailureMessages.length === 1 ? '' : 's'}`\n : '';\n const tableCode =\n tableStatus === 'fail' && tableChildren.length > 0 && tableChildren[0]\n ? tableChildren[0].code\n : '';\n rootChildren.push({\n status: tableStatus,\n kind: 'table',\n name: `table ${tableName}`,\n contractPath: tablePath,\n code: tableCode,\n message: tableMessage,\n expected: undefined,\n actual: undefined,\n children: tableChildren,\n });\n }\n\n // Check for extra tables in strict mode\n if (strict) {\n for (const tableName of Object.keys(schemaTables)) {\n if (!contractTables[tableName]) {\n issues.push({\n kind: 'extra_table',\n table: tableName,\n message: `Extra table \"${tableName}\" found in database (not in contract)`,\n });\n rootChildren.push({\n status: 'fail',\n kind: 'table',\n name: `table ${tableName}`,\n contractPath: `storage.tables.${tableName}`,\n code: 'extra_table',\n message: `Extra table \"${tableName}\" found`,\n expected: undefined,\n actual: undefined,\n children: [],\n });\n }\n }\n }\n\n // Validate that all extension packs declared in the contract are present in frameworkComponents\n // This is a configuration integrity check - if the contract was emitted with an extension,\n // that extension must be provided in the current configuration.\n // Note: contract.extensionPacks includes adapter.id and target.id (from extractExtensionIds),\n // so we check for matches as extension, adapter, or target components.\n const contractExtensionPacks = contract.extensionPacks ?? {};\n for (const extensionNamespace of Object.keys(contractExtensionPacks)) {\n const hasComponent = options.frameworkComponents.some(\n (component) =>\n component.id === extensionNamespace &&\n (component.kind === 'extension' ||\n component.kind === 'adapter' ||\n component.kind === 'target'),\n );\n if (!hasComponent) {\n throw new Error(\n `Extension pack '${extensionNamespace}' is declared in the contract but not found in framework components. ` +\n 'This indicates a configuration mismatch - the contract was emitted with this extension pack, ' +\n 'but it is not provided in the current configuration.',\n );\n }\n }\n\n // Compare component-owned database dependencies (pure, deterministic)\n // Per ADR 154: We do NOT infer dependencies from contract extension packs.\n // Dependencies are only collected from frameworkComponents provided by the CLI.\n const databaseDependencies = collectDependenciesFromFrameworkComponents(\n options.frameworkComponents,\n );\n const dependencyStatuses = verifyDatabaseDependencies(databaseDependencies, schema, issues);\n rootChildren.push(...dependencyStatuses);\n\n // Build root node\n const rootStatus = rootChildren.some((c) => c.status === 'fail')\n ? 'fail'\n : rootChildren.some((c) => c.status === 'warn')\n ? 'warn'\n : 'pass';\n const root: SchemaVerificationNode = {\n status: rootStatus,\n kind: 'contract',\n name: 'contract',\n contractPath: '',\n code: '',\n message: '',\n expected: undefined,\n actual: undefined,\n children: rootChildren,\n };\n\n // Compute counts\n const counts = computeCounts(root);\n\n // Set ok flag\n const ok = counts.fail === 0;\n\n // Set code\n const code = ok ? undefined : 'PN-SCHEMA-0001';\n\n // Set summary\n const summary = ok\n ? 'Database schema satisfies contract'\n : `Database schema does not satisfy contract (${counts.fail} failure${counts.fail === 1 ? '' : 's'})`;\n\n const totalTime = Date.now() - startTime;\n\n return {\n ok,\n ...ifDefined('code', code),\n summary,\n contract: {\n coreHash: contractCoreHash,\n ...ifDefined('profileHash', contractProfileHash),\n },\n target: {\n expected: contractTarget,\n actual: contractTarget,\n },\n schema: {\n issues,\n root,\n counts,\n },\n meta: {\n strict,\n ...ifDefined('contractPath', context?.contractPath),\n ...ifDefined('configPath', context?.configPath),\n },\n timings: {\n total: totalTime,\n },\n };\n}\n\n/**\n * Type predicate to check if a component has database dependencies with an init array.\n * The familyId check is redundant since TargetBoundComponentDescriptor<'sql', T> already\n * guarantees familyId is 'sql' at the type level, so we don't need runtime checks for it.\n */\nfunction hasDatabaseDependenciesInit<T extends string>(\n component: TargetBoundComponentDescriptor<'sql', T>,\n): component is TargetBoundComponentDescriptor<'sql', T> & {\n readonly databaseDependencies: {\n readonly init: readonly ComponentDatabaseDependency<T>[];\n };\n} {\n if (!('databaseDependencies' in component)) {\n return false;\n }\n const dbDeps = (component as Record<string, unknown>)['databaseDependencies'];\n if (dbDeps === undefined || dbDeps === null || typeof dbDeps !== 'object') {\n return false;\n }\n const depsRecord = dbDeps as Record<string, unknown>;\n const init = depsRecord['init'];\n if (init === undefined || !Array.isArray(init)) {\n return false;\n }\n return true;\n}\n\nfunction collectDependenciesFromFrameworkComponents<T extends string>(\n components: ReadonlyArray<TargetBoundComponentDescriptor<'sql', T>>,\n): ReadonlyArray<ComponentDatabaseDependency<T>> {\n const dependencies: ComponentDatabaseDependency<T>[] = [];\n for (const component of components) {\n if (hasDatabaseDependenciesInit(component)) {\n dependencies.push(...component.databaseDependencies.init);\n }\n }\n return dependencies;\n}\n"],"mappings":";AAuBO,SAAS,YAAY,GAAsB,GAA+B;AAC/E,MAAI,EAAE,WAAW,EAAE,QAAQ;AACzB,WAAO;AAAA,EACT;AACA,WAAS,IAAI,GAAG,IAAI,EAAE,QAAQ,KAAK;AACjC,QAAI,EAAE,CAAC,MAAM,EAAE,CAAC,GAAG;AACjB,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAqBO,SAAS,4BACd,SACA,SACA,SACS;AAET,QAAM,gBAAgB,QAAQ,KAAK,CAAC,WAAW,YAAY,OAAO,SAAS,OAAO,CAAC;AACnF,MAAI,eAAe;AACjB,WAAO;AAAA,EACT;AAEA,SAAO,QAAQ,KAAK,CAAC,UAAU,MAAM,UAAU,YAAY,MAAM,S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,IAAI,GAAG;AAC9C,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEA,SAAS,2CACP,YAC+C;AAC/C,QAAM,eAAiD,CAAC;AACxD,aAAW,aAAa,YAAY;AAClC,QAAI,4BAA4B,SAAS,GAAG;AAC1C,mBAAa,KAAK,GAAG,UAAU,qBAAqB,IAAI;AAAA,IAC1D;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
|
@@ -10,26 +10,72 @@ import type { ComponentDatabaseDependency } from '../migrations/types';
|
|
|
10
10
|
* Compares two arrays of strings for equality (order-sensitive).
|
|
11
11
|
*/
|
|
12
12
|
export declare function arraysEqual(a: readonly string[], b: readonly string[]): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Checks if a unique constraint requirement is satisfied by the given columns.
|
|
15
|
+
*
|
|
16
|
+
* Semantic satisfaction: a unique constraint requirement can be satisfied by:
|
|
17
|
+
* - A unique constraint with the same columns, OR
|
|
18
|
+
* - A unique index with the same columns
|
|
19
|
+
*
|
|
20
|
+
* @param uniques - The unique constraints in the schema table
|
|
21
|
+
* @param indexes - The indexes in the schema table
|
|
22
|
+
* @param columns - The columns required by the unique constraint
|
|
23
|
+
* @returns true if the requirement is satisfied
|
|
24
|
+
*/
|
|
25
|
+
export declare function isUniqueConstraintSatisfied(uniques: readonly SqlUniqueIR[], indexes: readonly SqlIndexIR[], columns: readonly string[]): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Checks if an index requirement is satisfied by the given columns.
|
|
28
|
+
*
|
|
29
|
+
* Semantic satisfaction: a non-unique index requirement can be satisfied by:
|
|
30
|
+
* - Any index (unique or non-unique) with the same columns, OR
|
|
31
|
+
* - A unique constraint with the same columns (stronger satisfies weaker)
|
|
32
|
+
*
|
|
33
|
+
* @param indexes - The indexes in the schema table
|
|
34
|
+
* @param uniques - The unique constraints in the schema table
|
|
35
|
+
* @param columns - The columns required by the index
|
|
36
|
+
* @returns true if the requirement is satisfied
|
|
37
|
+
*/
|
|
38
|
+
export declare function isIndexSatisfied(indexes: readonly SqlIndexIR[], uniques: readonly SqlUniqueIR[], columns: readonly string[]): boolean;
|
|
13
39
|
/**
|
|
14
40
|
* Verifies primary key matches between contract and schema.
|
|
15
41
|
* Returns 'pass' or 'fail'.
|
|
42
|
+
*
|
|
43
|
+
* Uses semantic satisfaction: identity is based on (table + kind + columns).
|
|
44
|
+
* Name differences are ignored by default (names are for DDL/diagnostics, not identity).
|
|
16
45
|
*/
|
|
17
46
|
export declare function verifyPrimaryKey(contractPK: PrimaryKey, schemaPK: PrimaryKey | undefined, tableName: string, issues: SchemaIssue[]): 'pass' | 'fail';
|
|
18
47
|
/**
|
|
19
48
|
* Verifies foreign keys match between contract and schema.
|
|
20
49
|
* Returns verification nodes for the tree.
|
|
50
|
+
*
|
|
51
|
+
* Uses semantic satisfaction: identity is based on (table + columns + referenced table + referenced columns).
|
|
52
|
+
* Name differences are ignored by default (names are for DDL/diagnostics, not identity).
|
|
21
53
|
*/
|
|
22
54
|
export declare function verifyForeignKeys(contractFKs: readonly ForeignKey[], schemaFKs: readonly SqlForeignKeyIR[], tableName: string, tablePath: string, issues: SchemaIssue[], strict: boolean): SchemaVerificationNode[];
|
|
23
55
|
/**
|
|
24
56
|
* Verifies unique constraints match between contract and schema.
|
|
25
57
|
* Returns verification nodes for the tree.
|
|
58
|
+
*
|
|
59
|
+
* Uses semantic satisfaction: identity is based on (table + kind + columns).
|
|
60
|
+
* A unique constraint requirement can be satisfied by either:
|
|
61
|
+
* - A unique constraint with the same columns, or
|
|
62
|
+
* - A unique index with the same columns
|
|
63
|
+
*
|
|
64
|
+
* Name differences are ignored by default (names are for DDL/diagnostics, not identity).
|
|
26
65
|
*/
|
|
27
|
-
export declare function verifyUniqueConstraints(contractUniques: readonly UniqueConstraint[], schemaUniques: readonly SqlUniqueIR[], tableName: string, tablePath: string, issues: SchemaIssue[], strict: boolean): SchemaVerificationNode[];
|
|
66
|
+
export declare function verifyUniqueConstraints(contractUniques: readonly UniqueConstraint[], schemaUniques: readonly SqlUniqueIR[], schemaIndexes: readonly SqlIndexIR[], tableName: string, tablePath: string, issues: SchemaIssue[], strict: boolean): SchemaVerificationNode[];
|
|
28
67
|
/**
|
|
29
68
|
* Verifies indexes match between contract and schema.
|
|
30
69
|
* Returns verification nodes for the tree.
|
|
70
|
+
*
|
|
71
|
+
* Uses semantic satisfaction: identity is based on (table + kind + columns).
|
|
72
|
+
* A non-unique index requirement can be satisfied by either:
|
|
73
|
+
* - A non-unique index with the same columns, or
|
|
74
|
+
* - A unique index with the same columns (stronger satisfies weaker)
|
|
75
|
+
*
|
|
76
|
+
* Name differences are ignored by default (names are for DDL/diagnostics, not identity).
|
|
31
77
|
*/
|
|
32
|
-
export declare function verifyIndexes(contractIndexes: readonly Index[], schemaIndexes: readonly SqlIndexIR[], tableName: string, tablePath: string, issues: SchemaIssue[], strict: boolean): SchemaVerificationNode[];
|
|
78
|
+
export declare function verifyIndexes(contractIndexes: readonly Index[], schemaIndexes: readonly SqlIndexIR[], schemaUniques: readonly SqlUniqueIR[], tableName: string, tablePath: string, issues: SchemaIssue[], strict: boolean): SchemaVerificationNode[];
|
|
33
79
|
/**
|
|
34
80
|
* Verifies database dependencies are installed using component-owned verification hooks.
|
|
35
81
|
* Each dependency provides a pure verifyDatabaseDependencyInstalled function that checks
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify-helpers.d.ts","sourceRoot":"","sources":["../../../src/core/schema-verify/verify-helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AACjG,OAAO,KAAK,EACV,UAAU,EACV,KAAK,EACL,UAAU,EACV,gBAAgB,EACjB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EACV,eAAe,EACf,UAAU,EACV,WAAW,EACX,WAAW,EACZ,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,q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-schema.d.ts","sourceRoot":"","sources":["../../../src/core/schema-verify/verify-sql-schema.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,4CAA4C,CAAC;AACjG,OAAO,KAAK,EACV,gBAAgB,EAGhB,0BAA0B,EAC3B,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAYpE;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,mDAAmD;IACnD,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;IAC3C,2DAA2D;IAC3D,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,mEAAmE;IACnE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,8CAA8C;IAC9C,QAAQ,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC;IACpC,4DAA4D;IAC5D,QAAQ,CAAC,oBAAoB,EAAE,WAAW,CAAC,MAAM,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC5E;;;OAGG;IACH,QAAQ,CAAC,mBAAmB,EAAE,aAAa,CAAC,8BAA8B,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;CAC5F;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,0BAA0B,
|
|
1
|
+
{"version":3,"file":"verify-sql-schema.d.ts","sourceRoot":"","sources":["../../../src/core/schema-verify/verify-sql-schema.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,4CAA4C,CAAC;AACjG,OAAO,KAAK,EACV,gBAAgB,EAGhB,0BAA0B,EAC3B,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAYpE;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,mDAAmD;IACnD,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;IAC3C,2DAA2D;IAC3D,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,mEAAmE;IACnE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,8CAA8C;IAC9C,QAAQ,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC;IACpC,4DAA4D;IAC5D,QAAQ,CAAC,oBAAoB,EAAE,WAAW,CAAC,MAAM,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC5E;;;OAGG;IACH,QAAQ,CAAC,mBAAmB,EAAE,aAAa,CAAC,8BAA8B,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;CAC5F;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,0BAA0B,CAye3F"}
|
package/dist/exports/control.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createSqlFamilyInstance
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-F27CR6XZ.js";
|
|
4
4
|
import "../chunk-SU7LN2UH.js";
|
|
5
|
-
import "../chunk-
|
|
5
|
+
import "../chunk-XH2Y5NTD.js";
|
|
6
6
|
|
|
7
7
|
// src/core/descriptor.ts
|
|
8
8
|
import { sqlTargetFamilyHook } from "@prisma-next/sql-contract-emitter";
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* without a database connection. It's suitable for migration planning and
|
|
6
6
|
* other tools that need to compare schema states.
|
|
7
7
|
*/
|
|
8
|
-
export { arraysEqual, verifyDatabaseDependencies } from '../core/schema-verify/verify-helpers';
|
|
8
|
+
export { arraysEqual, isIndexSatisfied, isUniqueConstraintSatisfied, verifyDatabaseDependencies, } from '../core/schema-verify/verify-helpers';
|
|
9
9
|
export type { VerifySqlSchemaOptions } from '../core/schema-verify/verify-sql-schema';
|
|
10
10
|
export { verifySqlSchema } from '../core/schema-verify/verify-sql-schema';
|
|
11
11
|
//# sourceMappingURL=schema-verify.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-verify.d.ts","sourceRoot":"","sources":["../../src/exports/schema-verify.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"schema-verify.d.ts","sourceRoot":"","sources":["../../src/exports/schema-verify.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,2BAA2B,EAC3B,0BAA0B,GAC3B,MAAM,sCAAsC,CAAC;AAC9C,YAAY,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
arraysEqual,
|
|
3
|
+
isIndexSatisfied,
|
|
4
|
+
isUniqueConstraintSatisfied,
|
|
3
5
|
verifyDatabaseDependencies,
|
|
4
6
|
verifySqlSchema
|
|
5
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-XH2Y5NTD.js";
|
|
6
8
|
export {
|
|
7
9
|
arraysEqual,
|
|
10
|
+
isIndexSatisfied,
|
|
11
|
+
isUniqueConstraintSatisfied,
|
|
8
12
|
verifyDatabaseDependencies,
|
|
9
13
|
verifySqlSchema
|
|
10
14
|
};
|
|
@@ -4,9 +4,9 @@ import {
|
|
|
4
4
|
extractCodecTypeImports,
|
|
5
5
|
extractExtensionIds,
|
|
6
6
|
extractOperationTypeImports
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-F27CR6XZ.js";
|
|
8
8
|
import "../chunk-SU7LN2UH.js";
|
|
9
|
-
import "../chunk-
|
|
9
|
+
import "../chunk-XH2Y5NTD.js";
|
|
10
10
|
export {
|
|
11
11
|
assembleOperationRegistry,
|
|
12
12
|
convertOperationManifest,
|
package/package.json
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/family-sql",
|
|
3
|
-
"version": "0.3.0-pr.88.
|
|
3
|
+
"version": "0.3.0-pr.88.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "SQL family descriptor for Prisma Next",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"arktype": "^2.0.0",
|
|
9
|
-
"@prisma-next/cli": "0.3.0-pr.88.
|
|
10
|
-
"@prisma-next/contract": "0.3.0-pr.88.
|
|
11
|
-
"@prisma-next/core-control-plane": "0.3.0-pr.88.
|
|
12
|
-
"@prisma-next/core-execution-plane": "0.3.0-pr.88.
|
|
13
|
-
"@prisma-next/operations": "0.3.0-pr.88.
|
|
14
|
-
"@prisma-next/
|
|
15
|
-
"@prisma-next/sql-contract": "0.3.0-pr.88.
|
|
16
|
-
"@prisma-next/sql-contract-
|
|
17
|
-
"@prisma-next/sql-
|
|
18
|
-
"@prisma-next/sql-
|
|
19
|
-
"@prisma-next/sql-runtime": "0.3.0-pr.88.
|
|
20
|
-
"@prisma-next/sql-schema-ir": "0.3.0-pr.88.
|
|
21
|
-
"@prisma-next/
|
|
22
|
-
"@prisma-next/
|
|
9
|
+
"@prisma-next/cli": "0.3.0-pr.88.6",
|
|
10
|
+
"@prisma-next/contract": "0.3.0-pr.88.6",
|
|
11
|
+
"@prisma-next/core-control-plane": "0.3.0-pr.88.6",
|
|
12
|
+
"@prisma-next/core-execution-plane": "0.3.0-pr.88.6",
|
|
13
|
+
"@prisma-next/operations": "0.3.0-pr.88.6",
|
|
14
|
+
"@prisma-next/sql-contract": "0.3.0-pr.88.6",
|
|
15
|
+
"@prisma-next/sql-contract-emitter": "0.3.0-pr.88.6",
|
|
16
|
+
"@prisma-next/sql-contract-ts": "0.3.0-pr.88.6",
|
|
17
|
+
"@prisma-next/sql-operations": "0.3.0-pr.88.6",
|
|
18
|
+
"@prisma-next/sql-relational-core": "0.3.0-pr.88.6",
|
|
19
|
+
"@prisma-next/sql-runtime": "0.3.0-pr.88.6",
|
|
20
|
+
"@prisma-next/sql-schema-ir": "0.3.0-pr.88.6",
|
|
21
|
+
"@prisma-next/utils": "0.3.0-pr.88.6",
|
|
22
|
+
"@prisma-next/runtime-executor": "0.3.0-pr.88.6"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@vitest/coverage-v8": "4.0.16",
|
|
26
26
|
"tsup": "8.5.1",
|
|
27
27
|
"typescript": "5.9.3",
|
|
28
28
|
"vitest": "4.0.16",
|
|
29
|
-
"@prisma-next/driver-postgres": "0.3.0-pr.88.
|
|
29
|
+
"@prisma-next/driver-postgres": "0.3.0-pr.88.6",
|
|
30
30
|
"@prisma-next/test-utils": "0.0.1"
|
|
31
31
|
},
|
|
32
32
|
"files": [
|
|
@@ -33,9 +33,71 @@ export function arraysEqual(a: readonly string[], b: readonly string[]): boolean
|
|
|
33
33
|
return true;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
// ============================================================================
|
|
37
|
+
// Semantic Satisfaction Predicates
|
|
38
|
+
// ============================================================================
|
|
39
|
+
// These predicates implement the "stronger satisfies weaker" logic for storage
|
|
40
|
+
// objects. They are used by both verification and migration planning to ensure
|
|
41
|
+
// consistent behavior across the control plane.
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Checks if a unique constraint requirement is satisfied by the given columns.
|
|
45
|
+
*
|
|
46
|
+
* Semantic satisfaction: a unique constraint requirement can be satisfied by:
|
|
47
|
+
* - A unique constraint with the same columns, OR
|
|
48
|
+
* - A unique index with the same columns
|
|
49
|
+
*
|
|
50
|
+
* @param uniques - The unique constraints in the schema table
|
|
51
|
+
* @param indexes - The indexes in the schema table
|
|
52
|
+
* @param columns - The columns required by the unique constraint
|
|
53
|
+
* @returns true if the requirement is satisfied
|
|
54
|
+
*/
|
|
55
|
+
export function isUniqueConstraintSatisfied(
|
|
56
|
+
uniques: readonly SqlUniqueIR[],
|
|
57
|
+
indexes: readonly SqlIndexIR[],
|
|
58
|
+
columns: readonly string[],
|
|
59
|
+
): boolean {
|
|
60
|
+
// Check for matching unique constraint
|
|
61
|
+
const hasConstraint = uniques.some((unique) => arraysEqual(unique.columns, columns));
|
|
62
|
+
if (hasConstraint) {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
// Check for matching unique index (semantic satisfaction)
|
|
66
|
+
return indexes.some((index) => index.unique && arraysEqual(index.columns, columns));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Checks if an index requirement is satisfied by the given columns.
|
|
71
|
+
*
|
|
72
|
+
* Semantic satisfaction: a non-unique index requirement can be satisfied by:
|
|
73
|
+
* - Any index (unique or non-unique) with the same columns, OR
|
|
74
|
+
* - A unique constraint with the same columns (stronger satisfies weaker)
|
|
75
|
+
*
|
|
76
|
+
* @param indexes - The indexes in the schema table
|
|
77
|
+
* @param uniques - The unique constraints in the schema table
|
|
78
|
+
* @param columns - The columns required by the index
|
|
79
|
+
* @returns true if the requirement is satisfied
|
|
80
|
+
*/
|
|
81
|
+
export function isIndexSatisfied(
|
|
82
|
+
indexes: readonly SqlIndexIR[],
|
|
83
|
+
uniques: readonly SqlUniqueIR[],
|
|
84
|
+
columns: readonly string[],
|
|
85
|
+
): boolean {
|
|
86
|
+
// Check for any matching index (unique or non-unique)
|
|
87
|
+
const hasMatchingIndex = indexes.some((index) => arraysEqual(index.columns, columns));
|
|
88
|
+
if (hasMatchingIndex) {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
// Check for matching unique constraint (semantic satisfaction)
|
|
92
|
+
return uniques.some((unique) => arraysEqual(unique.columns, columns));
|
|
93
|
+
}
|
|
94
|
+
|
|
36
95
|
/**
|
|
37
96
|
* Verifies primary key matches between contract and schema.
|
|
38
97
|
* Returns 'pass' or 'fail'.
|
|
98
|
+
*
|
|
99
|
+
* Uses semantic satisfaction: identity is based on (table + kind + columns).
|
|
100
|
+
* Name differences are ignored by default (names are for DDL/diagnostics, not identity).
|
|
39
101
|
*/
|
|
40
102
|
export function verifyPrimaryKey(
|
|
41
103
|
contractPK: PrimaryKey,
|
|
@@ -64,18 +126,8 @@ export function verifyPrimaryKey(
|
|
|
64
126
|
return 'fail';
|
|
65
127
|
}
|
|
66
128
|
|
|
67
|
-
//
|
|
68
|
-
|
|
69
|
-
issues.push({
|
|
70
|
-
kind: 'primary_key_mismatch',
|
|
71
|
-
table: tableName,
|
|
72
|
-
indexOrConstraint: contractPK.name,
|
|
73
|
-
expected: contractPK.name,
|
|
74
|
-
actual: schemaPK.name,
|
|
75
|
-
message: `Table "${tableName}" has primary key name mismatch: expected "${contractPK.name}", got "${schemaPK.name}"`,
|
|
76
|
-
});
|
|
77
|
-
return 'fail';
|
|
78
|
-
}
|
|
129
|
+
// Name differences are ignored for semantic satisfaction.
|
|
130
|
+
// Names are persisted for deterministic DDL and diagnostics but are not identity.
|
|
79
131
|
|
|
80
132
|
return 'pass';
|
|
81
133
|
}
|
|
@@ -83,6 +135,9 @@ export function verifyPrimaryKey(
|
|
|
83
135
|
/**
|
|
84
136
|
* Verifies foreign keys match between contract and schema.
|
|
85
137
|
* Returns verification nodes for the tree.
|
|
138
|
+
*
|
|
139
|
+
* Uses semantic satisfaction: identity is based on (table + columns + referenced table + referenced columns).
|
|
140
|
+
* Name differences are ignored by default (names are for DDL/diagnostics, not identity).
|
|
86
141
|
*/
|
|
87
142
|
export function verifyForeignKeys(
|
|
88
143
|
contractFKs: readonly ForeignKey[],
|
|
@@ -124,40 +179,19 @@ export function verifyForeignKeys(
|
|
|
124
179
|
children: [],
|
|
125
180
|
});
|
|
126
181
|
} else {
|
|
127
|
-
//
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
name: `foreignKey(${contractFK.columns.join(', ')})`,
|
|
141
|
-
contractPath: fkPath,
|
|
142
|
-
code: 'foreign_key_mismatch',
|
|
143
|
-
message: 'Foreign key name mismatch',
|
|
144
|
-
expected: contractFK.name,
|
|
145
|
-
actual: matchingFK.name,
|
|
146
|
-
children: [],
|
|
147
|
-
});
|
|
148
|
-
} else {
|
|
149
|
-
nodes.push({
|
|
150
|
-
status: 'pass',
|
|
151
|
-
kind: 'foreignKey',
|
|
152
|
-
name: `foreignKey(${contractFK.columns.join(', ')})`,
|
|
153
|
-
contractPath: fkPath,
|
|
154
|
-
code: '',
|
|
155
|
-
message: '',
|
|
156
|
-
expected: undefined,
|
|
157
|
-
actual: undefined,
|
|
158
|
-
children: [],
|
|
159
|
-
});
|
|
160
|
-
}
|
|
182
|
+
// Name differences are ignored for semantic satisfaction.
|
|
183
|
+
// Names are persisted for deterministic DDL and diagnostics but are not identity.
|
|
184
|
+
nodes.push({
|
|
185
|
+
status: 'pass',
|
|
186
|
+
kind: 'foreignKey',
|
|
187
|
+
name: `foreignKey(${contractFK.columns.join(', ')})`,
|
|
188
|
+
contractPath: fkPath,
|
|
189
|
+
code: '',
|
|
190
|
+
message: '',
|
|
191
|
+
expected: undefined,
|
|
192
|
+
actual: undefined,
|
|
193
|
+
children: [],
|
|
194
|
+
});
|
|
161
195
|
}
|
|
162
196
|
}
|
|
163
197
|
|
|
@@ -199,10 +233,18 @@ export function verifyForeignKeys(
|
|
|
199
233
|
/**
|
|
200
234
|
* Verifies unique constraints match between contract and schema.
|
|
201
235
|
* Returns verification nodes for the tree.
|
|
236
|
+
*
|
|
237
|
+
* Uses semantic satisfaction: identity is based on (table + kind + columns).
|
|
238
|
+
* A unique constraint requirement can be satisfied by either:
|
|
239
|
+
* - A unique constraint with the same columns, or
|
|
240
|
+
* - A unique index with the same columns
|
|
241
|
+
*
|
|
242
|
+
* Name differences are ignored by default (names are for DDL/diagnostics, not identity).
|
|
202
243
|
*/
|
|
203
244
|
export function verifyUniqueConstraints(
|
|
204
245
|
contractUniques: readonly UniqueConstraint[],
|
|
205
246
|
schemaUniques: readonly SqlUniqueIR[],
|
|
247
|
+
schemaIndexes: readonly SqlIndexIR[],
|
|
206
248
|
tableName: string,
|
|
207
249
|
tablePath: string,
|
|
208
250
|
issues: SchemaIssue[],
|
|
@@ -213,11 +255,18 @@ export function verifyUniqueConstraints(
|
|
|
213
255
|
// Check each contract unique exists in schema
|
|
214
256
|
for (const contractUnique of contractUniques) {
|
|
215
257
|
const uniquePath = `${tablePath}.uniques[${contractUnique.columns.join(',')}]`;
|
|
258
|
+
|
|
259
|
+
// First check for a matching unique constraint
|
|
216
260
|
const matchingUnique = schemaUniques.find((u) =>
|
|
217
261
|
arraysEqual(u.columns, contractUnique.columns),
|
|
218
262
|
);
|
|
219
263
|
|
|
220
|
-
|
|
264
|
+
// If no matching constraint, check for a unique index with the same columns
|
|
265
|
+
const matchingUniqueIndex =
|
|
266
|
+
!matchingUnique &&
|
|
267
|
+
schemaIndexes.find((idx) => idx.unique && arraysEqual(idx.columns, contractUnique.columns));
|
|
268
|
+
|
|
269
|
+
if (!matchingUnique && !matchingUniqueIndex) {
|
|
221
270
|
issues.push({
|
|
222
271
|
kind: 'unique_constraint_mismatch',
|
|
223
272
|
table: tableName,
|
|
@@ -236,44 +285,19 @@ export function verifyUniqueConstraints(
|
|
|
236
285
|
children: [],
|
|
237
286
|
});
|
|
238
287
|
} else {
|
|
239
|
-
//
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
});
|
|
253
|
-
nodes.push({
|
|
254
|
-
status: 'fail',
|
|
255
|
-
kind: 'unique',
|
|
256
|
-
name: `unique(${contractUnique.columns.join(', ')})`,
|
|
257
|
-
contractPath: uniquePath,
|
|
258
|
-
code: 'unique_constraint_mismatch',
|
|
259
|
-
message: 'Unique constraint name mismatch',
|
|
260
|
-
expected: contractUnique.name,
|
|
261
|
-
actual: matchingUnique.name,
|
|
262
|
-
children: [],
|
|
263
|
-
});
|
|
264
|
-
} else {
|
|
265
|
-
nodes.push({
|
|
266
|
-
status: 'pass',
|
|
267
|
-
kind: 'unique',
|
|
268
|
-
name: `unique(${contractUnique.columns.join(', ')})`,
|
|
269
|
-
contractPath: uniquePath,
|
|
270
|
-
code: '',
|
|
271
|
-
message: '',
|
|
272
|
-
expected: undefined,
|
|
273
|
-
actual: undefined,
|
|
274
|
-
children: [],
|
|
275
|
-
});
|
|
276
|
-
}
|
|
288
|
+
// Name differences are ignored for semantic satisfaction.
|
|
289
|
+
// Names are persisted for deterministic DDL and diagnostics but are not identity.
|
|
290
|
+
nodes.push({
|
|
291
|
+
status: 'pass',
|
|
292
|
+
kind: 'unique',
|
|
293
|
+
name: `unique(${contractUnique.columns.join(', ')})`,
|
|
294
|
+
contractPath: uniquePath,
|
|
295
|
+
code: '',
|
|
296
|
+
message: '',
|
|
297
|
+
expected: undefined,
|
|
298
|
+
actual: undefined,
|
|
299
|
+
children: [],
|
|
300
|
+
});
|
|
277
301
|
}
|
|
278
302
|
}
|
|
279
303
|
|
|
@@ -311,10 +335,18 @@ export function verifyUniqueConstraints(
|
|
|
311
335
|
/**
|
|
312
336
|
* Verifies indexes match between contract and schema.
|
|
313
337
|
* Returns verification nodes for the tree.
|
|
338
|
+
*
|
|
339
|
+
* Uses semantic satisfaction: identity is based on (table + kind + columns).
|
|
340
|
+
* A non-unique index requirement can be satisfied by either:
|
|
341
|
+
* - A non-unique index with the same columns, or
|
|
342
|
+
* - A unique index with the same columns (stronger satisfies weaker)
|
|
343
|
+
*
|
|
344
|
+
* Name differences are ignored by default (names are for DDL/diagnostics, not identity).
|
|
314
345
|
*/
|
|
315
346
|
export function verifyIndexes(
|
|
316
347
|
contractIndexes: readonly Index[],
|
|
317
348
|
schemaIndexes: readonly SqlIndexIR[],
|
|
349
|
+
schemaUniques: readonly SqlUniqueIR[],
|
|
318
350
|
tableName: string,
|
|
319
351
|
tablePath: string,
|
|
320
352
|
issues: SchemaIssue[],
|
|
@@ -325,11 +357,18 @@ export function verifyIndexes(
|
|
|
325
357
|
// Check each contract index exists in schema
|
|
326
358
|
for (const contractIndex of contractIndexes) {
|
|
327
359
|
const indexPath = `${tablePath}.indexes[${contractIndex.columns.join(',')}]`;
|
|
328
|
-
|
|
329
|
-
|
|
360
|
+
|
|
361
|
+
// Check for any matching index (unique or non-unique)
|
|
362
|
+
// A unique index can satisfy a non-unique index requirement (stronger satisfies weaker)
|
|
363
|
+
const matchingIndex = schemaIndexes.find((idx) =>
|
|
364
|
+
arraysEqual(idx.columns, contractIndex.columns),
|
|
330
365
|
);
|
|
331
366
|
|
|
332
|
-
if
|
|
367
|
+
// Also check if a unique constraint satisfies the index requirement
|
|
368
|
+
const matchingUniqueConstraint =
|
|
369
|
+
!matchingIndex && schemaUniques.find((u) => arraysEqual(u.columns, contractIndex.columns));
|
|
370
|
+
|
|
371
|
+
if (!matchingIndex && !matchingUniqueConstraint) {
|
|
333
372
|
issues.push({
|
|
334
373
|
kind: 'index_mismatch',
|
|
335
374
|
table: tableName,
|
|
@@ -348,40 +387,19 @@ export function verifyIndexes(
|
|
|
348
387
|
children: [],
|
|
349
388
|
});
|
|
350
389
|
} else {
|
|
351
|
-
//
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
name: `index(${contractIndex.columns.join(', ')})`,
|
|
365
|
-
contractPath: indexPath,
|
|
366
|
-
code: 'index_mismatch',
|
|
367
|
-
message: 'Index name mismatch',
|
|
368
|
-
expected: contractIndex.name,
|
|
369
|
-
actual: matchingIndex.name,
|
|
370
|
-
children: [],
|
|
371
|
-
});
|
|
372
|
-
} else {
|
|
373
|
-
nodes.push({
|
|
374
|
-
status: 'pass',
|
|
375
|
-
kind: 'index',
|
|
376
|
-
name: `index(${contractIndex.columns.join(', ')})`,
|
|
377
|
-
contractPath: indexPath,
|
|
378
|
-
code: '',
|
|
379
|
-
message: '',
|
|
380
|
-
expected: undefined,
|
|
381
|
-
actual: undefined,
|
|
382
|
-
children: [],
|
|
383
|
-
});
|
|
384
|
-
}
|
|
390
|
+
// Name differences are ignored for semantic satisfaction.
|
|
391
|
+
// Names are persisted for deterministic DDL and diagnostics but are not identity.
|
|
392
|
+
nodes.push({
|
|
393
|
+
status: 'pass',
|
|
394
|
+
kind: 'index',
|
|
395
|
+
name: `index(${contractIndex.columns.join(', ')})`,
|
|
396
|
+
contractPath: indexPath,
|
|
397
|
+
code: '',
|
|
398
|
+
message: '',
|
|
399
|
+
expected: undefined,
|
|
400
|
+
actual: undefined,
|
|
401
|
+
children: [],
|
|
402
|
+
});
|
|
385
403
|
}
|
|
386
404
|
}
|
|
387
405
|
|
|
@@ -373,9 +373,11 @@ export function verifySqlSchema(options: VerifySqlSchemaOptions): VerifyDatabase
|
|
|
373
373
|
tableChildren.push(...fkStatuses);
|
|
374
374
|
|
|
375
375
|
// Compare unique constraints
|
|
376
|
+
// Pass schemaIndexes so unique indexes can satisfy unique constraint requirements
|
|
376
377
|
const uniqueStatuses = verifyUniqueConstraints(
|
|
377
378
|
contractTable.uniques,
|
|
378
379
|
schemaTable.uniques,
|
|
380
|
+
schemaTable.indexes,
|
|
379
381
|
tableName,
|
|
380
382
|
tablePath,
|
|
381
383
|
issues,
|
|
@@ -384,9 +386,11 @@ export function verifySqlSchema(options: VerifySqlSchemaOptions): VerifyDatabase
|
|
|
384
386
|
tableChildren.push(...uniqueStatuses);
|
|
385
387
|
|
|
386
388
|
// Compare indexes
|
|
389
|
+
// Pass schemaUniques so unique constraints can satisfy index requirements
|
|
387
390
|
const indexStatuses = verifyIndexes(
|
|
388
391
|
contractTable.indexes,
|
|
389
392
|
schemaTable.indexes,
|
|
393
|
+
schemaTable.uniques,
|
|
390
394
|
tableName,
|
|
391
395
|
tablePath,
|
|
392
396
|
issues,
|
|
@@ -6,6 +6,11 @@
|
|
|
6
6
|
* other tools that need to compare schema states.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
export {
|
|
9
|
+
export {
|
|
10
|
+
arraysEqual,
|
|
11
|
+
isIndexSatisfied,
|
|
12
|
+
isUniqueConstraintSatisfied,
|
|
13
|
+
verifyDatabaseDependencies,
|
|
14
|
+
} from '../core/schema-verify/verify-helpers';
|
|
10
15
|
export type { VerifySqlSchemaOptions } from '../core/schema-verify/verify-sql-schema';
|
|
11
16
|
export { verifySqlSchema } from '../core/schema-verify/verify-sql-schema';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/schema-verify/verify-helpers.ts","../src/core/schema-verify/verify-sql-schema.ts"],"sourcesContent":["/**\n * Pure verification helper functions for SQL schema verification.\n * These functions verify schema IR against contract requirements.\n */\n\nimport type { SchemaIssue, SchemaVerificationNode } from '@prisma-next/core-control-plane/types';\nimport type {\n ForeignKey,\n Index,\n PrimaryKey,\n UniqueConstraint,\n} from '@prisma-next/sql-contract/types';\nimport type {\n SqlForeignKeyIR,\n SqlIndexIR,\n SqlSchemaIR,\n SqlUniqueIR,\n} from '@prisma-next/sql-schema-ir/types';\nimport type { ComponentDatabaseDependency } from '../migrations/types';\n\n/**\n * Compares two arrays of strings for equality (order-sensitive).\n */\nexport function arraysEqual(a: readonly string[], b: readonly string[]): boolean {\n if (a.length !== b.length) {\n return false;\n }\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Verifies primary key matches between contract and schema.\n * Returns 'pass' or 'fail'.\n */\nexport function verifyPrimaryKey(\n contractPK: PrimaryKey,\n schemaPK: PrimaryKey | undefined,\n tableName: string,\n issues: SchemaIssue[],\n): 'pass' | 'fail' {\n if (!schemaPK) {\n issues.push({\n kind: 'primary_key_mismatch',\n table: tableName,\n expected: contractPK.columns.join(', '),\n message: `Table \"${tableName}\" is missing primary key`,\n });\n return 'fail';\n }\n\n if (!arraysEqual(contractPK.columns, schemaPK.columns)) {\n issues.push({\n kind: 'primary_key_mismatch',\n table: tableName,\n expected: contractPK.columns.join(', '),\n actual: schemaPK.columns.join(', '),\n message: `Table \"${tableName}\" has primary key mismatch: expected columns [${contractPK.columns.join(', ')}], got [${schemaPK.columns.join(', ')}]`,\n });\n return 'fail';\n }\n\n // Compare name if both are modeled\n if (contractPK.name && schemaPK.name && contractPK.name !== schemaPK.name) {\n issues.push({\n kind: 'primary_key_mismatch',\n table: tableName,\n indexOrConstraint: contractPK.name,\n expected: contractPK.name,\n actual: schemaPK.name,\n message: `Table \"${tableName}\" has primary key name mismatch: expected \"${contractPK.name}\", got \"${schemaPK.name}\"`,\n });\n return 'fail';\n }\n\n return 'pass';\n}\n\n/**\n * Verifies foreign keys match between contract and schema.\n * Returns verification nodes for the tree.\n */\nexport function verifyForeignKeys(\n contractFKs: readonly ForeignKey[],\n schemaFKs: readonly SqlForeignKeyIR[],\n tableName: string,\n tablePath: string,\n issues: SchemaIssue[],\n strict: boolean,\n): SchemaVerificationNode[] {\n const nodes: SchemaVerificationNode[] = [];\n\n // Check each contract FK exists in schema\n for (const contractFK of contractFKs) {\n const fkPath = `${tablePath}.foreignKeys[${contractFK.columns.join(',')}]`;\n const matchingFK = schemaFKs.find((fk) => {\n return (\n arraysEqual(fk.columns, contractFK.columns) &&\n fk.referencedTable === contractFK.references.table &&\n arraysEqual(fk.referencedColumns, contractFK.references.columns)\n );\n });\n\n if (!matchingFK) {\n issues.push({\n kind: 'foreign_key_mismatch',\n table: tableName,\n expected: `${contractFK.columns.join(', ')} -> ${contractFK.references.table}(${contractFK.references.columns.join(', ')})`,\n message: `Table \"${tableName}\" is missing foreign key: ${contractFK.columns.join(', ')} -> ${contractFK.references.table}(${contractFK.references.columns.join(', ')})`,\n });\n nodes.push({\n status: 'fail',\n kind: 'foreignKey',\n name: `foreignKey(${contractFK.columns.join(', ')})`,\n contractPath: fkPath,\n code: 'foreign_key_mismatch',\n message: 'Foreign key missing',\n expected: contractFK,\n actual: undefined,\n children: [],\n });\n } else {\n // Compare name if both are modeled\n if (contractFK.name && matchingFK.name && contractFK.name !== matchingFK.name) {\n issues.push({\n kind: 'foreign_key_mismatch',\n table: tableName,\n indexOrConstraint: contractFK.name,\n expected: contractFK.name,\n actual: matchingFK.name,\n message: `Table \"${tableName}\" has foreign key name mismatch: expected \"${contractFK.name}\", got \"${matchingFK.name}\"`,\n });\n nodes.push({\n status: 'fail',\n kind: 'foreignKey',\n name: `foreignKey(${contractFK.columns.join(', ')})`,\n contractPath: fkPath,\n code: 'foreign_key_mismatch',\n message: 'Foreign key name mismatch',\n expected: contractFK.name,\n actual: matchingFK.name,\n children: [],\n });\n } else {\n nodes.push({\n status: 'pass',\n kind: 'foreignKey',\n name: `foreignKey(${contractFK.columns.join(', ')})`,\n contractPath: fkPath,\n code: '',\n message: '',\n expected: undefined,\n actual: undefined,\n children: [],\n });\n }\n }\n }\n\n // Check for extra FKs in strict mode\n if (strict) {\n for (const schemaFK of schemaFKs) {\n const matchingFK = contractFKs.find((fk) => {\n return (\n arraysEqual(fk.columns, schemaFK.columns) &&\n fk.references.table === schemaFK.referencedTable &&\n arraysEqual(fk.references.columns, schemaFK.referencedColumns)\n );\n });\n\n if (!matchingFK) {\n issues.push({\n kind: 'extra_foreign_key',\n table: tableName,\n message: `Extra foreign key found in database (not in contract): ${schemaFK.columns.join(', ')} -> ${schemaFK.referencedTable}(${schemaFK.referencedColumns.join(', ')})`,\n });\n nodes.push({\n status: 'fail',\n kind: 'foreignKey',\n name: `foreignKey(${schemaFK.columns.join(', ')})`,\n contractPath: `${tablePath}.foreignKeys[${schemaFK.columns.join(',')}]`,\n code: 'extra_foreign_key',\n message: 'Extra foreign key found',\n expected: undefined,\n actual: schemaFK,\n children: [],\n });\n }\n }\n }\n\n return nodes;\n}\n\n/**\n * Verifies unique constraints match between contract and schema.\n * Returns verification nodes for the tree.\n */\nexport function verifyUniqueConstraints(\n contractUniques: readonly UniqueConstraint[],\n schemaUniques: readonly SqlUniqueIR[],\n tableName: string,\n tablePath: string,\n issues: SchemaIssue[],\n strict: boolean,\n): SchemaVerificationNode[] {\n const nodes: SchemaVerificationNode[] = [];\n\n // Check each contract unique exists in schema\n for (const contractUnique of contractUniques) {\n const uniquePath = `${tablePath}.uniques[${contractUnique.columns.join(',')}]`;\n const matchingUnique = schemaUniques.find((u) =>\n arraysEqual(u.columns, contractUnique.columns),\n );\n\n if (!matchingUnique) {\n issues.push({\n kind: 'unique_constraint_mismatch',\n table: tableName,\n expected: contractUnique.columns.join(', '),\n message: `Table \"${tableName}\" is missing unique constraint: ${contractUnique.columns.join(', ')}`,\n });\n nodes.push({\n status: 'fail',\n kind: 'unique',\n name: `unique(${contractUnique.columns.join(', ')})`,\n contractPath: uniquePath,\n code: 'unique_constraint_mismatch',\n message: 'Unique constraint missing',\n expected: contractUnique,\n actual: undefined,\n children: [],\n });\n } else {\n // Compare name if both are modeled\n if (\n contractUnique.name &&\n matchingUnique.name &&\n contractUnique.name !== matchingUnique.name\n ) {\n issues.push({\n kind: 'unique_constraint_mismatch',\n table: tableName,\n indexOrConstraint: contractUnique.name,\n expected: contractUnique.name,\n actual: matchingUnique.name,\n message: `Table \"${tableName}\" has unique constraint name mismatch: expected \"${contractUnique.name}\", got \"${matchingUnique.name}\"`,\n });\n nodes.push({\n status: 'fail',\n kind: 'unique',\n name: `unique(${contractUnique.columns.join(', ')})`,\n contractPath: uniquePath,\n code: 'unique_constraint_mismatch',\n message: 'Unique constraint name mismatch',\n expected: contractUnique.name,\n actual: matchingUnique.name,\n children: [],\n });\n } else {\n nodes.push({\n status: 'pass',\n kind: 'unique',\n name: `unique(${contractUnique.columns.join(', ')})`,\n contractPath: uniquePath,\n code: '',\n message: '',\n expected: undefined,\n actual: undefined,\n children: [],\n });\n }\n }\n }\n\n // Check for extra uniques in strict mode\n if (strict) {\n for (const schemaUnique of schemaUniques) {\n const matchingUnique = contractUniques.find((u) =>\n arraysEqual(u.columns, schemaUnique.columns),\n );\n\n if (!matchingUnique) {\n issues.push({\n kind: 'extra_unique_constraint',\n table: tableName,\n message: `Extra unique constraint found in database (not in contract): ${schemaUnique.columns.join(', ')}`,\n });\n nodes.push({\n status: 'fail',\n kind: 'unique',\n name: `unique(${schemaUnique.columns.join(', ')})`,\n contractPath: `${tablePath}.uniques[${schemaUnique.columns.join(',')}]`,\n code: 'extra_unique_constraint',\n message: 'Extra unique constraint found',\n expected: undefined,\n actual: schemaUnique,\n children: [],\n });\n }\n }\n }\n\n return nodes;\n}\n\n/**\n * Verifies indexes match between contract and schema.\n * Returns verification nodes for the tree.\n */\nexport function verifyIndexes(\n contractIndexes: readonly Index[],\n schemaIndexes: readonly SqlIndexIR[],\n tableName: string,\n tablePath: string,\n issues: SchemaIssue[],\n strict: boolean,\n): SchemaVerificationNode[] {\n const nodes: SchemaVerificationNode[] = [];\n\n // Check each contract index exists in schema\n for (const contractIndex of contractIndexes) {\n const indexPath = `${tablePath}.indexes[${contractIndex.columns.join(',')}]`;\n const matchingIndex = schemaIndexes.find(\n (idx) => arraysEqual(idx.columns, contractIndex.columns) && idx.unique === false,\n );\n\n if (!matchingIndex) {\n issues.push({\n kind: 'index_mismatch',\n table: tableName,\n expected: contractIndex.columns.join(', '),\n message: `Table \"${tableName}\" is missing index: ${contractIndex.columns.join(', ')}`,\n });\n nodes.push({\n status: 'fail',\n kind: 'index',\n name: `index(${contractIndex.columns.join(', ')})`,\n contractPath: indexPath,\n code: 'index_mismatch',\n message: 'Index missing',\n expected: contractIndex,\n actual: undefined,\n children: [],\n });\n } else {\n // Compare name if both are modeled\n if (contractIndex.name && matchingIndex.name && contractIndex.name !== matchingIndex.name) {\n issues.push({\n kind: 'index_mismatch',\n table: tableName,\n indexOrConstraint: contractIndex.name,\n expected: contractIndex.name,\n actual: matchingIndex.name,\n message: `Table \"${tableName}\" has index name mismatch: expected \"${contractIndex.name}\", got \"${matchingIndex.name}\"`,\n });\n nodes.push({\n status: 'fail',\n kind: 'index',\n name: `index(${contractIndex.columns.join(', ')})`,\n contractPath: indexPath,\n code: 'index_mismatch',\n message: 'Index name mismatch',\n expected: contractIndex.name,\n actual: matchingIndex.name,\n children: [],\n });\n } else {\n nodes.push({\n status: 'pass',\n kind: 'index',\n name: `index(${contractIndex.columns.join(', ')})`,\n contractPath: indexPath,\n code: '',\n message: '',\n expected: undefined,\n actual: undefined,\n children: [],\n });\n }\n }\n }\n\n // Check for extra indexes in strict mode\n if (strict) {\n for (const schemaIndex of schemaIndexes) {\n // Skip unique indexes (they're handled as unique constraints)\n if (schemaIndex.unique) {\n continue;\n }\n\n const matchingIndex = contractIndexes.find((idx) =>\n arraysEqual(idx.columns, schemaIndex.columns),\n );\n\n if (!matchingIndex) {\n issues.push({\n kind: 'extra_index',\n table: tableName,\n message: `Extra index found in database (not in contract): ${schemaIndex.columns.join(', ')}`,\n });\n nodes.push({\n status: 'fail',\n kind: 'index',\n name: `index(${schemaIndex.columns.join(', ')})`,\n contractPath: `${tablePath}.indexes[${schemaIndex.columns.join(',')}]`,\n code: 'extra_index',\n message: 'Extra index found',\n expected: undefined,\n actual: schemaIndex,\n children: [],\n });\n }\n }\n }\n\n return nodes;\n}\n\n/**\n * Verifies database dependencies are installed using component-owned verification hooks.\n * Each dependency provides a pure verifyDatabaseDependencyInstalled function that checks\n * whether the dependency is satisfied based on the in-memory schema IR (no DB I/O).\n *\n * Returns verification nodes for the tree.\n */\nexport function verifyDatabaseDependencies(\n dependencies: ReadonlyArray<ComponentDatabaseDependency<unknown>>,\n schema: SqlSchemaIR,\n issues: SchemaIssue[],\n): SchemaVerificationNode[] {\n const nodes: SchemaVerificationNode[] = [];\n\n for (const dependency of dependencies) {\n const depIssues = dependency.verifyDatabaseDependencyInstalled(schema);\n const depPath = `dependencies.${dependency.id}`;\n\n if (depIssues.length > 0) {\n // Dependency is not satisfied\n issues.push(...depIssues);\n const issuesMessage = depIssues.map((i) => i.message).join('; ');\n const nodeMessage = issuesMessage ? `${dependency.id}: ${issuesMessage}` : dependency.id;\n nodes.push({\n status: 'fail',\n kind: 'databaseDependency',\n name: dependency.label,\n contractPath: depPath,\n code: 'dependency_missing',\n message: nodeMessage,\n expected: undefined,\n actual: undefined,\n children: [],\n });\n } else {\n // Dependency is satisfied\n nodes.push({\n status: 'pass',\n kind: 'databaseDependency',\n name: dependency.label,\n contractPath: depPath,\n code: '',\n message: '',\n expected: undefined,\n actual: undefined,\n children: [],\n });\n }\n }\n\n return nodes;\n}\n\n/**\n * Computes counts of pass/warn/fail nodes by traversing the tree.\n */\nexport function computeCounts(node: SchemaVerificationNode): {\n pass: number;\n warn: number;\n fail: number;\n totalNodes: number;\n} {\n let pass = 0;\n let warn = 0;\n let fail = 0;\n\n function traverse(n: SchemaVerificationNode): void {\n if (n.status === 'pass') {\n pass++;\n } else if (n.status === 'warn') {\n warn++;\n } else if (n.status === 'fail') {\n fail++;\n }\n\n if (n.children) {\n for (const child of n.children) {\n traverse(child);\n }\n }\n }\n\n traverse(node);\n\n return {\n pass,\n warn,\n fail,\n totalNodes: pass + warn + fail,\n };\n}\n","/**\n * Pure SQL schema verification function.\n *\n * This module provides a pure function that verifies a SqlSchemaIR against\n * a SqlContract without requiring a database connection. It can be reused\n * by migration planners and other tools that need to compare schema states.\n */\n\nimport type { TargetBoundComponentDescriptor } from '@prisma-next/contract/framework-components';\nimport type {\n OperationContext,\n SchemaIssue,\n SchemaVerificationNode,\n VerifyDatabaseSchemaResult,\n} from '@prisma-next/core-control-plane/types';\nimport type { SqlContract, SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport type { ComponentDatabaseDependency } from '../migrations/types';\nimport {\n computeCounts,\n verifyDatabaseDependencies,\n verifyForeignKeys,\n verifyIndexes,\n verifyPrimaryKey,\n verifyUniqueConstraints,\n} from './verify-helpers';\n\n/**\n * Options for the pure schema verification function.\n */\nexport interface VerifySqlSchemaOptions {\n /** The validated SQL contract to verify against */\n readonly contract: SqlContract<SqlStorage>;\n /** The schema IR from introspection (or another source) */\n readonly schema: SqlSchemaIR;\n /** Whether to run in strict mode (detects extra tables/columns) */\n readonly strict: boolean;\n /** Optional operation context for metadata */\n readonly context?: OperationContext;\n /** Type metadata registry for codec consistency warnings */\n readonly typeMetadataRegistry: ReadonlyMap<string, { nativeType?: string }>;\n /**\n * Active framework components participating in this composition.\n * All components must have matching familyId ('sql') and targetId.\n */\n readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;\n}\n\n/**\n * Verifies that a SqlSchemaIR matches a SqlContract.\n *\n * This is a pure function that does NOT perform any database I/O.\n * It takes an already-introspected schema IR and compares it against\n * the contract requirements.\n *\n * @param options - Verification options\n * @returns VerifyDatabaseSchemaResult with verification tree and issues\n */\nexport function verifySqlSchema(options: VerifySqlSchemaOptions): VerifyDatabaseSchemaResult {\n const { contract, schema, strict, context, typeMetadataRegistry } = options;\n const startTime = Date.now();\n\n // Extract contract hashes and target\n const contractCoreHash = contract.coreHash;\n const contractProfileHash =\n 'profileHash' in contract && typeof contract.profileHash === 'string'\n ? contract.profileHash\n : undefined;\n const contractTarget = contract.target;\n\n // Compare contract vs schema IR\n const issues: SchemaIssue[] = [];\n const rootChildren: SchemaVerificationNode[] = [];\n\n // Compare tables\n const contractTables = contract.storage.tables;\n const schemaTables = schema.tables;\n\n for (const [tableName, contractTable] of Object.entries(contractTables)) {\n const schemaTable = schemaTables[tableName];\n const tablePath = `storage.tables.${tableName}`;\n\n if (!schemaTable) {\n // Missing table\n issues.push({\n kind: 'missing_table',\n table: tableName,\n message: `Table \"${tableName}\" is missing from database`,\n });\n rootChildren.push({\n status: 'fail',\n kind: 'table',\n name: `table ${tableName}`,\n contractPath: tablePath,\n code: 'missing_table',\n message: `Table \"${tableName}\" is missing`,\n expected: undefined,\n actual: undefined,\n children: [],\n });\n continue;\n }\n\n // Table exists - compare columns, constraints, etc.\n const tableChildren: SchemaVerificationNode[] = [];\n const columnNodes: SchemaVerificationNode[] = [];\n\n // Compare columns\n for (const [columnName, contractColumn] of Object.entries(contractTable.columns)) {\n const schemaColumn = schemaTable.columns[columnName];\n const columnPath = `${tablePath}.columns.${columnName}`;\n\n if (!schemaColumn) {\n // Missing column\n issues.push({\n kind: 'missing_column',\n table: tableName,\n column: columnName,\n message: `Column \"${tableName}\".\"${columnName}\" is missing from database`,\n });\n columnNodes.push({\n status: 'fail',\n kind: 'column',\n name: `${columnName}: missing`,\n contractPath: columnPath,\n code: 'missing_column',\n message: `Column \"${columnName}\" is missing`,\n expected: undefined,\n actual: undefined,\n children: [],\n });\n continue;\n }\n\n // Column exists - compare type and nullability\n const columnChildren: SchemaVerificationNode[] = [];\n let columnStatus: 'pass' | 'warn' | 'fail' = 'pass';\n\n // Compare type using nativeType directly\n // Both contractColumn.nativeType and schemaColumn.nativeType are required by their types\n const contractNativeType = contractColumn.nativeType;\n const schemaNativeType = schemaColumn.nativeType;\n\n if (contractNativeType !== schemaNativeType) {\n // Compare native types directly\n issues.push({\n kind: 'type_mismatch',\n table: tableName,\n column: columnName,\n expected: contractNativeType,\n actual: schemaNativeType,\n message: `Column \"${tableName}\".\"${columnName}\" has type mismatch: expected \"${contractNativeType}\", got \"${schemaNativeType}\"`,\n });\n columnChildren.push({\n status: 'fail',\n kind: 'type',\n name: 'type',\n contractPath: `${columnPath}.nativeType`,\n code: 'type_mismatch',\n message: `Type mismatch: expected ${contractNativeType}, got ${schemaNativeType}`,\n expected: contractNativeType,\n actual: schemaNativeType,\n children: [],\n });\n columnStatus = 'fail';\n }\n\n // Optionally validate that codecId (if present) and nativeType agree with registry\n if (contractColumn.codecId) {\n const typeMetadata = typeMetadataRegistry.get(contractColumn.codecId);\n if (!typeMetadata) {\n // Warning: codecId not found in registry\n columnChildren.push({\n status: 'warn',\n kind: 'type',\n name: 'type_metadata_missing',\n contractPath: `${columnPath}.codecId`,\n code: 'type_metadata_missing',\n message: `codecId \"${contractColumn.codecId}\" not found in type metadata registry`,\n expected: contractColumn.codecId,\n actual: undefined,\n children: [],\n });\n } else if (typeMetadata.nativeType && typeMetadata.nativeType !== contractNativeType) {\n // Warning: codecId and nativeType don't agree with registry\n columnChildren.push({\n status: 'warn',\n kind: 'type',\n name: 'type_consistency',\n contractPath: `${columnPath}.codecId`,\n code: 'type_consistency_warning',\n message: `codecId \"${contractColumn.codecId}\" maps to nativeType \"${typeMetadata.nativeType}\" in registry, but contract has \"${contractNativeType}\"`,\n expected: typeMetadata.nativeType,\n actual: contractNativeType,\n children: [],\n });\n }\n }\n\n // Compare nullability\n if (contractColumn.nullable !== schemaColumn.nullable) {\n issues.push({\n kind: 'nullability_mismatch',\n table: tableName,\n column: columnName,\n expected: String(contractColumn.nullable),\n actual: String(schemaColumn.nullable),\n message: `Column \"${tableName}\".\"${columnName}\" has nullability mismatch: expected ${contractColumn.nullable ? 'nullable' : 'not null'}, got ${schemaColumn.nullable ? 'nullable' : 'not null'}`,\n });\n columnChildren.push({\n status: 'fail',\n kind: 'nullability',\n name: 'nullability',\n contractPath: `${columnPath}.nullable`,\n code: 'nullability_mismatch',\n message: `Nullability mismatch: expected ${contractColumn.nullable ? 'nullable' : 'not null'}, got ${schemaColumn.nullable ? 'nullable' : 'not null'}`,\n expected: contractColumn.nullable,\n actual: schemaColumn.nullable,\n children: [],\n });\n columnStatus = 'fail';\n }\n\n // Compute column status from children (fail > warn > pass)\n const computedColumnStatus = columnChildren.some((c) => c.status === 'fail')\n ? 'fail'\n : columnChildren.some((c) => c.status === 'warn')\n ? 'warn'\n : 'pass';\n // Use computed status if we have children, otherwise use the manually set status\n const finalColumnStatus = columnChildren.length > 0 ? computedColumnStatus : columnStatus;\n\n // Build column node\n const nullableText = contractColumn.nullable ? 'nullable' : 'not nullable';\n const columnTypeDisplay = contractColumn.codecId\n ? `${contractNativeType} (${contractColumn.codecId})`\n : contractNativeType;\n // Collect failure messages from children to create a summary message\n const failureMessages = columnChildren\n .filter((child) => child.status === 'fail' && child.message)\n .map((child) => child.message)\n .filter((msg): msg is string => typeof msg === 'string' && msg.length > 0);\n const columnMessage =\n finalColumnStatus === 'fail' && failureMessages.length > 0\n ? failureMessages.join('; ')\n : '';\n // Extract code from first child if status indicates an issue\n const columnCode =\n (finalColumnStatus === 'fail' || finalColumnStatus === 'warn') && columnChildren[0]\n ? columnChildren[0].code\n : '';\n columnNodes.push({\n status: finalColumnStatus,\n kind: 'column',\n name: `${columnName}: ${columnTypeDisplay} (${nullableText})`,\n contractPath: columnPath,\n code: columnCode,\n message: columnMessage,\n expected: undefined,\n actual: undefined,\n children: columnChildren,\n });\n }\n\n // Group columns under a \"columns\" header if we have any columns\n if (columnNodes.length > 0) {\n const columnsStatus = columnNodes.some((c) => c.status === 'fail')\n ? 'fail'\n : columnNodes.some((c) => c.status === 'warn')\n ? 'warn'\n : 'pass';\n tableChildren.push({\n status: columnsStatus,\n kind: 'columns',\n name: 'columns',\n contractPath: `${tablePath}.columns`,\n code: '',\n message: '',\n expected: undefined,\n actual: undefined,\n children: columnNodes,\n });\n }\n\n // Check for extra columns in strict mode\n if (strict) {\n for (const [columnName, { nativeType }] of Object.entries(schemaTable.columns)) {\n if (!contractTable.columns[columnName]) {\n issues.push({\n kind: 'extra_column',\n table: tableName,\n column: columnName,\n message: `Extra column \"${tableName}\".\"${columnName}\" found in database (not in contract)`,\n });\n columnNodes.push({\n status: 'fail',\n kind: 'column',\n name: `${columnName}: extra`,\n contractPath: `${tablePath}.columns.${columnName}`,\n code: 'extra_column',\n message: `Extra column \"${columnName}\" found`,\n expected: undefined,\n actual: nativeType,\n children: [],\n });\n }\n }\n }\n\n // Compare primary key\n if (contractTable.primaryKey) {\n const pkStatus = verifyPrimaryKey(\n contractTable.primaryKey,\n schemaTable.primaryKey,\n tableName,\n issues,\n );\n if (pkStatus === 'fail') {\n tableChildren.push({\n status: 'fail',\n kind: 'primaryKey',\n name: `primary key: ${contractTable.primaryKey.columns.join(', ')}`,\n contractPath: `${tablePath}.primaryKey`,\n code: 'primary_key_mismatch',\n message: 'Primary key mismatch',\n expected: contractTable.primaryKey,\n actual: schemaTable.primaryKey,\n children: [],\n });\n } else {\n tableChildren.push({\n status: 'pass',\n kind: 'primaryKey',\n name: `primary key: ${contractTable.primaryKey.columns.join(', ')}`,\n contractPath: `${tablePath}.primaryKey`,\n code: '',\n message: '',\n expected: undefined,\n actual: undefined,\n children: [],\n });\n }\n } else if (schemaTable.primaryKey && strict) {\n // Extra primary key in strict mode\n issues.push({\n kind: 'extra_primary_key',\n table: tableName,\n message: 'Extra primary key found in database (not in contract)',\n });\n tableChildren.push({\n status: 'fail',\n kind: 'primaryKey',\n name: `primary key: ${schemaTable.primaryKey.columns.join(', ')}`,\n contractPath: `${tablePath}.primaryKey`,\n code: 'extra_primary_key',\n message: 'Extra primary key found',\n expected: undefined,\n actual: schemaTable.primaryKey,\n children: [],\n });\n }\n\n // Compare foreign keys\n const fkStatuses = verifyForeignKeys(\n contractTable.foreignKeys,\n schemaTable.foreignKeys,\n tableName,\n tablePath,\n issues,\n strict,\n );\n tableChildren.push(...fkStatuses);\n\n // Compare unique constraints\n const uniqueStatuses = verifyUniqueConstraints(\n contractTable.uniques,\n schemaTable.uniques,\n tableName,\n tablePath,\n issues,\n strict,\n );\n tableChildren.push(...uniqueStatuses);\n\n // Compare indexes\n const indexStatuses = verifyIndexes(\n contractTable.indexes,\n schemaTable.indexes,\n tableName,\n tablePath,\n issues,\n strict,\n );\n tableChildren.push(...indexStatuses);\n\n // Build table node\n const tableStatus = tableChildren.some((c) => c.status === 'fail')\n ? 'fail'\n : tableChildren.some((c) => c.status === 'warn')\n ? 'warn'\n : 'pass';\n // Collect failure messages from children to create a summary message\n const tableFailureMessages = tableChildren\n .filter((child) => child.status === 'fail' && child.message)\n .map((child) => child.message)\n .filter((msg): msg is string => typeof msg === 'string' && msg.length > 0);\n const tableMessage =\n tableStatus === 'fail' && tableFailureMessages.length > 0\n ? `${tableFailureMessages.length} issue${tableFailureMessages.length === 1 ? '' : 's'}`\n : '';\n const tableCode =\n tableStatus === 'fail' && tableChildren.length > 0 && tableChildren[0]\n ? tableChildren[0].code\n : '';\n rootChildren.push({\n status: tableStatus,\n kind: 'table',\n name: `table ${tableName}`,\n contractPath: tablePath,\n code: tableCode,\n message: tableMessage,\n expected: undefined,\n actual: undefined,\n children: tableChildren,\n });\n }\n\n // Check for extra tables in strict mode\n if (strict) {\n for (const tableName of Object.keys(schemaTables)) {\n if (!contractTables[tableName]) {\n issues.push({\n kind: 'extra_table',\n table: tableName,\n message: `Extra table \"${tableName}\" found in database (not in contract)`,\n });\n rootChildren.push({\n status: 'fail',\n kind: 'table',\n name: `table ${tableName}`,\n contractPath: `storage.tables.${tableName}`,\n code: 'extra_table',\n message: `Extra table \"${tableName}\" found`,\n expected: undefined,\n actual: undefined,\n children: [],\n });\n }\n }\n }\n\n // Validate that all extension packs declared in the contract are present in frameworkComponents\n // This is a configuration integrity check - if the contract was emitted with an extension,\n // that extension must be provided in the current configuration.\n // Note: contract.extensionPacks includes adapter.id and target.id (from extractExtensionIds),\n // so we check for matches as extension, adapter, or target components.\n const contractExtensionPacks = contract.extensionPacks ?? {};\n for (const extensionNamespace of Object.keys(contractExtensionPacks)) {\n const hasComponent = options.frameworkComponents.some(\n (component) =>\n component.id === extensionNamespace &&\n (component.kind === 'extension' ||\n component.kind === 'adapter' ||\n component.kind === 'target'),\n );\n if (!hasComponent) {\n throw new Error(\n `Extension pack '${extensionNamespace}' is declared in the contract but not found in framework components. ` +\n 'This indicates a configuration mismatch - the contract was emitted with this extension pack, ' +\n 'but it is not provided in the current configuration.',\n );\n }\n }\n\n // Compare component-owned database dependencies (pure, deterministic)\n // Per ADR 154: We do NOT infer dependencies from contract extension packs.\n // Dependencies are only collected from frameworkComponents provided by the CLI.\n const databaseDependencies = collectDependenciesFromFrameworkComponents(\n options.frameworkComponents,\n );\n const dependencyStatuses = verifyDatabaseDependencies(databaseDependencies, schema, issues);\n rootChildren.push(...dependencyStatuses);\n\n // Build root node\n const rootStatus = rootChildren.some((c) => c.status === 'fail')\n ? 'fail'\n : rootChildren.some((c) => c.status === 'warn')\n ? 'warn'\n : 'pass';\n const root: SchemaVerificationNode = {\n status: rootStatus,\n kind: 'contract',\n name: 'contract',\n contractPath: '',\n code: '',\n message: '',\n expected: undefined,\n actual: undefined,\n children: rootChildren,\n };\n\n // Compute counts\n const counts = computeCounts(root);\n\n // Set ok flag\n const ok = counts.fail === 0;\n\n // Set code\n const code = ok ? undefined : 'PN-SCHEMA-0001';\n\n // Set summary\n const summary = ok\n ? 'Database schema satisfies contract'\n : `Database schema does not satisfy contract (${counts.fail} failure${counts.fail === 1 ? '' : 's'})`;\n\n const totalTime = Date.now() - startTime;\n\n return {\n ok,\n ...ifDefined('code', code),\n summary,\n contract: {\n coreHash: contractCoreHash,\n ...ifDefined('profileHash', contractProfileHash),\n },\n target: {\n expected: contractTarget,\n actual: contractTarget,\n },\n schema: {\n issues,\n root,\n counts,\n },\n meta: {\n strict,\n ...ifDefined('contractPath', context?.contractPath),\n ...ifDefined('configPath', context?.configPath),\n },\n timings: {\n total: totalTime,\n },\n };\n}\n\n/**\n * Type predicate to check if a component has database dependencies with an init array.\n * The familyId check is redundant since TargetBoundComponentDescriptor<'sql', T> already\n * guarantees familyId is 'sql' at the type level, so we don't need runtime checks for it.\n */\nfunction hasDatabaseDependenciesInit<T extends string>(\n component: TargetBoundComponentDescriptor<'sql', T>,\n): component is TargetBoundComponentDescriptor<'sql', T> & {\n readonly databaseDependencies: {\n readonly init: readonly ComponentDatabaseDependency<T>[];\n };\n} {\n if (!('databaseDependencies' in component)) {\n return false;\n }\n const dbDeps = (component as Record<string, unknown>)['databaseDependencies'];\n if (dbDeps === undefined || dbDeps === null || typeof dbDeps !== 'object') {\n return false;\n }\n const depsRecord = dbDeps as Record<string, unknown>;\n const init = depsRecord['init'];\n if (init === undefined || !Array.isArray(init)) {\n return false;\n }\n return true;\n}\n\nfunction collectDependenciesFromFrameworkComponents<T extends string>(\n components: ReadonlyArray<TargetBoundComponentDescriptor<'sql', T>>,\n): ReadonlyArray<ComponentDatabaseDependency<T>> {\n const dependencies: ComponentDatabaseDependency<T>[] = [];\n for (const component of components) {\n if (hasDatabaseDependenciesInit(component)) {\n dependencies.push(...component.databaseDependencies.init);\n }\n }\n return dependencies;\n}\n"],"mappings":";AAuBO,SAAS,YAAY,GAAsB,GAA+B;AAC/E,MAAI,EAAE,WAAW,EAAE,QAAQ;AACzB,WAAO;AAAA,EACT;AACA,WAAS,IAAI,GAAG,IAAI,EAAE,QAAQ,KAAK;AACjC,QAAI,EAAE,CAAC,MAAM,EAAE,CAAC,GAAG;AACjB,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAMO,SAAS,iBACd,YACA,UACA,WACA,QACiB;AACjB,MAAI,CAAC,UAAU;AACb,WAAO,KAAK;AAAA,MACV,MAAM;AAAA,MACN,OAAO;AAAA,MACP,UAAU,WAAW,QAAQ,KAAK,IAAI;AAAA,MACtC,SAAS,UAAU,SAAS;AAAA,IAC9B,CAAC;AACD,WAAO;AAAA,EACT;AAEA,MAAI,CAAC,YAAY,WAAW,SAAS,SAAS,OAAO,GAAG;AACtD,WAAO,KAAK;AAAA,MACV,MAAM;AAAA,MACN,OAAO;AAAA,MACP,UAAU,WAAW,QAAQ,KAAK,IAAI;AAAA,MACtC,QAAQ,SAAS,QAAQ,KAAK,IAAI;AAAA,MAClC,SAAS,UAAU,SAAS,iDAAiD,WAAW,QAAQ,KAAK,IAAI,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