symmetria-kit 2.2.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/query-inspect.js +1 -1
- package/dist/cli.js +4 -4
- package/dist/{ddl-Ct-1bZI1.js → ddl-D5b2NczN.js} +4 -2
- package/dist/ddl-D5b2NczN.js.map +1 -0
- package/dist/{diff-DXavyPT_.js → diff-CcYP6bTY.js} +30 -8
- package/dist/diff-CcYP6bTY.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -3
- package/dist/{query-inspector-ChvIIZep.js → query-inspector-B6UEqDzn.js} +2 -2
- package/dist/{query-inspector-ChvIIZep.js.map → query-inspector-B6UEqDzn.js.map} +1 -1
- package/dist/{src-t1x6buIR.js → src-CYyQ1VMI.js} +19 -4
- package/dist/src-CYyQ1VMI.js.map +1 -0
- package/dist/testing.js +1 -1
- package/package.json +2 -2
- package/dist/ddl-Ct-1bZI1.js.map +0 -1
- package/dist/diff-DXavyPT_.js.map +0 -1
- package/dist/src-t1x6buIR.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as migrationSnapshot, g as emptySnapshot, h as compareNames, m as checksum, p as canonicalJSON, v as objectName, x as snapshotHash, y as parseMigrationSnapshot } from "./ddl-
|
|
2
|
-
import { a as renamedDefinitions, c as readExpression, d as normalizeSqlType, f as undeclaredTables, i as diffSchemas, l as detectDrift, m as readCatalog, n as counterparts, o as conversionMessage, p as readPullCatalog, s as typeConversion, t as changedDefinition, u as formatDriftFindings } from "./diff-
|
|
1
|
+
import { _ as migrationSnapshot, g as emptySnapshot, h as compareNames, m as checksum, p as canonicalJSON, v as objectName, x as snapshotHash, y as parseMigrationSnapshot } from "./ddl-D5b2NczN.js";
|
|
2
|
+
import { a as renamedDefinitions, c as readExpression, d as normalizeSqlType, f as undeclaredTables, i as diffSchemas, l as detectDrift, m as readCatalog, n as counterparts, o as conversionMessage, p as readPullCatalog, s as typeConversion, t as changedDefinition, u as formatDriftFindings } from "./diff-CcYP6bTY.js";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
import { INDEX_METHODS, normalizeResult, quoteIdentifier } from "symmetria/internal";
|
|
5
5
|
import { access, mkdir, mkdtemp, open, readFile, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
@@ -169,6 +169,9 @@ const lintMigration = (plan, renames = {}) => {
|
|
|
169
169
|
const next = plan.after.enumerations.find((enumeration) => enumeration.name === to);
|
|
170
170
|
return previous !== void 0 && next !== void 0 && !plan.after.enumerations.some((enumeration) => enumeration.name === from) && !plan.before.enumerations.some((enumeration) => enumeration.name === to) && previous.values.join("\0") === next.values.join("\0");
|
|
171
171
|
};
|
|
172
|
+
const rewritten = (table, column) => {
|
|
173
|
+
if (column.generated !== void 0) report("caution", table, `Column "${column.name}" is computed and stored for every existing row; PostgreSQL rewrites the table while it holds a lock.`, "On a large table run the migration in a quiet hour.", column.name);
|
|
174
|
+
};
|
|
172
175
|
const compareColumns = (before, after) => {
|
|
173
176
|
const renamedColumns = renames.columns?.[after.name] ?? {};
|
|
174
177
|
const afterColumns = new Map(after.columns.map((column) => [column.name, column]));
|
|
@@ -176,10 +179,15 @@ const lintMigration = (plan, renames = {}) => {
|
|
|
176
179
|
for (const column of before.columns) {
|
|
177
180
|
const renamedTo = renamedColumns[column.name];
|
|
178
181
|
const next = afterColumns.get(renamedTo ?? column.name);
|
|
182
|
+
if (!next && column.generated !== void 0) continue;
|
|
179
183
|
if (!next) {
|
|
180
184
|
report("destructive", after.name, `Column "${column.name}" is dropped; its data is lost.`, "Stop reading and writing the column in a release first, then drop it in a later migration.", column.name);
|
|
181
185
|
continue;
|
|
182
186
|
}
|
|
187
|
+
if (column.generated !== void 0 || next.generated !== void 0) {
|
|
188
|
+
if (column.generated !== next.generated) rewritten(after.name, next);
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
183
191
|
compareColumn(after, column, next);
|
|
184
192
|
const target = column.references && {
|
|
185
193
|
table: renamedTables[column.references.table] ?? column.references.table,
|
|
@@ -205,6 +213,10 @@ const lintMigration = (plan, renames = {}) => {
|
|
|
205
213
|
for (const definition of after.checks ?? []) if (!keptChecks.has(definition.sqlName)) report("blocking", after.name, `CHECK constraint "${definition.sqlName}" is added; the statement fails when an existing row violates it.`, "Fix violating rows first, or generate with --online, which adds the check NOT VALID and validates it separately.");
|
|
206
214
|
for (const column of after.columns) {
|
|
207
215
|
if (beforeColumns.has(column.name) || Object.values(renamedColumns).includes(column.name)) continue;
|
|
216
|
+
if (column.generated !== void 0) {
|
|
217
|
+
rewritten(after.name, column);
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
208
220
|
if (column.notNull && column.default === void 0 && !column.identity) report("blocking", after.name, `Column "${column.name}" is added as NOT NULL without a default; the statement fails when the table has rows.`, "Add a default, or add the column as nullable, backfill it and set NOT NULL in a later migration.", column.name);
|
|
209
221
|
if (column.unique) report("caution", after.name, `Column "${column.name}" is added with a UNIQUE constraint.`, "Existing rows all receive the same default; make sure the default is unique or add the constraint after backfilling.", column.name);
|
|
210
222
|
}
|
|
@@ -236,7 +248,10 @@ const lintMigration = (plan, renames = {}) => {
|
|
|
236
248
|
if (!next) continue;
|
|
237
249
|
const removed = enumeration.values.filter((value) => !next.values.includes(value));
|
|
238
250
|
if (removed.length) report("destructive", enumeration.name, `Enum "${enumeration.name}" drops ${removed.map((value) => `'${value}'`).join(", ")}; rows using those labels make the rebuild fail.`, "Update or delete the rows that use the removed labels before migrating.");
|
|
239
|
-
else if (JSON.stringify(enumeration.values) !== JSON.stringify(next.values))
|
|
251
|
+
else if (JSON.stringify(enumeration.values) !== JSON.stringify(next.values)) {
|
|
252
|
+
const added = plan.up.some((statement) => statement.startsWith(`ALTER TYPE ${quoteIdentifier(enumeration.name)} ADD VALUE `));
|
|
253
|
+
report("caution", enumeration.name, added ? `Enum "${enumeration.name}" gains labels in place.` : `Enum "${enumeration.name}" is rebuilt to change its labels.`, added ? "A new label can be used only after the migration that adds it commits." : "Dependent columns are rewritten while the type is replaced; plan for the lock.");
|
|
254
|
+
}
|
|
240
255
|
}
|
|
241
256
|
return findings.sort((left, right) => levelOrder$1[left.level] - levelOrder$1[right.level] || left.table.localeCompare(right.table));
|
|
242
257
|
};
|
|
@@ -3520,4 +3535,4 @@ const renderMermaid = (graph, options = {}) => {
|
|
|
3520
3535
|
//#endregion
|
|
3521
3536
|
export { parseMigrationSQL as _, boundaryDifferences as a, MigrationExecutionError as c, loadMigrationState as d, loadMigrations as f, lintMigration as g, formatLintFindings as h, defineMigrationConfig as i, lintMigrationSQL as l, recoverMigrationFiles as m, schemaGraph as n, verifyMigrations as o, squashMigrations as p, pullSchema as r, migrator as s, renderMermaid as t, generateMigration as u };
|
|
3522
3537
|
|
|
3523
|
-
//# sourceMappingURL=src-
|
|
3538
|
+
//# sourceMappingURL=src-CYyQ1VMI.js.map
|