@contember/database-migrations 2.2.0-alpha.2 → 2.2.0-alpha.21
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/development/index.cjs +5 -1
- package/dist/development/index.cjs.map +1 -1
- package/dist/development/index.js +5 -1
- package/dist/development/index.js.map +1 -1
- package/dist/development/src/Migration.cjs.map +1 -1
- package/dist/development/src/Migration.js.map +1 -1
- package/dist/development/src/MigrationBuilder.cjs +299 -0
- package/dist/development/src/MigrationBuilder.cjs.map +1 -0
- package/dist/development/src/MigrationBuilder.js +299 -0
- package/dist/development/src/MigrationBuilder.js.map +1 -0
- package/dist/development/src/helpers.cjs +4 -16
- package/dist/development/src/helpers.cjs.map +1 -1
- package/dist/development/src/helpers.js +4 -15
- package/dist/development/src/helpers.js.map +1 -1
- package/dist/production/index.cjs +5 -1
- package/dist/production/index.cjs.map +1 -1
- package/dist/production/index.js +5 -1
- package/dist/production/index.js.map +1 -1
- package/dist/production/src/Migration.cjs.map +1 -1
- package/dist/production/src/Migration.js.map +1 -1
- package/dist/production/src/MigrationBuilder.cjs +299 -0
- package/dist/production/src/MigrationBuilder.cjs.map +1 -0
- package/dist/production/src/MigrationBuilder.js +299 -0
- package/dist/production/src/MigrationBuilder.js.map +1 -0
- package/dist/production/src/helpers.cjs +4 -16
- package/dist/production/src/helpers.cjs.map +1 -1
- package/dist/production/src/helpers.js +4 -15
- package/dist/production/src/helpers.js.map +1 -1
- package/dist/types/GroupMigrationsResolver.d.ts.map +1 -1
- package/dist/types/Migration.d.ts +1 -1
- package/dist/types/Migration.d.ts.map +1 -1
- package/dist/types/MigrationBuilder.d.ts +95 -0
- package/dist/types/MigrationBuilder.d.ts.map +1 -0
- package/dist/types/MigrationsRunner.d.ts.map +1 -1
- package/dist/types/SnapshotMigrationResolver.d.ts.map +1 -1
- package/dist/types/helpers.d.ts +3 -6
- package/dist/types/helpers.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/runner.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -3
- package/readme.md +1 -1
- package/src/Migration.ts +1 -1
- package/src/MigrationBuilder.ts +419 -0
- package/src/helpers.ts +4 -17
- package/src/index.ts +2 -1
- package/tests/cases/unit/migrationBuilder.test.ts +486 -0
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, key + "", value);
|
|
4
|
+
const quote = (identifier) => `"${identifier.replace(/"/g, '""')}"`;
|
|
5
|
+
const literal = (name) => typeof name === "object" ? (name.schema ? `${quote(name.schema)}.` : "") + quote(name.name) : quote(name);
|
|
6
|
+
const nextDollarTag = function* () {
|
|
7
|
+
const chars = "abcdefghijklmnopqrstuvwxyz";
|
|
8
|
+
const ids = [0];
|
|
9
|
+
while (true) {
|
|
10
|
+
yield `$pg${ids.map((id) => chars[id]).join("")}$`;
|
|
11
|
+
let i = ids.length - 1;
|
|
12
|
+
for (; i >= 0; i--) {
|
|
13
|
+
ids[i] += 1;
|
|
14
|
+
if (ids[i] < chars.length) {
|
|
15
|
+
break;
|
|
16
|
+
}
|
|
17
|
+
ids[i] = 0;
|
|
18
|
+
}
|
|
19
|
+
if (i < 0) {
|
|
20
|
+
ids.unshift(0);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const escapeArrayBody = (values) => `[${values.map((it) => Array.isArray(it) ? escapeArrayBody(it) : escapeValue(it)).join(",")}]`;
|
|
25
|
+
const isPgLiteral = (value) => typeof value === "object" && value !== null && "literal" in value && value.literal === true && "value" in value;
|
|
26
|
+
const describeUnescapable = (value) => {
|
|
27
|
+
if (typeof value === "number") {
|
|
28
|
+
return String(value);
|
|
29
|
+
}
|
|
30
|
+
if (typeof value === "object") {
|
|
31
|
+
return "an object";
|
|
32
|
+
}
|
|
33
|
+
return typeof value === "undefined" ? "undefined" : `a ${typeof value}`;
|
|
34
|
+
};
|
|
35
|
+
const escapeValue = (value) => {
|
|
36
|
+
if (value === null) {
|
|
37
|
+
return "NULL";
|
|
38
|
+
}
|
|
39
|
+
if (typeof value === "boolean") {
|
|
40
|
+
return value.toString();
|
|
41
|
+
}
|
|
42
|
+
if (typeof value === "string") {
|
|
43
|
+
for (const tag of nextDollarTag()) {
|
|
44
|
+
if (!`${value}$`.includes(tag)) {
|
|
45
|
+
return `${tag}${value}${tag}`;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
50
|
+
return value;
|
|
51
|
+
}
|
|
52
|
+
if (Array.isArray(value)) {
|
|
53
|
+
return `ARRAY${escapeArrayBody(value)}`;
|
|
54
|
+
}
|
|
55
|
+
if (isPgLiteral(value)) {
|
|
56
|
+
return typeof value.value === "number" ? value.value : `${value.value}`;
|
|
57
|
+
}
|
|
58
|
+
throw new Error(`Cannot escape ${describeUnescapable(value)} as an SQL value`);
|
|
59
|
+
};
|
|
60
|
+
const typeAdapters = {
|
|
61
|
+
int: "integer",
|
|
62
|
+
string: "text",
|
|
63
|
+
float: "real",
|
|
64
|
+
double: "double precision",
|
|
65
|
+
datetime: "timestamp",
|
|
66
|
+
bool: "boolean"
|
|
67
|
+
};
|
|
68
|
+
const adaptType = (type) => typeAdapters[type] ?? type;
|
|
69
|
+
const resolveType = (type) => type === "id" ? "serial" : adaptType(type);
|
|
70
|
+
const applyColumnShorthand = (column) => column.type === "id" ? { primaryKey: true, ...column, type: "serial" } : { ...column, type: adaptType(column.type) };
|
|
71
|
+
const formatLines = (lines, prefix = " ", separator = ",") => lines.map((line) => line.replace(/(?:\r\n|\r|\n)+/g, " ")).join(`${separator}
|
|
72
|
+
`).replace(/^/gm, prefix);
|
|
73
|
+
const SEQUENCE_PRECEDENCES = ["ALWAYS", "BY DEFAULT"];
|
|
74
|
+
const assertValidSequenceOptions = (sequence) => {
|
|
75
|
+
const { precedence, type, increment, minvalue, maxvalue, start, cache, owner } = sequence;
|
|
76
|
+
if (!SEQUENCE_PRECEDENCES.includes(precedence)) {
|
|
77
|
+
throw new Error(`Invalid sequence precedence ${JSON.stringify(precedence)}: expected ALWAYS or BY DEFAULT`);
|
|
78
|
+
}
|
|
79
|
+
for (const [name, value] of Object.entries({ increment, minvalue, maxvalue, start, cache })) {
|
|
80
|
+
if (value !== void 0 && value !== null && value !== false && !Number.isInteger(value)) {
|
|
81
|
+
throw new Error(`Invalid sequence option ${name} ${JSON.stringify(value)}: expected an integer`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (type !== void 0 && !/^[a-zA-Z_][a-zA-Z0-9_ ]*$/.test(type)) {
|
|
85
|
+
throw new Error(`Invalid sequence type ${JSON.stringify(type)}: expected a type name`);
|
|
86
|
+
}
|
|
87
|
+
if (owner && !/^[_a-zA-Z][_a-zA-Z0-9$]*(\.[_a-zA-Z][_a-zA-Z0-9$]*){1,2}$/.test(owner)) {
|
|
88
|
+
throw new Error(`Invalid sequence owner ${JSON.stringify(owner)}: expected table.column`);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
const sequenceClause = (sequence) => {
|
|
92
|
+
assertValidSequenceOptions(sequence);
|
|
93
|
+
const { type, increment, minvalue, maxvalue, start, cache, cycle, owner } = sequence;
|
|
94
|
+
const clauses = [];
|
|
95
|
+
if (type) {
|
|
96
|
+
clauses.push(`AS ${resolveType(type)}`);
|
|
97
|
+
}
|
|
98
|
+
if (increment) {
|
|
99
|
+
clauses.push(`INCREMENT BY ${increment}`);
|
|
100
|
+
}
|
|
101
|
+
if (minvalue) {
|
|
102
|
+
clauses.push(`MINVALUE ${minvalue}`);
|
|
103
|
+
} else if (minvalue === null || minvalue === false) {
|
|
104
|
+
clauses.push("NO MINVALUE");
|
|
105
|
+
}
|
|
106
|
+
if (maxvalue) {
|
|
107
|
+
clauses.push(`MAXVALUE ${maxvalue}`);
|
|
108
|
+
} else if (maxvalue === null || maxvalue === false) {
|
|
109
|
+
clauses.push("NO MAXVALUE");
|
|
110
|
+
}
|
|
111
|
+
if (start) {
|
|
112
|
+
clauses.push(`START WITH ${start}`);
|
|
113
|
+
}
|
|
114
|
+
if (cache) {
|
|
115
|
+
clauses.push(`CACHE ${cache}`);
|
|
116
|
+
}
|
|
117
|
+
if (cycle) {
|
|
118
|
+
clauses.push("CYCLE");
|
|
119
|
+
} else if (cycle === false) {
|
|
120
|
+
clauses.push("NO CYCLE");
|
|
121
|
+
}
|
|
122
|
+
if (owner) {
|
|
123
|
+
clauses.push(`OWNED BY ${owner}`);
|
|
124
|
+
} else if (owner === null || owner === false) {
|
|
125
|
+
clauses.push("OWNED BY NONE");
|
|
126
|
+
}
|
|
127
|
+
return `GENERATED ${sequence.precedence} AS IDENTITY${clauses.length ? ` (${clauses.join(" ")})` : ""}`;
|
|
128
|
+
};
|
|
129
|
+
const referencesClause = (column) => {
|
|
130
|
+
const { references, onDelete } = column;
|
|
131
|
+
const target = typeof references === "string" && (references.startsWith('"') || references.endsWith(")")) ? references : literal(references);
|
|
132
|
+
return `REFERENCES ${target}${onDelete ? ` ON DELETE ${onDelete}` : ""}`;
|
|
133
|
+
};
|
|
134
|
+
const columnLines = (columns) => {
|
|
135
|
+
const applied = Object.entries(columns).map(([name, column]) => [name, applyColumnShorthand(column)]);
|
|
136
|
+
const primaryKey = applied.filter(([, column]) => column.primaryKey).map(([name]) => name);
|
|
137
|
+
const lines = applied.map(([name, column]) => {
|
|
138
|
+
const constraints = [];
|
|
139
|
+
if (column.collation) {
|
|
140
|
+
constraints.push(`COLLATE ${column.collation}`);
|
|
141
|
+
}
|
|
142
|
+
if (column.default !== void 0) {
|
|
143
|
+
constraints.push(`DEFAULT ${escapeValue(column.default)}`);
|
|
144
|
+
}
|
|
145
|
+
if (column.unique) {
|
|
146
|
+
constraints.push("UNIQUE");
|
|
147
|
+
}
|
|
148
|
+
if (column.primaryKey && primaryKey.length === 1) {
|
|
149
|
+
constraints.push("PRIMARY KEY");
|
|
150
|
+
}
|
|
151
|
+
if (column.notNull) {
|
|
152
|
+
constraints.push("NOT NULL");
|
|
153
|
+
}
|
|
154
|
+
if (column.references) {
|
|
155
|
+
constraints.push(referencesClause({ ...column, references: column.references }));
|
|
156
|
+
}
|
|
157
|
+
if (column.sequenceGenerated) {
|
|
158
|
+
constraints.push(sequenceClause(column.sequenceGenerated));
|
|
159
|
+
}
|
|
160
|
+
return `${literal(name)} ${column.type}${constraints.length ? ` ${constraints.join(" ")}` : ""}`;
|
|
161
|
+
});
|
|
162
|
+
return { lines, primaryKey: primaryKey.length > 1 ? primaryKey : [] };
|
|
163
|
+
};
|
|
164
|
+
const tableNameOf = (table) => typeof table === "object" ? table.name : table;
|
|
165
|
+
class MigrationBuilder {
|
|
166
|
+
constructor() {
|
|
167
|
+
__publicField(this, "steps", []);
|
|
168
|
+
}
|
|
169
|
+
getSqlSteps() {
|
|
170
|
+
return [...this.steps];
|
|
171
|
+
}
|
|
172
|
+
getSql() {
|
|
173
|
+
return `${this.steps.join("\n")}
|
|
174
|
+
`;
|
|
175
|
+
}
|
|
176
|
+
sql(sql) {
|
|
177
|
+
this.steps.push(sql.lastIndexOf(";") !== sql.length - 1 ? `${sql};` : sql);
|
|
178
|
+
}
|
|
179
|
+
createTable(table, columns) {
|
|
180
|
+
const { lines, primaryKey } = columnLines(columns);
|
|
181
|
+
const definition = primaryKey.length > 0 ? [...lines, `CONSTRAINT ${literal(`${tableNameOf(table)}_pkey`)} PRIMARY KEY (${primaryKey.map((name) => literal(name)).join(", ")})`] : lines;
|
|
182
|
+
this.steps.push(`CREATE TABLE ${literal(table)} (
|
|
183
|
+
${formatLines(definition)}
|
|
184
|
+
);`);
|
|
185
|
+
}
|
|
186
|
+
dropTable(table) {
|
|
187
|
+
this.steps.push(`DROP TABLE ${literal(table)};`);
|
|
188
|
+
}
|
|
189
|
+
renameTable(table, newName) {
|
|
190
|
+
this.steps.push(`ALTER TABLE ${literal(table)} RENAME TO ${literal(newName)};`);
|
|
191
|
+
}
|
|
192
|
+
addColumn(table, columns) {
|
|
193
|
+
this.steps.push(`ALTER TABLE ${literal(table)}
|
|
194
|
+
${formatLines(columnLines(columns).lines, " ADD ")};`);
|
|
195
|
+
}
|
|
196
|
+
dropColumn(table, column) {
|
|
197
|
+
this.steps.push(`ALTER TABLE ${literal(table)}
|
|
198
|
+
${formatLines([literal(column)], " DROP ")};`);
|
|
199
|
+
}
|
|
200
|
+
renameColumn(table, column, newName) {
|
|
201
|
+
this.steps.push(`ALTER TABLE ${literal(table)} RENAME ${literal(column)} TO ${literal(newName)};`);
|
|
202
|
+
}
|
|
203
|
+
alterColumn(table, column, options) {
|
|
204
|
+
const actions = [];
|
|
205
|
+
if (options.type) {
|
|
206
|
+
const collation = options.collation ? ` COLLATE ${options.collation}` : "";
|
|
207
|
+
const using = options.using ? ` USING ${options.using}` : "";
|
|
208
|
+
actions.push(`SET DATA TYPE ${adaptType(options.type)}${collation}${using}`);
|
|
209
|
+
}
|
|
210
|
+
if (options.notNull) {
|
|
211
|
+
actions.push("SET NOT NULL");
|
|
212
|
+
} else if (options.notNull === false) {
|
|
213
|
+
actions.push("DROP NOT NULL");
|
|
214
|
+
}
|
|
215
|
+
if (options.sequenceGenerated !== void 0) {
|
|
216
|
+
actions.push(options.sequenceGenerated ? `ADD ${sequenceClause(options.sequenceGenerated)}` : "DROP IDENTITY");
|
|
217
|
+
}
|
|
218
|
+
if (actions.length > 0) {
|
|
219
|
+
this.steps.push(`ALTER TABLE ${literal(table)}
|
|
220
|
+
${formatLines(actions, ` ALTER ${literal(column)} `)};`);
|
|
221
|
+
} else {
|
|
222
|
+
this.steps.push("");
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
addConstraint(table, constraintName, options) {
|
|
226
|
+
const name = literal(constraintName || `${tableNameOf(table)}_pkey`);
|
|
227
|
+
const constraint = `CONSTRAINT ${name} PRIMARY KEY (${options.primaryKey.map((column) => literal(column)).join(", ")})`;
|
|
228
|
+
this.steps.push(`ALTER TABLE ${literal(table)}
|
|
229
|
+
${formatLines([constraint], " ADD ")};`);
|
|
230
|
+
}
|
|
231
|
+
dropConstraint(table, constraintName) {
|
|
232
|
+
this.steps.push(`ALTER TABLE ${literal(table)} DROP CONSTRAINT ${literal(constraintName)};`);
|
|
233
|
+
}
|
|
234
|
+
createIndex(table, columns, options) {
|
|
235
|
+
const columnsSql = columns.map((column) => /[. ()]/.test(column) ? column : literal(column)).join(", ");
|
|
236
|
+
const name = options.name || `${tableNameOf(table)}_${columns.join("_")}_index`;
|
|
237
|
+
this.steps.push(`CREATE INDEX ${literal(name)} ON ${literal(table)} (${columnsSql});`);
|
|
238
|
+
}
|
|
239
|
+
createDomain(domain, type, options) {
|
|
240
|
+
const constraintName = options.constraintName ? ` CONSTRAINT ${literal(options.constraintName)}` : "";
|
|
241
|
+
const check = options.check ? `${constraintName} CHECK (${options.check})` : "";
|
|
242
|
+
this.steps.push(`CREATE DOMAIN ${literal(domain)} AS ${resolveType(type)}${check};`);
|
|
243
|
+
}
|
|
244
|
+
renameDomain(domain, newName) {
|
|
245
|
+
this.steps.push(`ALTER DOMAIN ${literal(domain)} RENAME TO ${literal(newName)};`);
|
|
246
|
+
}
|
|
247
|
+
dropDomain(domain) {
|
|
248
|
+
this.steps.push(`DROP DOMAIN ${literal(domain)};`);
|
|
249
|
+
}
|
|
250
|
+
createView(view, options, definition) {
|
|
251
|
+
this.steps.push(`CREATE${options.replace ? " OR REPLACE" : ""} VIEW ${literal(view)} AS ${definition};`);
|
|
252
|
+
}
|
|
253
|
+
renameView(view, newName) {
|
|
254
|
+
this.steps.push(`ALTER VIEW ${literal(view)} RENAME TO ${literal(newName)};`);
|
|
255
|
+
}
|
|
256
|
+
dropView(view) {
|
|
257
|
+
this.steps.push(`DROP VIEW ${literal(view)};`);
|
|
258
|
+
}
|
|
259
|
+
createMaterializedView(view, options, definition) {
|
|
260
|
+
const data = options.data !== void 0 ? ` WITH${options.data ? "" : " NO"} DATA` : "";
|
|
261
|
+
this.steps.push(`CREATE MATERIALIZED VIEW ${literal(view)} AS ${definition}${data};`);
|
|
262
|
+
}
|
|
263
|
+
dropMaterializedView(view) {
|
|
264
|
+
this.steps.push(`DROP MATERIALIZED VIEW ${literal(view)};`);
|
|
265
|
+
}
|
|
266
|
+
createTrigger(table, trigger, options) {
|
|
267
|
+
const { constraint, deferrable, deferred, functionParams = [], level = "STATEMENT" } = options;
|
|
268
|
+
const when = constraint ? "AFTER" : options.when;
|
|
269
|
+
const operations = typeof options.operation === "string" ? options.operation : options.operation.join(" OR ");
|
|
270
|
+
if (!options.function) {
|
|
271
|
+
throw new Error("Can't determine function name");
|
|
272
|
+
}
|
|
273
|
+
if (!operations) {
|
|
274
|
+
throw new Error('"operation" (INSERT/UPDATE[ OF ...]/DELETE/TRUNCATE) have to be specified');
|
|
275
|
+
}
|
|
276
|
+
const defer = constraint ? `${deferrable ? `DEFERRABLE INITIALLY ${deferred ? "DEFERRED" : "IMMEDIATE"}` : "NOT DEFERRABLE"}
|
|
277
|
+
` : "";
|
|
278
|
+
this.steps.push(
|
|
279
|
+
`CREATE${constraint ? " CONSTRAINT" : ""} TRIGGER ${literal(trigger)}
|
|
280
|
+
${when} ${operations} ON ${literal(table)}
|
|
281
|
+
${defer}FOR EACH ${level}
|
|
282
|
+
EXECUTE PROCEDURE ${literal(options.function)}(${functionParams.map(escapeValue).join(", ")});`
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
dropTrigger(table, trigger, options = {}) {
|
|
286
|
+
this.steps.push(`DROP TRIGGER${options.ifExists ? " IF EXISTS" : ""} ${literal(trigger)} ON ${literal(table)};`);
|
|
287
|
+
}
|
|
288
|
+
dropFunction(fn, params) {
|
|
289
|
+
const paramsSql = params.map((param) => [param.name ? literal(param.name) : "", param.type ? resolveType(param.type) : ""].filter(Boolean).join(" ")).join(", ");
|
|
290
|
+
this.steps.push(`DROP FUNCTION ${literal(fn)}(${paramsSql});`);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
export {
|
|
294
|
+
MigrationBuilder,
|
|
295
|
+
assertValidSequenceOptions,
|
|
296
|
+
escapeValue,
|
|
297
|
+
isPgLiteral
|
|
298
|
+
};
|
|
299
|
+
//# sourceMappingURL=MigrationBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MigrationBuilder.js","sources":["../../../../packages/database-migrations/src/MigrationBuilder.ts"],"sourcesContent":["/*\nThe SQL generation in this file is ported from the migration builder of node-pg-migrate. (https://github.com/salsita/node-pg-migrate)\n\nThe MIT License (MIT)\n\nCopyright (c) 2016-2020 Salsita Software <jando@salsitasoft.com>\n\nCopyright (c) 2014-2016 Theo Ephraim\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n */\n\n// Collects the SQL of engine and content migrations. The output reproduces node-pg-migrate 5 byte for byte for the\n// operations and options below, because not-yet-run migrations on existing databases must execute the same SQL. It differs\n// only for a name containing `\"`, which node-pg-migrate did not escape.\n\nexport type Name = string | { schema?: string; name: string }\n\nexport type Value = null | boolean | string | number | readonly Value[]\n\nexport interface SequenceOptions {\n\tprecedence: 'ALWAYS' | 'BY DEFAULT'\n\ttype?: string\n\tincrement?: number\n\tminvalue?: number | null | false\n\tmaxvalue?: number | null | false\n\tstart?: number\n\tcache?: number\n\tcycle?: boolean\n\towner?: string | null | false\n}\n\nexport interface ColumnDefinition {\n\ttype: string\n\tcollation?: string\n\tdefault?: Value\n\tunique?: boolean\n\tprimaryKey?: boolean\n\tnotNull?: boolean\n\treferences?: Name\n\tonDelete?: string\n\tsequenceGenerated?: SequenceOptions\n}\n\nexport interface AlterColumnOptions {\n\ttype?: string\n\tcollation?: string\n\tusing?: string\n\tnotNull?: boolean\n\tsequenceGenerated?: SequenceOptions | false\n}\n\nexport interface TriggerOptions {\n\twhen: 'BEFORE' | 'AFTER'\n\toperation: string | readonly string[]\n\tlevel?: 'ROW' | 'STATEMENT'\n\tfunction: Name\n\tfunctionParams?: readonly Value[]\n\tconstraint?: boolean\n\tdeferrable?: boolean\n\tdeferred?: boolean\n}\n\nexport interface FunctionParam {\n\tname: string\n\ttype: string\n}\n\nconst quote = (identifier: string): string => `\"${identifier.replace(/\"/g, '\"\"')}\"`\n\nconst literal = (name: Name): string => typeof name === 'object' ? (name.schema ? `${quote(name.schema)}.` : '') + quote(name.name) : quote(name)\n\nconst nextDollarTag = function*(): Generator<string> {\n\tconst chars = 'abcdefghijklmnopqrstuvwxyz'\n\tconst ids = [0]\n\twhile (true) {\n\t\tyield `$pg${ids.map(id => chars[id]).join('')}$`\n\t\tlet i = ids.length - 1\n\t\tfor (; i >= 0; i--) {\n\t\t\tids[i] += 1\n\t\t\tif (ids[i] < chars.length) {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tids[i] = 0\n\t\t}\n\t\tif (i < 0) {\n\t\t\tids.unshift(0)\n\t\t}\n\t}\n}\n\n// Inner arrays stay bare `[..]` (valid inside ARRAY[..]) so the emitted SQL matches what earlier versions generated.\nconst escapeArrayBody = (values: unknown[]): string => `[${values.map(it => Array.isArray(it) ? escapeArrayBody(it) : escapeValue(it)).join(',')}]`\n\n// node-pg-migrate's PgLiteral shape; migration JSON (e.g. a fill value or column default) can carry it.\nexport const isPgLiteral = (value: unknown): value is { literal: true; value: unknown } =>\n\ttypeof value === 'object' && value !== null && 'literal' in value && value.literal === true && 'value' in value\n\nconst describeUnescapable = (value: unknown): string => {\n\tif (typeof value === 'number') {\n\t\treturn String(value)\n\t}\n\tif (typeof value === 'object') {\n\t\treturn 'an object'\n\t}\n\treturn typeof value === 'undefined' ? 'undefined' : `a ${typeof value}`\n}\n\nexport const escapeValue = (value: unknown): string | number => {\n\tif (value === null) {\n\t\treturn 'NULL'\n\t}\n\tif (typeof value === 'boolean') {\n\t\treturn value.toString()\n\t}\n\tif (typeof value === 'string') {\n\t\t// The closing tag follows the value, so a value ending in `$pga` would form `$pga$` with it.\n\t\tfor (const tag of nextDollarTag()) {\n\t\t\tif (!`${value}$`.includes(tag)) {\n\t\t\t\treturn `${tag}${value}${tag}`\n\t\t\t}\n\t\t}\n\t}\n\tif (typeof value === 'number' && Number.isFinite(value)) {\n\t\treturn value\n\t}\n\tif (Array.isArray(value)) {\n\t\treturn `ARRAY${escapeArrayBody(value)}`\n\t}\n\tif (isPgLiteral(value)) {\n\t\treturn typeof value.value === 'number' ? value.value : `${value.value}`\n\t}\n\tthrow new Error(`Cannot escape ${describeUnescapable(value)} as an SQL value`)\n}\n\nconst typeAdapters: Record<string, string> = {\n\tint: 'integer',\n\tstring: 'text',\n\tfloat: 'real',\n\tdouble: 'double precision',\n\tdatetime: 'timestamp',\n\tbool: 'boolean',\n}\n\nconst adaptType = (type: string): string => typeAdapters[type] ?? type\n\n// `id` is node-pg-migrate's only default type shorthand; on columns it also implies a primary key.\nconst resolveType = (type: string): string => type === 'id' ? 'serial' : adaptType(type)\n\nconst applyColumnShorthand = (column: ColumnDefinition): ColumnDefinition =>\n\tcolumn.type === 'id' ? { primaryKey: true, ...column, type: 'serial' } : { ...column, type: adaptType(column.type) }\n\nconst formatLines = (lines: readonly string[], prefix = ' ', separator = ','): string =>\n\tlines\n\t\t.map(line => line.replace(/(?:\\r\\n|\\r|\\n)+/g, ' '))\n\t\t.join(`${separator}\\n`)\n\t\t.replace(/^/gm, prefix)\n\nconst SEQUENCE_PRECEDENCES: readonly string[] = ['ALWAYS', 'BY DEFAULT']\n\n// Sequence options arrive unparsed from migration JSON and go into the SQL as is, so each one must have its declared shape.\nexport const assertValidSequenceOptions = (sequence: SequenceOptions): void => {\n\tconst { precedence, type, increment, minvalue, maxvalue, start, cache, owner } = sequence\n\tif (!SEQUENCE_PRECEDENCES.includes(precedence)) {\n\t\tthrow new Error(`Invalid sequence precedence ${JSON.stringify(precedence)}: expected ALWAYS or BY DEFAULT`)\n\t}\n\tfor (const [name, value] of Object.entries({ increment, minvalue, maxvalue, start, cache })) {\n\t\tif (value !== undefined && value !== null && value !== false && !Number.isInteger(value)) {\n\t\t\tthrow new Error(`Invalid sequence option ${name} ${JSON.stringify(value)}: expected an integer`)\n\t\t}\n\t}\n\tif (type !== undefined && !/^[a-zA-Z_][a-zA-Z0-9_ ]*$/.test(type)) {\n\t\tthrow new Error(`Invalid sequence type ${JSON.stringify(type)}: expected a type name`)\n\t}\n\tif (owner && !/^[_a-zA-Z][_a-zA-Z0-9$]*(\\.[_a-zA-Z][_a-zA-Z0-9$]*){1,2}$/.test(owner)) {\n\t\tthrow new Error(`Invalid sequence owner ${JSON.stringify(owner)}: expected table.column`)\n\t}\n}\n\n// Every option node-pg-migrate rendered is kept.\nconst sequenceClause = (sequence: SequenceOptions): string => {\n\tassertValidSequenceOptions(sequence)\n\tconst { type, increment, minvalue, maxvalue, start, cache, cycle, owner } = sequence\n\tconst clauses: string[] = []\n\tif (type) {\n\t\tclauses.push(`AS ${resolveType(type)}`)\n\t}\n\tif (increment) {\n\t\tclauses.push(`INCREMENT BY ${increment}`)\n\t}\n\tif (minvalue) {\n\t\tclauses.push(`MINVALUE ${minvalue}`)\n\t} else if (minvalue === null || minvalue === false) {\n\t\tclauses.push('NO MINVALUE')\n\t}\n\tif (maxvalue) {\n\t\tclauses.push(`MAXVALUE ${maxvalue}`)\n\t} else if (maxvalue === null || maxvalue === false) {\n\t\tclauses.push('NO MAXVALUE')\n\t}\n\tif (start) {\n\t\tclauses.push(`START WITH ${start}`)\n\t}\n\tif (cache) {\n\t\tclauses.push(`CACHE ${cache}`)\n\t}\n\tif (cycle) {\n\t\tclauses.push('CYCLE')\n\t} else if (cycle === false) {\n\t\tclauses.push('NO CYCLE')\n\t}\n\tif (owner) {\n\t\tclauses.push(`OWNED BY ${owner}`)\n\t} else if (owner === null || owner === false) {\n\t\tclauses.push('OWNED BY NONE')\n\t}\n\treturn `GENERATED ${sequence.precedence} AS IDENTITY${clauses.length ? ` (${clauses.join(' ')})` : ''}`\n}\n\nconst referencesClause = (column: ColumnDefinition & { references: Name }): string => {\n\tconst { references, onDelete } = column\n\tconst target = typeof references === 'string' && (references.startsWith('\"') || references.endsWith(')')) ? references : literal(references)\n\treturn `REFERENCES ${target}${onDelete ? ` ON DELETE ${onDelete}` : ''}`\n}\n\nconst columnLines = (columns: Record<string, ColumnDefinition>): { lines: string[]; primaryKey: string[] } => {\n\tconst applied = Object.entries(columns).map(([name, column]) => [name, applyColumnShorthand(column)] as const)\n\tconst primaryKey = applied.filter(([, column]) => column.primaryKey).map(([name]) => name)\n\tconst lines = applied.map(([name, column]) => {\n\t\tconst constraints: string[] = []\n\t\tif (column.collation) {\n\t\t\tconstraints.push(`COLLATE ${column.collation}`)\n\t\t}\n\t\tif (column.default !== undefined) {\n\t\t\tconstraints.push(`DEFAULT ${escapeValue(column.default)}`)\n\t\t}\n\t\tif (column.unique) {\n\t\t\tconstraints.push('UNIQUE')\n\t\t}\n\t\tif (column.primaryKey && primaryKey.length === 1) {\n\t\t\tconstraints.push('PRIMARY KEY')\n\t\t}\n\t\tif (column.notNull) {\n\t\t\tconstraints.push('NOT NULL')\n\t\t}\n\t\tif (column.references) {\n\t\t\tconstraints.push(referencesClause({ ...column, references: column.references }))\n\t\t}\n\t\tif (column.sequenceGenerated) {\n\t\t\tconstraints.push(sequenceClause(column.sequenceGenerated))\n\t\t}\n\t\treturn `${literal(name)} ${column.type}${constraints.length ? ` ${constraints.join(' ')}` : ''}`\n\t})\n\treturn { lines, primaryKey: primaryKey.length > 1 ? primaryKey : [] }\n}\n\nconst tableNameOf = (table: Name): string => typeof table === 'object' ? table.name : table\n\nexport class MigrationBuilder {\n\tprivate readonly steps: string[] = []\n\n\tgetSqlSteps(): string[] {\n\t\treturn [...this.steps]\n\t}\n\n\tgetSql(): string {\n\t\treturn `${this.steps.join('\\n')}\\n`\n\t}\n\n\tsql(sql: string): void {\n\t\tthis.steps.push(sql.lastIndexOf(';') !== sql.length - 1 ? `${sql};` : sql)\n\t}\n\n\tcreateTable(table: Name, columns: Record<string, ColumnDefinition>): void {\n\t\tconst { lines, primaryKey } = columnLines(columns)\n\t\tconst definition = primaryKey.length > 0\n\t\t\t? [...lines, `CONSTRAINT ${literal(`${tableNameOf(table)}_pkey`)} PRIMARY KEY (${primaryKey.map(name => literal(name)).join(', ')})`]\n\t\t\t: lines\n\t\tthis.steps.push(`CREATE TABLE ${literal(table)} (\\n${formatLines(definition)}\\n);`)\n\t}\n\n\tdropTable(table: Name): void {\n\t\tthis.steps.push(`DROP TABLE ${literal(table)};`)\n\t}\n\n\trenameTable(table: Name, newName: Name): void {\n\t\tthis.steps.push(`ALTER TABLE ${literal(table)} RENAME TO ${literal(newName)};`)\n\t}\n\n\taddColumn(table: Name, columns: Record<string, ColumnDefinition>): void {\n\t\tthis.steps.push(`ALTER TABLE ${literal(table)}\\n${formatLines(columnLines(columns).lines, ' ADD ')};`)\n\t}\n\n\tdropColumn(table: Name, column: string): void {\n\t\tthis.steps.push(`ALTER TABLE ${literal(table)}\\n${formatLines([literal(column)], ' DROP ')};`)\n\t}\n\n\trenameColumn(table: Name, column: string, newName: string): void {\n\t\tthis.steps.push(`ALTER TABLE ${literal(table)} RENAME ${literal(column)} TO ${literal(newName)};`)\n\t}\n\n\talterColumn(table: Name, column: string, options: AlterColumnOptions): void {\n\t\tconst actions: string[] = []\n\t\tif (options.type) {\n\t\t\tconst collation = options.collation ? ` COLLATE ${options.collation}` : ''\n\t\t\tconst using = options.using ? ` USING ${options.using}` : ''\n\t\t\tactions.push(`SET DATA TYPE ${adaptType(options.type)}${collation}${using}`)\n\t\t}\n\t\tif (options.notNull) {\n\t\t\tactions.push('SET NOT NULL')\n\t\t} else if (options.notNull === false) {\n\t\t\tactions.push('DROP NOT NULL')\n\t\t}\n\t\tif (options.sequenceGenerated !== undefined) {\n\t\t\tactions.push(options.sequenceGenerated ? `ADD ${sequenceClause(options.sequenceGenerated)}` : 'DROP IDENTITY')\n\t\t}\n\t\tif (actions.length > 0) {\n\t\t\tthis.steps.push(`ALTER TABLE ${literal(table)}\\n${formatLines(actions, ` ALTER ${literal(column)} `)};`)\n\t\t} else {\n\t\t\tthis.steps.push('')\n\t\t}\n\t}\n\n\taddConstraint(table: Name, constraintName: string | null, options: { primaryKey: readonly string[] }): void {\n\t\tconst name = literal(constraintName || `${tableNameOf(table)}_pkey`)\n\t\tconst constraint = `CONSTRAINT ${name} PRIMARY KEY (${options.primaryKey.map(column => literal(column)).join(', ')})`\n\t\tthis.steps.push(`ALTER TABLE ${literal(table)}\\n${formatLines([constraint], ' ADD ')};`)\n\t}\n\n\tdropConstraint(table: Name, constraintName: string): void {\n\t\tthis.steps.push(`ALTER TABLE ${literal(table)} DROP CONSTRAINT ${literal(constraintName)};`)\n\t}\n\n\tcreateIndex(table: Name, columns: readonly string[], options: { name: string }): void {\n\t\tconst columnsSql = columns.map(column => /[. ()]/.test(column) ? column : literal(column)).join(', ')\n\t\tconst name = options.name || `${tableNameOf(table)}_${columns.join('_')}_index`\n\t\tthis.steps.push(`CREATE INDEX ${literal(name)} ON ${literal(table)} (${columnsSql});`)\n\t}\n\n\tcreateDomain(domain: Name, type: string, options: { check: string; constraintName?: string }): void {\n\t\tconst constraintName = options.constraintName ? ` CONSTRAINT ${literal(options.constraintName)}` : ''\n\t\tconst check = options.check ? `${constraintName} CHECK (${options.check})` : ''\n\t\tthis.steps.push(`CREATE DOMAIN ${literal(domain)} AS ${resolveType(type)}${check};`)\n\t}\n\n\trenameDomain(domain: Name, newName: Name): void {\n\t\tthis.steps.push(`ALTER DOMAIN ${literal(domain)} RENAME TO ${literal(newName)};`)\n\t}\n\n\tdropDomain(domain: Name): void {\n\t\tthis.steps.push(`DROP DOMAIN ${literal(domain)};`)\n\t}\n\n\tcreateView(view: Name, options: { replace?: boolean }, definition: string): void {\n\t\tthis.steps.push(`CREATE${options.replace ? ' OR REPLACE' : ''} VIEW ${literal(view)} AS ${definition};`)\n\t}\n\n\trenameView(view: Name, newName: Name): void {\n\t\tthis.steps.push(`ALTER VIEW ${literal(view)} RENAME TO ${literal(newName)};`)\n\t}\n\n\tdropView(view: Name): void {\n\t\tthis.steps.push(`DROP VIEW ${literal(view)};`)\n\t}\n\n\tcreateMaterializedView(view: Name, options: { data?: boolean }, definition: string): void {\n\t\tconst data = options.data !== undefined ? ` WITH${options.data ? '' : ' NO'} DATA` : ''\n\t\tthis.steps.push(`CREATE MATERIALIZED VIEW ${literal(view)} AS ${definition}${data};`)\n\t}\n\n\tdropMaterializedView(view: Name): void {\n\t\tthis.steps.push(`DROP MATERIALIZED VIEW ${literal(view)};`)\n\t}\n\n\tcreateTrigger(table: Name, trigger: string, options: TriggerOptions): void {\n\t\tconst { constraint, deferrable, deferred, functionParams = [], level = 'STATEMENT' } = options\n\t\tconst when = constraint ? 'AFTER' : options.when\n\t\tconst operations = typeof options.operation === 'string' ? options.operation : options.operation.join(' OR ')\n\t\tif (!options.function) {\n\t\t\tthrow new Error(\"Can't determine function name\")\n\t\t}\n\t\tif (!operations) {\n\t\t\tthrow new Error('\"operation\" (INSERT/UPDATE[ OF ...]/DELETE/TRUNCATE) have to be specified')\n\t\t}\n\t\tconst defer = constraint ? `${deferrable ? `DEFERRABLE INITIALLY ${deferred ? 'DEFERRED' : 'IMMEDIATE'}` : 'NOT DEFERRABLE'}\\n ` : ''\n\t\tthis.steps.push(\n\t\t\t`CREATE${constraint ? ' CONSTRAINT' : ''} TRIGGER ${literal(trigger)}\\n`\n\t\t\t\t+ ` ${when} ${operations} ON ${literal(table)}\\n`\n\t\t\t\t+ ` ${defer}FOR EACH ${level}\\n`\n\t\t\t\t+ ` EXECUTE PROCEDURE ${literal(options.function)}(${functionParams.map(escapeValue).join(', ')});`,\n\t\t)\n\t}\n\n\tdropTrigger(table: Name, trigger: string, options: { ifExists?: boolean } = {}): void {\n\t\tthis.steps.push(`DROP TRIGGER${options.ifExists ? ' IF EXISTS' : ''} ${literal(trigger)} ON ${literal(table)};`)\n\t}\n\n\tdropFunction(fn: Name, params: readonly FunctionParam[]): void {\n\t\tconst paramsSql = params.map(param => [param.name ? literal(param.name) : '', param.type ? resolveType(param.type) : ''].filter(Boolean).join(' '))\n\t\t\t.join(', ')\n\t\tthis.steps.push(`DROP FUNCTION ${literal(fn)}(${paramsSql});`)\n\t}\n}\n"],"names":[],"mappings":";;;AAoFA,MAAM,QAAQ,CAAC,eAA+B,IAAI,WAAW,QAAQ,MAAM,IAAI,CAAC;AAEhF,MAAM,UAAU,CAAC,SAAuB,OAAO,SAAS,YAAY,KAAK,SAAS,GAAG,MAAM,KAAK,MAAM,CAAC,MAAM,MAAM,MAAM,KAAK,IAAI,IAAI,MAAM,IAAI;AAEhJ,MAAM,gBAAgB,aAA+B;AACpD,QAAM,QAAQ;AACd,QAAM,MAAM,CAAC,CAAC;AACd,SAAO,MAAM;AACZ,UAAM,MAAM,IAAI,IAAI,CAAA,OAAM,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC;AAC7C,QAAI,IAAI,IAAI,SA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wBAAwB,WAAW,aAAa,WAAW,KAAK,gBAAgB;AAAA,MAAS;AACpI,SAAK,MAAM;AAAA,MACV,SAAS,aAAa,gBAAgB,EAAE,YAAY,QAAQ,OAAO,CAAC;AAAA,IAC5D,IAAI,IAAI,UAAU,OAAO,QAAQ,KAAK,CAAC;AAAA,IACvC,KAAK,YAAY,KAAK;AAAA,sBACJ,QAAQ,QAAQ,QAAQ,CAAC,IAAI,eAAe,IAAI,WAAW,EAAE,KAAK,IAAI,CAAC;AAAA,IAAA;AAAA,EAEnG;AAAA,EAEA,YAAY,OAAa,SAAiB,UAAkC,CAAA,GAAU;AACrF,SAAK,MAAM,KAAK,eAAe,QAAQ,WAAW,eAAe,EAAE,IAAI,QAAQ,OAAO,CAAC,OAAO,QAAQ,KAAK,CAAC,GAAG;AAAA,EAChH;AAAA,EAEA,aAAa,IAAU,QAAwC;AAC9D,UAAM,YAAY,OAAO,IAAI,CAAA,UAAS,CAAC,MAAM,OAAO,QAAQ,MAAM,IAAI,IAAI,IAAI,MAAM,OAAO,YAAY,MAAM,IAAI,IAAI,EAAE,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG,CAAC,EAChJ,KAAK,IAAI;AACX,SAAK,MAAM,KAAK,iBAAiB,QAAQ,EAAE,CAAC,IAAI,SAAS,IAAI;AAAA,EAC9D;AACD;"}
|
|
@@ -1,21 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
4
|
-
const utils_js = require("node-pg-migrate/dist/utils.js");
|
|
3
|
+
const MigrationBuilder = require("./MigrationBuilder.cjs");
|
|
5
4
|
function createMigrationBuilder() {
|
|
6
|
-
|
|
7
|
-
return new impl(
|
|
8
|
-
{
|
|
9
|
-
query: null,
|
|
10
|
-
select: null
|
|
11
|
-
},
|
|
12
|
-
{},
|
|
13
|
-
false,
|
|
14
|
-
{}
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
function escapeValue(value) {
|
|
18
|
-
return utils_js.escapeValue(value);
|
|
5
|
+
return new MigrationBuilder.MigrationBuilder();
|
|
19
6
|
}
|
|
20
7
|
const timePrefixLength = "YYYY-MM-DD-XXXXXX".length;
|
|
21
8
|
const checkOrder = (runMigrations, migrations) => {
|
|
@@ -31,8 +18,9 @@ const checkOrder = (runMigrations, migrations) => {
|
|
|
31
18
|
}
|
|
32
19
|
}
|
|
33
20
|
};
|
|
21
|
+
exports.escapeValue = MigrationBuilder.escapeValue;
|
|
22
|
+
exports.isPgLiteral = MigrationBuilder.isPgLiteral;
|
|
34
23
|
exports.checkOrder = checkOrder;
|
|
35
24
|
exports.createMigrationBuilder = createMigrationBuilder;
|
|
36
|
-
exports.escapeValue = escapeValue;
|
|
37
25
|
exports.timePrefixLength = timePrefixLength;
|
|
38
26
|
//# sourceMappingURL=helpers.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.cjs","sources":["../../../../packages/database-migrations/src/helpers.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"helpers.cjs","sources":["../../../../packages/database-migrations/src/helpers.ts"],"sourcesContent":["import { Migration, RunMigration } from './Migration.js'\nimport { MigrationBuilder } from './MigrationBuilder.js'\n\nexport { escapeValue, isPgLiteral } from './MigrationBuilder.js'\n\nexport function createMigrationBuilder(): MigrationBuilder {\n\treturn new MigrationBuilder()\n}\n\nexport const timePrefixLength = 'YYYY-MM-DD-XXXXXX'.length\n\nexport const checkOrder = (runMigrations: RunMigration[], migrations: Migration<any>[]) => {\n\tconst len = Math.min(runMigrations.length, migrations.length)\n\tfor (let i = 0; i < len; i++) {\n\t\tconst run = runMigrations[i]\n\t\tconst migrationName = migrations[i].name\n\t\tif (migrationName > run.name) {\n\t\t\tthrow new Error(`Previously executed migration ${run} is missing`)\n\t\t}\n\t\tif (run.name > migrationName) {\n\t\t\tthrow new Error(`Not executed migration ${migrationName} is preceding already run migration ${run.name}`)\n\t\t}\n\t}\n}\n"],"names":["MigrationBuilder"],"mappings":";;;AAKO,SAAS,yBAA2C;AAC1D,SAAO,IAAIA,iBAAAA,iBAAA;AACZ;AAEO,MAAM,mBAAmB,oBAAoB;AAE7C,MAAM,aAAa,CAAC,eAA+B,eAAiC;AAC1F,QAAM,MAAM,KAAK,IAAI,cAAc,QAAQ,WAAW,MAAM;AAC5D,WAAS,IAAI,GAAG,IAAI,KAAK,KAAK;AAC7B,UAAM,MAAM,cAAc,CAAC;AAC3B,UAAM,gBAAgB,WAAW,CAAC,EAAE;AACpC,QAAI,gBAAgB,IAAI,MAAM;AAC7B,YAAM,IAAI,MAAM,iCAAiC,GAAG,aAAa;AAAA,IAClE;AACA,QAAI,IAAI,OAAO,eAAe;AAC7B,YAAM,IAAI,MAAM,0BAA0B,aAAa,uCAAuC,IAAI,IAAI,EAAE;AAAA,IACzG;AAAA,EACD;AACD;;;;;;"}
|
|
@@ -1,19 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { escapeValue
|
|
1
|
+
import { MigrationBuilder } from "./MigrationBuilder.js";
|
|
2
|
+
import { escapeValue, isPgLiteral } from "./MigrationBuilder.js";
|
|
3
3
|
function createMigrationBuilder() {
|
|
4
|
-
|
|
5
|
-
return new impl(
|
|
6
|
-
{
|
|
7
|
-
query: null,
|
|
8
|
-
select: null
|
|
9
|
-
},
|
|
10
|
-
{},
|
|
11
|
-
false,
|
|
12
|
-
{}
|
|
13
|
-
);
|
|
14
|
-
}
|
|
15
|
-
function escapeValue(value) {
|
|
16
|
-
return escapeValue$1(value);
|
|
4
|
+
return new MigrationBuilder();
|
|
17
5
|
}
|
|
18
6
|
const timePrefixLength = "YYYY-MM-DD-XXXXXX".length;
|
|
19
7
|
const checkOrder = (runMigrations, migrations) => {
|
|
@@ -33,6 +21,7 @@ export {
|
|
|
33
21
|
checkOrder,
|
|
34
22
|
createMigrationBuilder,
|
|
35
23
|
escapeValue,
|
|
24
|
+
isPgLiteral,
|
|
36
25
|
timePrefixLength
|
|
37
26
|
};
|
|
38
27
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sources":["../../../../packages/database-migrations/src/helpers.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"helpers.js","sources":["../../../../packages/database-migrations/src/helpers.ts"],"sourcesContent":["import { Migration, RunMigration } from './Migration.js'\nimport { MigrationBuilder } from './MigrationBuilder.js'\n\nexport { escapeValue, isPgLiteral } from './MigrationBuilder.js'\n\nexport function createMigrationBuilder(): MigrationBuilder {\n\treturn new MigrationBuilder()\n}\n\nexport const timePrefixLength = 'YYYY-MM-DD-XXXXXX'.length\n\nexport const checkOrder = (runMigrations: RunMigration[], migrations: Migration<any>[]) => {\n\tconst len = Math.min(runMigrations.length, migrations.length)\n\tfor (let i = 0; i < len; i++) {\n\t\tconst run = runMigrations[i]\n\t\tconst migrationName = migrations[i].name\n\t\tif (migrationName > run.name) {\n\t\t\tthrow new Error(`Previously executed migration ${run} is missing`)\n\t\t}\n\t\tif (run.name > migrationName) {\n\t\t\tthrow new Error(`Not executed migration ${migrationName} is preceding already run migration ${run.name}`)\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;AAKO,SAAS,yBAA2C;AAC1D,SAAO,IAAI,iBAAA;AACZ;AAEO,MAAM,mBAAmB,oBAAoB;AAE7C,MAAM,aAAa,CAAC,eAA+B,eAAiC;AAC1F,QAAM,MAAM,KAAK,IAAI,cAAc,QAAQ,WAAW,MAAM;AAC5D,WAAS,IAAI,GAAG,IAAI,KAAK,KAAK;AAC7B,UAAM,MAAM,cAAc,CAAC;AAC3B,UAAM,gBAAgB,WAAW,CAAC,EAAE;AACpC,QAAI,gBAAgB,IAAI,MAAM;AAC7B,YAAM,IAAI,MAAM,iCAAiC,GAAG,aAAa;AAAA,IAClE;AACA,QAAI,IAAI,OAAO,eAAe;AAC7B,YAAM,IAAI,MAAM,0BAA0B,aAAa,uCAAuC,IAAI,IAAI,EAAE;AAAA,IACzG;AAAA,EACD;AACD;"}
|
|
@@ -5,13 +5,17 @@ const GroupMigrationsResolver = require("./src/GroupMigrationsResolver.cjs");
|
|
|
5
5
|
const SnapshotMigrationResolver = require("./src/SnapshotMigrationResolver.cjs");
|
|
6
6
|
const helpers = require("./src/helpers.cjs");
|
|
7
7
|
const Migration = require("./src/Migration.cjs");
|
|
8
|
+
const MigrationBuilder = require("./src/MigrationBuilder.cjs");
|
|
8
9
|
exports.MigrationsRunner = MigrationsRunner.MigrationsRunner;
|
|
9
10
|
exports.GroupMigrationsResolver = GroupMigrationsResolver.GroupMigrationsResolver;
|
|
10
11
|
exports.SnapshotMigrationResolver = SnapshotMigrationResolver.SnapshotMigrationResolver;
|
|
11
12
|
exports.checkOrder = helpers.checkOrder;
|
|
12
13
|
exports.createMigrationBuilder = helpers.createMigrationBuilder;
|
|
13
|
-
exports.escapeValue = helpers.escapeValue;
|
|
14
14
|
exports.timePrefixLength = helpers.timePrefixLength;
|
|
15
15
|
exports.Migration = Migration.Migration;
|
|
16
16
|
exports.MigrationGroup = Migration.MigrationGroup;
|
|
17
|
+
exports.MigrationBuilder = MigrationBuilder.MigrationBuilder;
|
|
18
|
+
exports.assertValidSequenceOptions = MigrationBuilder.assertValidSequenceOptions;
|
|
19
|
+
exports.escapeValue = MigrationBuilder.escapeValue;
|
|
20
|
+
exports.isPgLiteral = MigrationBuilder.isPgLiteral;
|
|
17
21
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;"}
|
package/dist/production/index.js
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { MigrationsRunner } from "./src/MigrationsRunner.js";
|
|
2
2
|
import { GroupMigrationsResolver } from "./src/GroupMigrationsResolver.js";
|
|
3
3
|
import { SnapshotMigrationResolver } from "./src/SnapshotMigrationResolver.js";
|
|
4
|
-
import { checkOrder, createMigrationBuilder,
|
|
4
|
+
import { checkOrder, createMigrationBuilder, timePrefixLength } from "./src/helpers.js";
|
|
5
5
|
import { Migration, MigrationGroup } from "./src/Migration.js";
|
|
6
|
+
import { MigrationBuilder, assertValidSequenceOptions, escapeValue, isPgLiteral } from "./src/MigrationBuilder.js";
|
|
6
7
|
export {
|
|
7
8
|
GroupMigrationsResolver,
|
|
8
9
|
Migration,
|
|
10
|
+
MigrationBuilder,
|
|
9
11
|
MigrationGroup,
|
|
10
12
|
MigrationsRunner,
|
|
11
13
|
SnapshotMigrationResolver,
|
|
14
|
+
assertValidSequenceOptions,
|
|
12
15
|
checkOrder,
|
|
13
16
|
createMigrationBuilder,
|
|
14
17
|
escapeValue,
|
|
18
|
+
isPgLiteral,
|
|
15
19
|
timePrefixLength
|
|
16
20
|
};
|
|
17
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Migration.cjs","sources":["../../../../packages/database-migrations/src/Migration.ts"],"sourcesContent":["import { MigrationBuilder } from '
|
|
1
|
+
{"version":3,"file":"Migration.cjs","sources":["../../../../packages/database-migrations/src/Migration.ts"],"sourcesContent":["import type { MigrationBuilder } from './MigrationBuilder.js'\nimport { Connection } from '@contember/database'\n\nexport type MigrationExecutor<Args = unknown> = (builder: MigrationBuilder, args: MigrationArgs<Args>) => Promise<void> | void\n\nexport class Migration<Args = unknown> {\n\tconstructor(\n\t\tpublic readonly name: string,\n\t\tpublic readonly migration: MigrationExecutor<Args>,\n\t\tpublic readonly group: string | null = null,\n\t) {\n\t}\n}\n\nexport type MigrationArgs<Args> =\n\t& Args\n\t& {\n\t\tconnection: Connection.ConnectionLike\n\t}\n\nexport interface RunMigration {\n\tname: string\n\tgroup: string | null\n}\n\nexport class MigrationGroup<Args = unknown> {\n\tconstructor(\n\t\tpublic readonly snapshot: MigrationExecutor<Args>,\n\t\tpublic readonly migrations: Record<string, MigrationExecutor<Args>>,\n\t) {\n\t}\n}\n"],"names":[],"mappings":";;AAKO,MAAM,UAA0B;AAAA,EACtC,YACiB,MACA,WACA,QAAuB,MACtC;AAHe,SAAA,OAAA;AACA,SAAA,YAAA;AACA,SAAA,QAAA;AAAA,EAEjB;AACD;AAaO,MAAM,eAA+B;AAAA,EAC3C,YACiB,UACA,YACf;AAFe,SAAA,WAAA;AACA,SAAA,aAAA;AAAA,EAEjB;AACD;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Migration.js","sources":["../../../../packages/database-migrations/src/Migration.ts"],"sourcesContent":["import { MigrationBuilder } from '
|
|
1
|
+
{"version":3,"file":"Migration.js","sources":["../../../../packages/database-migrations/src/Migration.ts"],"sourcesContent":["import type { MigrationBuilder } from './MigrationBuilder.js'\nimport { Connection } from '@contember/database'\n\nexport type MigrationExecutor<Args = unknown> = (builder: MigrationBuilder, args: MigrationArgs<Args>) => Promise<void> | void\n\nexport class Migration<Args = unknown> {\n\tconstructor(\n\t\tpublic readonly name: string,\n\t\tpublic readonly migration: MigrationExecutor<Args>,\n\t\tpublic readonly group: string | null = null,\n\t) {\n\t}\n}\n\nexport type MigrationArgs<Args> =\n\t& Args\n\t& {\n\t\tconnection: Connection.ConnectionLike\n\t}\n\nexport interface RunMigration {\n\tname: string\n\tgroup: string | null\n}\n\nexport class MigrationGroup<Args = unknown> {\n\tconstructor(\n\t\tpublic readonly snapshot: MigrationExecutor<Args>,\n\t\tpublic readonly migrations: Record<string, MigrationExecutor<Args>>,\n\t) {\n\t}\n}\n"],"names":[],"mappings":"AAKO,MAAM,UAA0B;AAAA,EACtC,YACiB,MACA,WACA,QAAuB,MACtC;AAHe,SAAA,OAAA;AACA,SAAA,YAAA;AACA,SAAA,QAAA;AAAA,EAEjB;AACD;AAaO,MAAM,eAA+B;AAAA,EAC3C,YACiB,UACA,YACf;AAFe,SAAA,WAAA;AACA,SAAA,aAAA;AAAA,EAEjB;AACD;"}
|