drizzle-kit 0.25.0-b4de377 → 0.25.0-b8bf113
Sign up to get free protection for your applications and to get access to all the features.
- package/api.d.mts +0 -474
- package/api.d.ts +0 -474
- package/api.js +15321 -95869
- package/api.mjs +15234 -95778
- package/bin.cjs +89 -1168
- package/package.json +1 -1
- package/utils.js +11 -51
- package/utils.mjs +11 -51
package/bin.cjs
CHANGED
@@ -922,8 +922,8 @@ var require_hanji = __commonJS({
|
|
922
922
|
};
|
923
923
|
exports2.deferred = deferred;
|
924
924
|
var Terminal = class {
|
925
|
-
constructor(
|
926
|
-
this.view =
|
925
|
+
constructor(view, stdin, stdout, closable) {
|
926
|
+
this.view = view;
|
927
927
|
this.stdin = stdin;
|
928
928
|
this.stdout = stdout;
|
929
929
|
this.closable = closable;
|
@@ -961,7 +961,7 @@ var require_hanji = __commonJS({
|
|
961
961
|
this.resolve({ status: "submitted", data: this.view.result() });
|
962
962
|
return;
|
963
963
|
}
|
964
|
-
|
964
|
+
view.input(str, key);
|
965
965
|
};
|
966
966
|
this.stdin.on("keypress", keypress);
|
967
967
|
this.view.attach(this);
|
@@ -1023,8 +1023,8 @@ var require_hanji = __commonJS({
|
|
1023
1023
|
};
|
1024
1024
|
exports2.TaskView = TaskView2;
|
1025
1025
|
var TaskTerminal = class {
|
1026
|
-
constructor(
|
1027
|
-
this.view =
|
1026
|
+
constructor(view, stdout) {
|
1027
|
+
this.view = view;
|
1028
1028
|
this.stdout = stdout;
|
1029
1029
|
this.text = "";
|
1030
1030
|
this.view.attach(this);
|
@@ -1043,22 +1043,22 @@ var require_hanji = __commonJS({
|
|
1043
1043
|
}
|
1044
1044
|
};
|
1045
1045
|
exports2.TaskTerminal = TaskTerminal;
|
1046
|
-
function render9(
|
1046
|
+
function render9(view) {
|
1047
1047
|
const { stdin, stdout, closable } = (0, readline_1.prepareReadLine)();
|
1048
|
-
if (
|
1049
|
-
const terminal = new Terminal(
|
1048
|
+
if (view instanceof Prompt3) {
|
1049
|
+
const terminal = new Terminal(view, stdin, stdout, closable);
|
1050
1050
|
terminal.requestLayout();
|
1051
1051
|
return terminal.result();
|
1052
1052
|
}
|
1053
|
-
stdout.write(`${
|
1053
|
+
stdout.write(`${view}
|
1054
1054
|
`);
|
1055
1055
|
closable.close();
|
1056
1056
|
return;
|
1057
1057
|
}
|
1058
1058
|
exports2.render = render9;
|
1059
|
-
function renderWithTask6(
|
1059
|
+
function renderWithTask6(view, task) {
|
1060
1060
|
return __awaiter2(this, void 0, void 0, function* () {
|
1061
|
-
const terminal = new TaskTerminal(
|
1061
|
+
const terminal = new TaskTerminal(view, process.stdout);
|
1062
1062
|
terminal.requestLayout();
|
1063
1063
|
const result = yield task;
|
1064
1064
|
terminal.clear();
|
@@ -5706,7 +5706,7 @@ var init_vector = __esm({
|
|
5706
5706
|
});
|
5707
5707
|
|
5708
5708
|
// src/serializer/pgSchema.ts
|
5709
|
-
var indexV2, columnV2, tableV2, enumSchemaV1, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, indexColumn, index2, indexV4, indexV5, indexV6, fk2, sequenceSchema, sequenceSquashed, columnV7, column2, columnSquashed, tableV32, compositePK2, uniqueConstraint2,
|
5709
|
+
var indexV2, columnV2, tableV2, enumSchemaV1, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, indexColumn, index2, indexV4, indexV5, indexV6, fk2, sequenceSchema, sequenceSquashed, columnV7, column2, columnSquashed, tableV32, compositePK2, uniqueConstraint2, tableV42, tableV5, tableV6, tableV7, table2, schemaHash2, kitInternals2, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaInternalV5, pgSchemaInternalV6, pgSchemaExternal, pgSchemaInternalV7, pgSchemaInternal, tableSquashed2, tableSquashedV42, pgSchemaSquashedV4, pgSchemaSquashedV6, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchemaV5, pgSchemaV6, pgSchemaV7, pgSchema, backwardCompatiblePgSchema, PgSquasher, squashPgScheme, dryPg;
|
5710
5710
|
var init_pgSchema = __esm({
|
5711
5711
|
"src/serializer/pgSchema.ts"() {
|
5712
5712
|
"use strict";
|
@@ -5901,44 +5901,6 @@ var init_pgSchema = __esm({
|
|
5901
5901
|
columns: stringType().array(),
|
5902
5902
|
nullsNotDistinct: booleanType()
|
5903
5903
|
}).strict();
|
5904
|
-
viewWithOption = objectType({
|
5905
|
-
checkOption: enumType(["local", "cascaded"]).optional(),
|
5906
|
-
securityBarrier: booleanType().optional(),
|
5907
|
-
securityInvoker: booleanType().optional()
|
5908
|
-
}).strict();
|
5909
|
-
matViewWithOption = objectType({
|
5910
|
-
fillfactor: numberType().optional(),
|
5911
|
-
toastTupleTarget: numberType().optional(),
|
5912
|
-
parallelWorkers: numberType().optional(),
|
5913
|
-
autovacuumEnabled: booleanType().optional(),
|
5914
|
-
vacuumIndexCleanup: enumType(["auto", "off", "on"]).optional(),
|
5915
|
-
vacuumTruncate: booleanType().optional(),
|
5916
|
-
autovacuumVacuumThreshold: numberType().optional(),
|
5917
|
-
autovacuumVacuumScaleFactor: numberType().optional(),
|
5918
|
-
autovacuumVacuumCostDelay: numberType().optional(),
|
5919
|
-
autovacuumVacuumCostLimit: numberType().optional(),
|
5920
|
-
autovacuumFreezeMinAge: numberType().optional(),
|
5921
|
-
autovacuumFreezeMaxAge: numberType().optional(),
|
5922
|
-
autovacuumFreezeTableAge: numberType().optional(),
|
5923
|
-
autovacuumMultixactFreezeMinAge: numberType().optional(),
|
5924
|
-
autovacuumMultixactFreezeMaxAge: numberType().optional(),
|
5925
|
-
autovacuumMultixactFreezeTableAge: numberType().optional(),
|
5926
|
-
logAutovacuumMinDuration: numberType().optional(),
|
5927
|
-
userCatalogTable: booleanType().optional()
|
5928
|
-
}).strict();
|
5929
|
-
mergedViewWithOption = viewWithOption.merge(matViewWithOption);
|
5930
|
-
view = objectType({
|
5931
|
-
name: stringType(),
|
5932
|
-
schema: stringType(),
|
5933
|
-
columns: recordType(stringType(), column2),
|
5934
|
-
definition: stringType().optional(),
|
5935
|
-
materialized: booleanType(),
|
5936
|
-
with: mergedViewWithOption.optional(),
|
5937
|
-
isExisting: booleanType(),
|
5938
|
-
withNoData: booleanType().optional(),
|
5939
|
-
using: stringType().optional(),
|
5940
|
-
tablespace: stringType().optional()
|
5941
|
-
}).strict();
|
5942
5904
|
tableV42 = objectType({
|
5943
5905
|
name: stringType(),
|
5944
5906
|
schema: stringType(),
|
@@ -6073,7 +6035,6 @@ var init_pgSchema = __esm({
|
|
6073
6035
|
tables: recordType(stringType(), table2),
|
6074
6036
|
enums: recordType(stringType(), enumSchema),
|
6075
6037
|
schemas: recordType(stringType(), stringType()),
|
6076
|
-
views: recordType(stringType(), view).default({}),
|
6077
6038
|
sequences: recordType(stringType(), sequenceSchema).default({}),
|
6078
6039
|
_meta: objectType({
|
6079
6040
|
schemas: recordType(stringType(), stringType()),
|
@@ -6118,7 +6079,6 @@ var init_pgSchema = __esm({
|
|
6118
6079
|
tables: recordType(stringType(), tableSquashed2),
|
6119
6080
|
enums: recordType(stringType(), enumSchema),
|
6120
6081
|
schemas: recordType(stringType(), stringType()),
|
6121
|
-
views: recordType(stringType(), view),
|
6122
6082
|
sequences: recordType(stringType(), sequenceSquashed)
|
6123
6083
|
}).strict();
|
6124
6084
|
pgSchemaV3 = pgSchemaInternalV3.merge(schemaHash2);
|
@@ -6336,7 +6296,6 @@ var init_pgSchema = __esm({
|
|
6336
6296
|
tables: mappedTables,
|
6337
6297
|
enums: json.enums,
|
6338
6298
|
schemas: json.schemas,
|
6339
|
-
views: json.views,
|
6340
6299
|
sequences: mappedSequences
|
6341
6300
|
};
|
6342
6301
|
};
|
@@ -8852,9 +8811,6 @@ var init_utils3 = __esm({
|
|
8852
8811
|
String.prototype.concatIf = function(it, condition) {
|
8853
8812
|
return condition ? `${this}${it}` : String(this);
|
8854
8813
|
};
|
8855
|
-
String.prototype.snake_case = function() {
|
8856
|
-
return this && this.length > 0 ? `${this.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`)}` : String(this);
|
8857
|
-
};
|
8858
8814
|
Array.prototype.random = function() {
|
8859
8815
|
return this[~~(Math.random() * this.length)];
|
8860
8816
|
};
|
@@ -12551,11 +12507,11 @@ var require_node2 = __commonJS({
|
|
12551
12507
|
};
|
12552
12508
|
var require_base64 = __commonJS3((exports3) => {
|
12553
12509
|
var intToCharMap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");
|
12554
|
-
exports3.encode = function(
|
12555
|
-
if (0 <=
|
12556
|
-
return intToCharMap[
|
12510
|
+
exports3.encode = function(number3) {
|
12511
|
+
if (0 <= number3 && number3 < intToCharMap.length) {
|
12512
|
+
return intToCharMap[number3];
|
12557
12513
|
}
|
12558
|
-
throw new TypeError("Must be between 0 and 63: " +
|
12514
|
+
throw new TypeError("Must be between 0 and 63: " + number3);
|
12559
12515
|
};
|
12560
12516
|
exports3.decode = function(charCode) {
|
12561
12517
|
var bigA = 65;
|
@@ -18508,8 +18464,6 @@ var init_pgImports = __esm({
|
|
18508
18464
|
const enums = [];
|
18509
18465
|
const schemas = [];
|
18510
18466
|
const sequences = [];
|
18511
|
-
const views = [];
|
18512
|
-
const matViews = [];
|
18513
18467
|
const i0values = Object.values(exports2);
|
18514
18468
|
i0values.forEach((t2) => {
|
18515
18469
|
if ((0, import_pg_core.isPgEnum)(t2)) {
|
@@ -18522,25 +18476,17 @@ var init_pgImports = __esm({
|
|
18522
18476
|
if ((0, import_drizzle_orm4.is)(t2, import_pg_core.PgSchema)) {
|
18523
18477
|
schemas.push(t2);
|
18524
18478
|
}
|
18525
|
-
if ((0, import_pg_core.isPgView)(t2)) {
|
18526
|
-
views.push(t2);
|
18527
|
-
}
|
18528
|
-
if ((0, import_pg_core.isPgMaterializedView)(t2)) {
|
18529
|
-
matViews.push(t2);
|
18530
|
-
}
|
18531
18479
|
if ((0, import_pg_core.isPgSequence)(t2)) {
|
18532
18480
|
sequences.push(t2);
|
18533
18481
|
}
|
18534
18482
|
});
|
18535
|
-
return { tables, enums, schemas, sequences
|
18483
|
+
return { tables, enums, schemas, sequences };
|
18536
18484
|
};
|
18537
18485
|
prepareFromPgImports = async (imports) => {
|
18538
|
-
|
18539
|
-
|
18540
|
-
|
18541
|
-
|
18542
|
-
const views = [];
|
18543
|
-
const matViews = [];
|
18486
|
+
let tables = [];
|
18487
|
+
let enums = [];
|
18488
|
+
let schemas = [];
|
18489
|
+
let sequences = [];
|
18544
18490
|
const { unregister } = await safeRegister();
|
18545
18491
|
for (let i2 = 0; i2 < imports.length; i2++) {
|
18546
18492
|
const it = imports[i2];
|
@@ -18550,11 +18496,9 @@ var init_pgImports = __esm({
|
|
18550
18496
|
enums.push(...prepared.enums);
|
18551
18497
|
schemas.push(...prepared.schemas);
|
18552
18498
|
sequences.push(...prepared.sequences);
|
18553
|
-
views.push(...prepared.views);
|
18554
|
-
matViews.push(...prepared.matViews);
|
18555
18499
|
}
|
18556
18500
|
unregister();
|
18557
|
-
return { tables: Array.from(new Set(tables)), enums, schemas, sequences
|
18501
|
+
return { tables: Array.from(new Set(tables)), enums, schemas, sequences };
|
18558
18502
|
};
|
18559
18503
|
}
|
18560
18504
|
});
|
@@ -18618,10 +18562,9 @@ var init_pgSerializer = __esm({
|
|
18618
18562
|
indexName2 = (tableName, columns) => {
|
18619
18563
|
return `${tableName}_${columns.join("_")}_index`;
|
18620
18564
|
};
|
18621
|
-
generatePgSnapshot = (tables, enums, schemas, sequences,
|
18622
|
-
var _a, _b, _c, _d, _e, _f
|
18565
|
+
generatePgSnapshot = (tables, enums, schemas, sequences, schemaFilter) => {
|
18566
|
+
var _a, _b, _c, _d, _e, _f;
|
18623
18567
|
const result = {};
|
18624
|
-
const resultViews = {};
|
18625
18568
|
const sequencesToReturn = {};
|
18626
18569
|
const indexesInSchema = {};
|
18627
18570
|
for (const table4 of tables) {
|
@@ -18920,149 +18863,6 @@ ${withStyle.errorWarning(
|
|
18920
18863
|
} else {
|
18921
18864
|
}
|
18922
18865
|
}
|
18923
|
-
const combinedViews = [...views, ...matViews];
|
18924
|
-
for (const view2 of combinedViews) {
|
18925
|
-
let viewName;
|
18926
|
-
let schema5;
|
18927
|
-
let query;
|
18928
|
-
let selectedFields;
|
18929
|
-
let isExisting;
|
18930
|
-
let withOption;
|
18931
|
-
let tablespace;
|
18932
|
-
let using;
|
18933
|
-
let withNoData;
|
18934
|
-
let materialized = false;
|
18935
|
-
if ((0, import_drizzle_orm5.is)(view2, import_pg_core2.PgView)) {
|
18936
|
-
({ name: viewName, schema: schema5, query, selectedFields, isExisting, with: withOption } = (0, import_pg_core2.getViewConfig)(view2));
|
18937
|
-
} else {
|
18938
|
-
({ name: viewName, schema: schema5, query, selectedFields, isExisting, with: withOption, tablespace, using, withNoData } = (0, import_pg_core2.getMaterializedViewConfig)(
|
18939
|
-
view2
|
18940
|
-
));
|
18941
|
-
materialized = true;
|
18942
|
-
}
|
18943
|
-
const viewSchema = schema5 ?? "public";
|
18944
|
-
const viewKey = `${viewSchema}.${viewName}`;
|
18945
|
-
const columnsObject = {};
|
18946
|
-
const uniqueConstraintObject = {};
|
18947
|
-
const existingView = resultViews[viewKey];
|
18948
|
-
if (typeof existingView !== "undefined") {
|
18949
|
-
console.log(
|
18950
|
-
`
|
18951
|
-
${withStyle.errorWarning(
|
18952
|
-
`We've found duplicated view name across ${source_default.underline.blue(
|
18953
|
-
schema5 ?? "public"
|
18954
|
-
)} schema. Please rename your view`
|
18955
|
-
)}`
|
18956
|
-
);
|
18957
|
-
process.exit(1);
|
18958
|
-
}
|
18959
|
-
for (const key in selectedFields) {
|
18960
|
-
if ((0, import_drizzle_orm5.is)(selectedFields[key], import_pg_core2.PgColumn)) {
|
18961
|
-
const column7 = selectedFields[key];
|
18962
|
-
const notNull = column7.notNull;
|
18963
|
-
const primaryKey = column7.primary;
|
18964
|
-
const sqlTypeLowered = column7.getSQLType().toLowerCase();
|
18965
|
-
const typeSchema = (0, import_drizzle_orm5.is)(column7, import_pg_core2.PgEnumColumn) ? column7.enum.schema || "public" : void 0;
|
18966
|
-
const generated = column7.generated;
|
18967
|
-
const identity = column7.generatedIdentity;
|
18968
|
-
const increment = stringFromIdentityProperty((_g = identity == null ? void 0 : identity.sequenceOptions) == null ? void 0 : _g.increment) ?? "1";
|
18969
|
-
const minValue = stringFromIdentityProperty((_h = identity == null ? void 0 : identity.sequenceOptions) == null ? void 0 : _h.minValue) ?? (parseFloat(increment) < 0 ? minRangeForIdentityBasedOn(column7.columnType) : "1");
|
18970
|
-
const maxValue = stringFromIdentityProperty((_i = identity == null ? void 0 : identity.sequenceOptions) == null ? void 0 : _i.maxValue) ?? (parseFloat(increment) < 0 ? "-1" : maxRangeForIdentityBasedOn(column7.getSQLType()));
|
18971
|
-
const startWith = stringFromIdentityProperty((_j = identity == null ? void 0 : identity.sequenceOptions) == null ? void 0 : _j.startWith) ?? (parseFloat(increment) < 0 ? maxValue : minValue);
|
18972
|
-
const cache = stringFromIdentityProperty((_k = identity == null ? void 0 : identity.sequenceOptions) == null ? void 0 : _k.cache) ?? "1";
|
18973
|
-
const columnToSet = {
|
18974
|
-
name: column7.name,
|
18975
|
-
type: column7.getSQLType(),
|
18976
|
-
typeSchema,
|
18977
|
-
primaryKey,
|
18978
|
-
notNull,
|
18979
|
-
generated: generated ? {
|
18980
|
-
as: (0, import_drizzle_orm5.is)(generated.as, import_drizzle_orm5.SQL) ? dialect5.sqlToQuery(generated.as).sql : typeof generated.as === "function" ? dialect5.sqlToQuery(generated.as()).sql : generated.as,
|
18981
|
-
type: "stored"
|
18982
|
-
} : void 0,
|
18983
|
-
identity: identity ? {
|
18984
|
-
type: identity.type,
|
18985
|
-
name: identity.sequenceName ?? `${viewName}_${column7.name}_seq`,
|
18986
|
-
schema: schema5 ?? "public",
|
18987
|
-
increment,
|
18988
|
-
startWith,
|
18989
|
-
minValue,
|
18990
|
-
maxValue,
|
18991
|
-
cache,
|
18992
|
-
cycle: ((_l = identity == null ? void 0 : identity.sequenceOptions) == null ? void 0 : _l.cycle) ?? false
|
18993
|
-
} : void 0
|
18994
|
-
};
|
18995
|
-
if (column7.isUnique) {
|
18996
|
-
const existingUnique = uniqueConstraintObject[column7.uniqueName];
|
18997
|
-
if (typeof existingUnique !== "undefined") {
|
18998
|
-
console.log(
|
18999
|
-
`
|
19000
|
-
${withStyle.errorWarning(`We've found duplicated unique constraint names in ${source_default.underline.blue(
|
19001
|
-
viewName
|
19002
|
-
)} table.
|
19003
|
-
The unique constraint ${source_default.underline.blue(
|
19004
|
-
column7.uniqueName
|
19005
|
-
)} on the ${source_default.underline.blue(
|
19006
|
-
column7.name
|
19007
|
-
)} column is confilcting with a unique constraint name already defined for ${source_default.underline.blue(
|
19008
|
-
existingUnique.columns.join(",")
|
19009
|
-
)} columns
|
19010
|
-
`)}`
|
19011
|
-
);
|
19012
|
-
process.exit(1);
|
19013
|
-
}
|
19014
|
-
uniqueConstraintObject[column7.uniqueName] = {
|
19015
|
-
name: column7.uniqueName,
|
19016
|
-
nullsNotDistinct: column7.uniqueType === "not distinct",
|
19017
|
-
columns: [columnToSet.name]
|
19018
|
-
};
|
19019
|
-
}
|
19020
|
-
if (column7.default !== void 0) {
|
19021
|
-
if ((0, import_drizzle_orm5.is)(column7.default, import_drizzle_orm5.SQL)) {
|
19022
|
-
columnToSet.default = sqlToStr(column7.default);
|
19023
|
-
} else {
|
19024
|
-
if (typeof column7.default === "string") {
|
19025
|
-
columnToSet.default = `'${column7.default}'`;
|
19026
|
-
} else {
|
19027
|
-
if (sqlTypeLowered === "jsonb" || sqlTypeLowered === "json") {
|
19028
|
-
columnToSet.default = `'${JSON.stringify(
|
19029
|
-
column7.default
|
19030
|
-
)}'::${sqlTypeLowered}`;
|
19031
|
-
} else if (column7.default instanceof Date) {
|
19032
|
-
if (sqlTypeLowered === "date") {
|
19033
|
-
columnToSet.default = `'${column7.default.toISOString().split("T")[0]}'`;
|
19034
|
-
} else if (sqlTypeLowered === "timestamp") {
|
19035
|
-
columnToSet.default = `'${column7.default.toISOString().replace("T", " ").slice(0, 23)}'`;
|
19036
|
-
} else {
|
19037
|
-
columnToSet.default = `'${column7.default.toISOString()}'`;
|
19038
|
-
}
|
19039
|
-
} else if (isPgArrayType(sqlTypeLowered) && Array.isArray(column7.default)) {
|
19040
|
-
columnToSet.default = `'${buildArrayString(
|
19041
|
-
column7.default,
|
19042
|
-
sqlTypeLowered
|
19043
|
-
)}'`;
|
19044
|
-
} else {
|
19045
|
-
columnToSet.default = column7.default;
|
19046
|
-
}
|
19047
|
-
}
|
19048
|
-
}
|
19049
|
-
}
|
19050
|
-
columnsObject[column7.name] = columnToSet;
|
19051
|
-
}
|
19052
|
-
}
|
19053
|
-
resultViews[viewKey] = {
|
19054
|
-
columns: columnsObject,
|
19055
|
-
definition: isExisting ? void 0 : dialect5.sqlToQuery(query).sql,
|
19056
|
-
name: viewName,
|
19057
|
-
schema: viewSchema,
|
19058
|
-
isExisting,
|
19059
|
-
with: withOption,
|
19060
|
-
withNoData,
|
19061
|
-
materialized,
|
19062
|
-
tablespace,
|
19063
|
-
using
|
19064
|
-
};
|
19065
|
-
}
|
19066
18866
|
const enumsToReturn = enums.reduce((map, obj) => {
|
19067
18867
|
const enumSchema3 = obj.schema || "public";
|
19068
18868
|
const key = `${enumSchema3}.${obj.enumName}`;
|
@@ -19089,7 +18889,6 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
|
|
19089
18889
|
enums: enumsToReturn,
|
19090
18890
|
schemas: schemasObject,
|
19091
18891
|
sequences: sequencesToReturn,
|
19092
|
-
views: resultViews,
|
19093
18892
|
_meta: {
|
19094
18893
|
schemas: {},
|
19095
18894
|
tables: {},
|
@@ -19108,25 +18907,10 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
|
|
19108
18907
|
};
|
19109
18908
|
fromDatabase2 = async (db, tablesFilter = () => true, schemaFilters, progressCallback) => {
|
19110
18909
|
const result = {};
|
19111
|
-
const views = {};
|
19112
18910
|
const internals = { tables: {} };
|
19113
|
-
const where = schemaFilters.map((t2) => `
|
18911
|
+
const where = schemaFilters.map((t2) => `table_schema = '${t2}'`).join(" or ");
|
19114
18912
|
const allTables = await db.query(
|
19115
|
-
`SELECT
|
19116
|
-
n.nspname AS table_schema,
|
19117
|
-
c.relname AS table_name,
|
19118
|
-
CASE
|
19119
|
-
WHEN c.relkind = 'r' THEN 'table'
|
19120
|
-
WHEN c.relkind = 'v' THEN 'view'
|
19121
|
-
WHEN c.relkind = 'm' THEN 'materialized_view'
|
19122
|
-
END AS type
|
19123
|
-
FROM
|
19124
|
-
pg_catalog.pg_class c
|
19125
|
-
JOIN
|
19126
|
-
pg_catalog.pg_namespace n ON n.oid = c.relnamespace
|
19127
|
-
WHERE
|
19128
|
-
c.relkind IN ('r', 'v', 'm')
|
19129
|
-
${where === "" ? "" : ` AND ${where}`};`
|
18913
|
+
`SELECT table_schema, table_name FROM information_schema.tables${where === "" ? "" : ` WHERE ${where}`};`
|
19130
18914
|
);
|
19131
18915
|
const schemas = new Set(allTables.map((it) => it.table_schema));
|
19132
18916
|
schemas.delete("public");
|
@@ -19204,7 +18988,7 @@ WHERE
|
|
19204
18988
|
progressCallback("enums", Object.keys(enumsToReturn).length, "done");
|
19205
18989
|
}
|
19206
18990
|
const sequencesInColumns = [];
|
19207
|
-
const all = allTables.
|
18991
|
+
const all = allTables.map((row) => {
|
19208
18992
|
return new Promise(async (res, rej) => {
|
19209
18993
|
var _a, _b, _c, _d, _e, _f;
|
19210
18994
|
const tableName = row.table_name;
|
@@ -19613,336 +19397,6 @@ WHERE
|
|
19613
19397
|
}
|
19614
19398
|
for await (const _2 of all) {
|
19615
19399
|
}
|
19616
|
-
const allViews = allTables.filter((it) => it.type === "view" || it.type === "materialized_view").map((row) => {
|
19617
|
-
return new Promise(async (res, rej) => {
|
19618
|
-
var _a, _b, _c, _d;
|
19619
|
-
const viewName = row.table_name;
|
19620
|
-
if (!tablesFilter(viewName))
|
19621
|
-
return res("");
|
19622
|
-
tableCount += 1;
|
19623
|
-
const viewSchema = row.table_schema;
|
19624
|
-
try {
|
19625
|
-
const columnToReturn = {};
|
19626
|
-
const viewResponses = await db.query(`WITH view_columns AS (
|
19627
|
-
SELECT DISTINCT
|
19628
|
-
nv.nspname::information_schema.sql_identifier AS view_schema,
|
19629
|
-
v.relname::information_schema.sql_identifier AS view_name,
|
19630
|
-
nt.nspname::information_schema.sql_identifier AS table_schema,
|
19631
|
-
t.relname::information_schema.sql_identifier AS table_name,
|
19632
|
-
a.attname::information_schema.sql_identifier AS column_name
|
19633
|
-
FROM pg_namespace nv
|
19634
|
-
JOIN pg_class v ON nv.oid = v.relnamespace
|
19635
|
-
JOIN pg_depend dv ON v.oid = dv.refobjid
|
19636
|
-
JOIN pg_depend dt ON dv.objid = dt.objid
|
19637
|
-
JOIN pg_class t ON dt.refobjid = t.oid
|
19638
|
-
JOIN pg_namespace nt ON t.relnamespace = nt.oid
|
19639
|
-
JOIN pg_attribute a ON t.oid = a.attrelid
|
19640
|
-
WHERE (v.relkind = 'v'::"char" OR v.relkind = 'm'::"char")
|
19641
|
-
AND dv.refclassid = 'pg_class'::regclass::oid
|
19642
|
-
AND dv.classid = 'pg_rewrite'::regclass::oid
|
19643
|
-
AND dv.deptype = 'i'::"char"
|
19644
|
-
AND dv.objid = dt.objid
|
19645
|
-
AND dv.refobjid <> dt.refobjid
|
19646
|
-
AND dt.classid = 'pg_rewrite'::regclass::oid
|
19647
|
-
AND dt.refclassid = 'pg_class'::regclass::oid
|
19648
|
-
AND t.relkind = ANY (ARRAY['r'::"char", 'v'::"char", 'f'::"char", 'p'::"char"])
|
19649
|
-
AND dt.refobjsubid = a.attnum
|
19650
|
-
AND pg_has_role(t.relowner, 'USAGE'::text)
|
19651
|
-
AND nv.nspname::information_schema.sql_identifier = '${viewSchema}'
|
19652
|
-
AND v.relname::information_schema.sql_identifier = '${viewName}'
|
19653
|
-
),
|
19654
|
-
column_descriptions AS (
|
19655
|
-
SELECT DISTINCT
|
19656
|
-
a.attrelid::regclass::text AS table_name,
|
19657
|
-
a.attname AS column_name,
|
19658
|
-
c.is_nullable,
|
19659
|
-
a.attndims AS array_dimensions,
|
19660
|
-
CASE
|
19661
|
-
WHEN a.atttypid = ANY ('{int,int8,int2}'::regtype[]) AND EXISTS (
|
19662
|
-
SELECT FROM pg_attrdef ad
|
19663
|
-
WHERE ad.adrelid = a.attrelid
|
19664
|
-
AND ad.adnum = a.attnum
|
19665
|
-
AND pg_get_expr(ad.adbin, ad.adrelid) = 'nextval(''' || pg_get_serial_sequence(a.attrelid::regclass::text, a.attname)::regclass || '''::regclass)'
|
19666
|
-
)
|
19667
|
-
THEN CASE a.atttypid
|
19668
|
-
WHEN 'int'::regtype THEN 'serial'
|
19669
|
-
WHEN 'int8'::regtype THEN 'bigserial'
|
19670
|
-
WHEN 'int2'::regtype THEN 'smallserial'
|
19671
|
-
END
|
19672
|
-
ELSE format_type(a.atttypid, a.atttypmod)
|
19673
|
-
END AS data_type,
|
19674
|
-
pg_get_serial_sequence('"' || c.table_schema || '"."' || c.table_name || '"', a.attname)::regclass AS seq_name,
|
19675
|
-
c.column_default,
|
19676
|
-
c.data_type AS additional_dt,
|
19677
|
-
c.udt_name AS enum_name,
|
19678
|
-
c.is_generated,
|
19679
|
-
c.generation_expression,
|
19680
|
-
c.is_identity,
|
19681
|
-
c.identity_generation,
|
19682
|
-
c.identity_start,
|
19683
|
-
c.identity_increment,
|
19684
|
-
c.identity_maximum,
|
19685
|
-
c.identity_minimum,
|
19686
|
-
c.identity_cycle
|
19687
|
-
FROM pg_attribute a
|
19688
|
-
JOIN information_schema.columns c ON c.column_name = a.attname
|
19689
|
-
JOIN pg_type t ON t.oid = a.atttypid
|
19690
|
-
LEFT JOIN pg_namespace ns ON ns.oid = t.typnamespace
|
19691
|
-
WHERE a.attnum > 0
|
19692
|
-
AND NOT a.attisdropped
|
19693
|
-
),
|
19694
|
-
table_constraints AS (
|
19695
|
-
SELECT DISTINCT ON (ccu.column_name)
|
19696
|
-
ccu.column_name,
|
19697
|
-
c.data_type,
|
19698
|
-
tc.constraint_type,
|
19699
|
-
tc.constraint_name,
|
19700
|
-
tc.constraint_schema,
|
19701
|
-
tc.table_name
|
19702
|
-
FROM information_schema.table_constraints tc
|
19703
|
-
JOIN information_schema.constraint_column_usage ccu USING (constraint_schema, constraint_name)
|
19704
|
-
JOIN information_schema.columns c ON c.table_schema = tc.constraint_schema
|
19705
|
-
AND tc.table_name = c.table_name
|
19706
|
-
AND ccu.column_name = c.column_name
|
19707
|
-
),
|
19708
|
-
additional_column_info AS (
|
19709
|
-
SELECT DISTINCT
|
19710
|
-
a.attrelid::regclass::text AS table_name,
|
19711
|
-
a.attname AS column_name,
|
19712
|
-
is_nullable,
|
19713
|
-
a.attndims AS array_dimensions,
|
19714
|
-
CASE
|
19715
|
-
WHEN a.atttypid = ANY ('{int,int8,int2}'::regtype[]) AND EXISTS (
|
19716
|
-
SELECT FROM pg_attrdef ad
|
19717
|
-
WHERE ad.adrelid = a.attrelid
|
19718
|
-
AND ad.adnum = a.attnum
|
19719
|
-
AND pg_get_expr(ad.adbin, ad.adrelid) = 'nextval(''' || pg_get_serial_sequence(a.attrelid::regclass::text, a.attname)::regclass || '''::regclass)'
|
19720
|
-
)
|
19721
|
-
THEN CASE a.atttypid
|
19722
|
-
WHEN 'int'::regtype THEN 'serial'
|
19723
|
-
WHEN 'int8'::regtype THEN 'bigserial'
|
19724
|
-
WHEN 'int2'::regtype THEN 'smallserial'
|
19725
|
-
END
|
19726
|
-
ELSE format_type(a.atttypid, a.atttypmod)
|
19727
|
-
END AS data_type,
|
19728
|
-
pg_get_serial_sequence('"' || c.table_schema || '"."' || c.table_name || '"', a.attname)::regclass AS seq_name,
|
19729
|
-
c.column_default,
|
19730
|
-
c.data_type AS additional_dt,
|
19731
|
-
c.udt_name AS enum_name,
|
19732
|
-
c.is_generated,
|
19733
|
-
generation_expression,
|
19734
|
-
is_identity,
|
19735
|
-
identity_generation,
|
19736
|
-
identity_start,
|
19737
|
-
identity_increment,
|
19738
|
-
identity_maximum,
|
19739
|
-
identity_minimum,
|
19740
|
-
identity_cycle
|
19741
|
-
FROM pg_attribute a
|
19742
|
-
JOIN information_schema.columns c ON c.column_name = a.attname
|
19743
|
-
LEFT JOIN pg_type t ON t.oid = a.atttypid
|
19744
|
-
LEFT JOIN pg_namespace ns ON ns.oid = t.typnamespace
|
19745
|
-
WHERE a.attnum > 0
|
19746
|
-
AND NOT a.attisdropped
|
19747
|
-
)
|
19748
|
-
SELECT DISTINCT ON (vc.table_name, vc.column_name)
|
19749
|
-
vc.view_schema,
|
19750
|
-
vc.view_name,
|
19751
|
-
vc.table_schema,
|
19752
|
-
vc.table_name,
|
19753
|
-
vc.column_name,
|
19754
|
-
COALESCE(cd.data_type, aci.data_type) AS data_type,
|
19755
|
-
tc.constraint_type,
|
19756
|
-
tc.constraint_name,
|
19757
|
-
aci.is_nullable,
|
19758
|
-
aci.array_dimensions,
|
19759
|
-
aci.seq_name,
|
19760
|
-
aci.column_default,
|
19761
|
-
aci.additional_dt,
|
19762
|
-
aci.enum_name,
|
19763
|
-
aci.is_generated,
|
19764
|
-
aci.generation_expression,
|
19765
|
-
aci.is_identity,
|
19766
|
-
aci.identity_generation,
|
19767
|
-
aci.identity_start,
|
19768
|
-
aci.identity_increment,
|
19769
|
-
aci.identity_maximum,
|
19770
|
-
aci.identity_minimum,
|
19771
|
-
aci.identity_cycle
|
19772
|
-
FROM view_columns vc
|
19773
|
-
LEFT JOIN column_descriptions cd ON vc.table_name = cd.table_name AND vc.column_name = cd.column_name
|
19774
|
-
LEFT JOIN table_constraints tc ON vc.table_name = tc.table_name AND vc.column_name = tc.column_name
|
19775
|
-
LEFT JOIN additional_column_info aci ON vc.table_name = aci.table_name AND vc.column_name = aci.column_name
|
19776
|
-
ORDER BY vc.table_name, vc.column_name;`);
|
19777
|
-
for (const viewResponse of viewResponses) {
|
19778
|
-
const columnName = viewResponse.column_name;
|
19779
|
-
const columnAdditionalDT = viewResponse.additional_dt;
|
19780
|
-
const columnDimensions = viewResponse.array_dimensions;
|
19781
|
-
const enumType2 = viewResponse.enum_name;
|
19782
|
-
let columnType = viewResponse.data_type;
|
19783
|
-
const typeSchema = viewResponse.type_schema;
|
19784
|
-
const isGenerated = viewResponse.is_generated === "ALWAYS";
|
19785
|
-
const generationExpression = viewResponse.generation_expression;
|
19786
|
-
const isIdentity = viewResponse.is_identity === "YES";
|
19787
|
-
const identityGeneration = viewResponse.identity_generation === "ALWAYS" ? "always" : "byDefault";
|
19788
|
-
const identityStart = viewResponse.identity_start;
|
19789
|
-
const identityIncrement = viewResponse.identity_increment;
|
19790
|
-
const identityMaximum = viewResponse.identity_maximum;
|
19791
|
-
const identityMinimum = viewResponse.identity_minimum;
|
19792
|
-
const identityCycle = viewResponse.identity_cycle === "YES";
|
19793
|
-
const identityName = viewResponse.seq_name;
|
19794
|
-
const defaultValueRes = viewResponse.column_default;
|
19795
|
-
const primaryKey = viewResponse.constraint_type === "PRIMARY KEY";
|
19796
|
-
let columnTypeMapped = columnType;
|
19797
|
-
if (columnAdditionalDT === "ARRAY") {
|
19798
|
-
if (typeof internals.tables[viewName] === "undefined") {
|
19799
|
-
internals.tables[viewName] = {
|
19800
|
-
columns: {
|
19801
|
-
[columnName]: {
|
19802
|
-
isArray: true,
|
19803
|
-
dimensions: columnDimensions,
|
19804
|
-
rawType: columnTypeMapped.substring(
|
19805
|
-
0,
|
19806
|
-
columnTypeMapped.length - 2
|
19807
|
-
)
|
19808
|
-
}
|
19809
|
-
}
|
19810
|
-
};
|
19811
|
-
} else {
|
19812
|
-
if (typeof internals.tables[viewName].columns[columnName] === "undefined") {
|
19813
|
-
internals.tables[viewName].columns[columnName] = {
|
19814
|
-
isArray: true,
|
19815
|
-
dimensions: columnDimensions,
|
19816
|
-
rawType: columnTypeMapped.substring(
|
19817
|
-
0,
|
19818
|
-
columnTypeMapped.length - 2
|
19819
|
-
)
|
19820
|
-
};
|
19821
|
-
}
|
19822
|
-
}
|
19823
|
-
}
|
19824
|
-
const defaultValue = defaultForColumn(
|
19825
|
-
viewResponse,
|
19826
|
-
internals,
|
19827
|
-
viewName
|
19828
|
-
);
|
19829
|
-
if (defaultValue === "NULL" || defaultValueRes && defaultValueRes.startsWith("(") && defaultValueRes.endsWith(")")) {
|
19830
|
-
if (typeof internals.tables[viewName] === "undefined") {
|
19831
|
-
internals.tables[viewName] = {
|
19832
|
-
columns: {
|
19833
|
-
[columnName]: {
|
19834
|
-
isDefaultAnExpression: true
|
19835
|
-
}
|
19836
|
-
}
|
19837
|
-
};
|
19838
|
-
} else {
|
19839
|
-
if (typeof internals.tables[viewName].columns[columnName] === "undefined") {
|
19840
|
-
internals.tables[viewName].columns[columnName] = {
|
19841
|
-
isDefaultAnExpression: true
|
19842
|
-
};
|
19843
|
-
} else {
|
19844
|
-
internals.tables[viewName].columns[columnName].isDefaultAnExpression = true;
|
19845
|
-
}
|
19846
|
-
}
|
19847
|
-
}
|
19848
|
-
const isSerial = columnType === "serial";
|
19849
|
-
if (columnTypeMapped.startsWith("numeric(")) {
|
19850
|
-
columnTypeMapped = columnTypeMapped.replace(",", ", ");
|
19851
|
-
}
|
19852
|
-
if (columnAdditionalDT === "ARRAY") {
|
19853
|
-
for (let i2 = 1; i2 < Number(columnDimensions); i2++) {
|
19854
|
-
columnTypeMapped += "[]";
|
19855
|
-
}
|
19856
|
-
}
|
19857
|
-
columnTypeMapped = columnTypeMapped.replace("character varying", "varchar").replace(" without time zone", "").replace("character", "char");
|
19858
|
-
columnTypeMapped = trimChar(columnTypeMapped, '"');
|
19859
|
-
columnToReturn[columnName] = {
|
19860
|
-
name: columnName,
|
19861
|
-
type: (
|
19862
|
-
// filter vectors, but in future we should filter any extension that was installed by user
|
19863
|
-
columnAdditionalDT === "USER-DEFINED" && !["vector", "geometry"].includes(enumType2) ? enumType2 : columnTypeMapped
|
19864
|
-
),
|
19865
|
-
typeSchema: enumsToReturn[`${typeSchema}.${enumType2}`] !== void 0 ? enumsToReturn[`${typeSchema}.${enumType2}`].schema : void 0,
|
19866
|
-
primaryKey,
|
19867
|
-
notNull: viewResponse.is_nullable === "NO",
|
19868
|
-
generated: isGenerated ? { as: generationExpression, type: "stored" } : void 0,
|
19869
|
-
identity: isIdentity ? {
|
19870
|
-
type: identityGeneration,
|
19871
|
-
name: identityName,
|
19872
|
-
increment: stringFromDatabaseIdentityProperty(identityIncrement),
|
19873
|
-
minValue: stringFromDatabaseIdentityProperty(identityMinimum),
|
19874
|
-
maxValue: stringFromDatabaseIdentityProperty(identityMaximum),
|
19875
|
-
startWith: stringFromDatabaseIdentityProperty(identityStart),
|
19876
|
-
cache: ((_a = sequencesToReturn[identityName]) == null ? void 0 : _a.cache) ? (_b = sequencesToReturn[identityName]) == null ? void 0 : _b.cache : ((_c = sequencesToReturn[`${viewSchema}.${identityName}`]) == null ? void 0 : _c.cache) ? (_d = sequencesToReturn[`${viewSchema}.${identityName}`]) == null ? void 0 : _d.cache : void 0,
|
19877
|
-
cycle: identityCycle,
|
19878
|
-
schema: viewSchema
|
19879
|
-
} : void 0
|
19880
|
-
};
|
19881
|
-
if (identityName) {
|
19882
|
-
delete sequencesToReturn[`${viewSchema}.${identityName.startsWith('"') && identityName.endsWith('"') ? identityName.slice(1, -1) : identityName}`];
|
19883
|
-
delete sequencesToReturn[identityName];
|
19884
|
-
}
|
19885
|
-
if (!isSerial && typeof defaultValue !== "undefined") {
|
19886
|
-
columnToReturn[columnName].default = defaultValue;
|
19887
|
-
}
|
19888
|
-
}
|
19889
|
-
const [viewInfo] = await db.query(`
|
19890
|
-
SELECT
|
19891
|
-
c.relname AS view_name,
|
19892
|
-
n.nspname AS schema_name,
|
19893
|
-
pg_get_viewdef(c.oid, true) AS definition,
|
19894
|
-
ts.spcname AS tablespace_name,
|
19895
|
-
c.reloptions AS options,
|
19896
|
-
pg_tablespace_location(ts.oid) AS location
|
19897
|
-
FROM
|
19898
|
-
pg_class c
|
19899
|
-
JOIN
|
19900
|
-
pg_namespace n ON c.relnamespace = n.oid
|
19901
|
-
LEFT JOIN
|
19902
|
-
pg_tablespace ts ON c.reltablespace = ts.oid
|
19903
|
-
WHERE
|
19904
|
-
(c.relkind = 'm' OR c.relkind = 'v')
|
19905
|
-
AND n.nspname = '${viewSchema}'
|
19906
|
-
AND c.relname = '${viewName}';`);
|
19907
|
-
const resultWith = {};
|
19908
|
-
if (viewInfo.options) {
|
19909
|
-
viewInfo.options.forEach((pair) => {
|
19910
|
-
const splitted = pair.split("=");
|
19911
|
-
const key = splitted[0];
|
19912
|
-
const value = splitted[1];
|
19913
|
-
if (value === "true") {
|
19914
|
-
resultWith[key] = true;
|
19915
|
-
} else if (value === "false") {
|
19916
|
-
resultWith[key] = false;
|
19917
|
-
} else if (!isNaN(Number(value))) {
|
19918
|
-
resultWith[key] = Number(value);
|
19919
|
-
} else {
|
19920
|
-
resultWith[key] = value;
|
19921
|
-
}
|
19922
|
-
});
|
19923
|
-
}
|
19924
|
-
const definition = viewInfo.definition.replace(/\s+/g, " ").replace(";", "").trim();
|
19925
|
-
const withOption = Object.values(resultWith).length ? Object.fromEntries(Object.entries(resultWith).map(([key, value]) => [key.camelCase(), value])) : void 0;
|
19926
|
-
const materialized = row.type === "materialized_view";
|
19927
|
-
views[`${viewSchema}.${viewName}`] = {
|
19928
|
-
name: viewName,
|
19929
|
-
schema: viewSchema,
|
19930
|
-
columns: columnToReturn,
|
19931
|
-
isExisting: false,
|
19932
|
-
definition,
|
19933
|
-
materialized,
|
19934
|
-
with: withOption,
|
19935
|
-
tablespace: viewInfo.tablespace_name ?? void 0
|
19936
|
-
};
|
19937
|
-
} catch (e2) {
|
19938
|
-
rej(e2);
|
19939
|
-
return;
|
19940
|
-
}
|
19941
|
-
res("");
|
19942
|
-
});
|
19943
|
-
});
|
19944
|
-
for await (const _2 of allViews) {
|
19945
|
-
}
|
19946
19400
|
if (progressCallback) {
|
19947
19401
|
progressCallback("columns", columnsCount, "done");
|
19948
19402
|
progressCallback("indexes", indexesCount, "done");
|
@@ -19956,7 +19410,6 @@ WHERE
|
|
19956
19410
|
enums: enumsToReturn,
|
19957
19411
|
schemas: schemasObject,
|
19958
19412
|
sequences: sequencesToReturn,
|
19959
|
-
views,
|
19960
19413
|
_meta: {
|
19961
19414
|
schemas: {},
|
19962
19415
|
tables: {},
|
@@ -20599,10 +20052,10 @@ ${filenames.join("\n")}
|
|
20599
20052
|
const filenames = prepareFilenames(path5);
|
20600
20053
|
const { prepareFromPgImports: prepareFromPgImports2 } = await Promise.resolve().then(() => (init_pgImports(), pgImports_exports));
|
20601
20054
|
const { generatePgSnapshot: generatePgSnapshot2 } = await Promise.resolve().then(() => (init_pgSerializer(), pgSerializer_exports));
|
20602
|
-
const { tables, enums, schemas, sequences
|
20055
|
+
const { tables, enums, schemas, sequences } = await prepareFromPgImports2(
|
20603
20056
|
filenames
|
20604
20057
|
);
|
20605
|
-
return generatePgSnapshot2(tables, enums, schemas, sequences,
|
20058
|
+
return generatePgSnapshot2(tables, enums, schemas, sequences, schemaFilter);
|
20606
20059
|
};
|
20607
20060
|
serializeSQLite = async (path5) => {
|
20608
20061
|
const filenames = prepareFilenames(path5);
|
@@ -23118,7 +22571,6 @@ function applyJsonDiff(json1, json2) {
|
|
23118
22571
|
difference.tables = difference.tables || {};
|
23119
22572
|
difference.enums = difference.enums || {};
|
23120
22573
|
difference.sequences = difference.sequences || {};
|
23121
|
-
difference.views = difference.views || {};
|
23122
22574
|
const schemaKeys = Object.keys(difference.schemas);
|
23123
22575
|
for (let key of schemaKeys) {
|
23124
22576
|
if (key.endsWith("__added") || key.endsWith("__deleted")) {
|
@@ -23174,71 +22626,6 @@ function applyJsonDiff(json1, json2) {
|
|
23174
22626
|
const alteredSequences = sequencesEntries.filter((it) => !(it[0].includes("__added") || it[0].includes("__deleted")) && "values" in it[1]).map((it) => {
|
23175
22627
|
return json2.sequences[it[0]];
|
23176
22628
|
});
|
23177
|
-
const viewsEntries = Object.entries(difference.views);
|
23178
|
-
const alteredViews = viewsEntries.filter((it) => !(it[0].includes("__added") || it[0].includes("__deleted"))).map(
|
23179
|
-
([nameWithSchema, view2]) => {
|
23180
|
-
const deletedWithOption = view2.with__deleted;
|
23181
|
-
const addedWithOption = view2.with__added;
|
23182
|
-
const deletedWith = Object.fromEntries(
|
23183
|
-
Object.entries(view2.with || {}).filter((it) => it[0].endsWith("__deleted")).map(([key, value]) => {
|
23184
|
-
return [key.replace("__deleted", ""), value];
|
23185
|
-
})
|
23186
|
-
);
|
23187
|
-
const addedWith = Object.fromEntries(
|
23188
|
-
Object.entries(view2.with || {}).filter((it) => it[0].endsWith("__added")).map(([key, value]) => {
|
23189
|
-
return [key.replace("__added", ""), value];
|
23190
|
-
})
|
23191
|
-
);
|
23192
|
-
const alterWith = Object.fromEntries(
|
23193
|
-
Object.entries(view2.with || {}).filter(
|
23194
|
-
(it) => typeof it[1].__old !== "undefined" && typeof it[1].__new !== "undefined"
|
23195
|
-
).map(
|
23196
|
-
(it) => {
|
23197
|
-
return [it[0], it[1].__new];
|
23198
|
-
}
|
23199
|
-
)
|
23200
|
-
);
|
23201
|
-
const alteredSchema = view2.schema;
|
23202
|
-
const alteredDefinition = view2.definition;
|
23203
|
-
const alteredExisting = view2.isExisting;
|
23204
|
-
const addedTablespace = view2.tablespace__added;
|
23205
|
-
const droppedTablespace = view2.tablespace__deleted;
|
23206
|
-
const alterTablespaceTo = view2.tablespace;
|
23207
|
-
let alteredTablespace;
|
23208
|
-
if (addedTablespace)
|
23209
|
-
alteredTablespace = { __new: addedTablespace, __old: "pg_default" };
|
23210
|
-
if (droppedTablespace)
|
23211
|
-
alteredTablespace = { __new: "pg_default", __old: droppedTablespace };
|
23212
|
-
if (alterTablespaceTo)
|
23213
|
-
alteredTablespace = alterTablespaceTo;
|
23214
|
-
const addedUsing = view2.using__added;
|
23215
|
-
const droppedUsing = view2.using__deleted;
|
23216
|
-
const alterUsingTo = view2.using;
|
23217
|
-
let alteredUsing;
|
23218
|
-
if (addedUsing)
|
23219
|
-
alteredUsing = { __new: addedUsing, __old: "heap" };
|
23220
|
-
if (droppedUsing)
|
23221
|
-
alteredUsing = { __new: "heap", __old: droppedUsing };
|
23222
|
-
if (alterUsingTo)
|
23223
|
-
alteredUsing = alterUsingTo;
|
23224
|
-
return {
|
23225
|
-
name: json2.views[nameWithSchema].name,
|
23226
|
-
schema: json2.views[nameWithSchema].schema,
|
23227
|
-
deletedWithOption,
|
23228
|
-
addedWithOption,
|
23229
|
-
alteredWith: {
|
23230
|
-
deletedWith: Object.keys(deletedWith).length ? deletedWith : void 0,
|
23231
|
-
addedWith: Object.keys(addedWith).length ? addedWith : void 0,
|
23232
|
-
alterWith: Object.keys(alterWith).length ? alterWith : void 0
|
23233
|
-
},
|
23234
|
-
alteredSchema,
|
23235
|
-
alteredDefinition,
|
23236
|
-
alteredExisting,
|
23237
|
-
alteredTablespace,
|
23238
|
-
alteredUsing
|
23239
|
-
};
|
23240
|
-
}
|
23241
|
-
);
|
23242
22629
|
const alteredTablesWithColumns = Object.values(difference.tables).map(
|
23243
22630
|
(table4) => {
|
23244
22631
|
return findAlternationsInTable(table4);
|
@@ -23247,8 +22634,7 @@ function applyJsonDiff(json1, json2) {
|
|
23247
22634
|
return {
|
23248
22635
|
alteredTablesWithColumns,
|
23249
22636
|
alteredEnums,
|
23250
|
-
alteredSequences
|
23251
|
-
alteredViews
|
22637
|
+
alteredSequences
|
23252
22638
|
};
|
23253
22639
|
}
|
23254
22640
|
var import_json_diff, mapArraysDiff, findAlternationsInTable, alternationsInColumn;
|
@@ -23643,7 +23029,7 @@ function fromJson(statements, dialect7, action, json2) {
|
|
23643
23029
|
}).filter((it) => it !== "");
|
23644
23030
|
return result;
|
23645
23031
|
}
|
23646
|
-
var pgNativeTypes, isPgNativeType, Convertor, PgCreateTableConvertor, MySqlCreateTableConvertor, SQLiteCreateTableConvertor,
|
23032
|
+
var pgNativeTypes, isPgNativeType, Convertor, PgCreateTableConvertor, MySqlCreateTableConvertor, SQLiteCreateTableConvertor, PgAlterTableAlterColumnSetGenerated, PgAlterTableAlterColumnDropGenerated, PgAlterTableAlterColumnAlterGenerated, PgAlterTableAddUniqueConstraintConvertor, PgAlterTableDropUniqueConstraintConvertor, MySQLAlterTableAddUniqueConstraintConvertor, MySQLAlterTableDropUniqueConstraintConvertor, CreatePgSequenceConvertor, DropPgSequenceConvertor, RenamePgSequenceConvertor, MovePgSequenceConvertor, AlterPgSequenceConvertor, CreateTypeEnumConvertor, AlterTypeAddValueConvertor, PgDropTableConvertor, MySQLDropTableConvertor, SQLiteDropTableConvertor, PgRenameTableConvertor, SqliteRenameTableConvertor, MySqlRenameTableConvertor, PgAlterTableRenameColumnConvertor, MySqlAlterTableRenameColumnConvertor, SQLiteAlterTableRenameColumnConvertor, PgAlterTableDropColumnConvertor, MySqlAlterTableDropColumnConvertor, SQLiteAlterTableDropColumnConvertor, PgAlterTableAddColumnConvertor, MySqlAlterTableAddColumnConvertor, SQLiteAlterTableAddColumnConvertor, PgAlterTableAlterColumnSetTypeConvertor, PgAlterTableAlterColumnSetDefaultConvertor, PgAlterTableAlterColumnDropDefaultConvertor, PgAlterTableAlterColumnDropGeneratedConvertor, PgAlterTableAlterColumnSetExpressionConvertor, PgAlterTableAlterColumnAlterrGeneratedConvertor, SqliteAlterTableAlterColumnDropGeneratedConvertor, SqliteAlterTableAlterColumnSetExpressionConvertor, SqliteAlterTableAlterColumnAlterGeneratedConvertor, MySqlAlterTableAlterColumnAlterrGeneratedConvertor, MySqlAlterTableAddPk, MySqlAlterTableDropPk, LibSQLModifyColumn, MySqlModifyColumn, PgAlterTableCreateCompositePrimaryKeyConvertor, PgAlterTableDeleteCompositePrimaryKeyConvertor, PgAlterTableAlterCompositePrimaryKeyConvertor, MySqlAlterTableCreateCompositePrimaryKeyConvertor, MySqlAlterTableDeleteCompositePrimaryKeyConvertor, MySqlAlterTableAlterCompositePrimaryKeyConvertor, PgAlterTableAlterColumnSetPrimaryKeyConvertor, PgAlterTableAlterColumnDropPrimaryKeyConvertor, PgAlterTableAlterColumnSetNotNullConvertor, PgAlterTableAlterColumnDropNotNullConvertor, PgCreateForeignKeyConvertor, LibSQLCreateForeignKeyConvertor, MySqlCreateForeignKeyConvertor, PgAlterForeignKeyConvertor, PgDeleteForeignKeyConvertor, MySqlDeleteForeignKeyConvertor, CreatePgIndexConvertor, CreateMySqlIndexConvertor, CreateSqliteIndexConvertor, PgDropIndexConvertor, PgCreateSchemaConvertor, PgRenameSchemaConvertor, PgDropSchemaConvertor, PgAlterTableSetSchemaConvertor, PgAlterTableSetNewSchemaConvertor, PgAlterTableRemoveFromSchemaConvertor, SqliteDropIndexConvertor, MySqlDropIndexConvertor, SQLiteRecreateTableConvertor, LibSQLRecreateTableConvertor, convertors;
|
23647
23033
|
var init_sqlgenerator = __esm({
|
23648
23034
|
"src/sqlgenerator.ts"() {
|
23649
23035
|
"use strict";
|
@@ -23859,118 +23245,6 @@ var init_sqlgenerator = __esm({
|
|
23859
23245
|
return statement;
|
23860
23246
|
}
|
23861
23247
|
};
|
23862
|
-
PgCreateViewConvertor = class extends Convertor {
|
23863
|
-
can(statement, dialect7) {
|
23864
|
-
return statement.type === "create_view" && dialect7 === "postgresql";
|
23865
|
-
}
|
23866
|
-
convert(st) {
|
23867
|
-
const { definition, name: viewName, schema: schema5, with: withOption, materialized, withNoData, tablespace, using } = st;
|
23868
|
-
const name = schema5 ? `"${schema5}"."${viewName}"` : `"${viewName}"`;
|
23869
|
-
let statement = materialized ? `CREATE MATERIALIZED VIEW ${name}` : `CREATE VIEW ${name}`;
|
23870
|
-
if (using)
|
23871
|
-
statement += ` USING "${using}"`;
|
23872
|
-
const options = [];
|
23873
|
-
if (withOption) {
|
23874
|
-
statement += ` WITH (`;
|
23875
|
-
Object.entries(withOption).forEach(([key, value]) => {
|
23876
|
-
if (typeof value === "undefined")
|
23877
|
-
return;
|
23878
|
-
options.push(`${key.snake_case()} = ${value}`);
|
23879
|
-
});
|
23880
|
-
statement += options.join(", ");
|
23881
|
-
statement += `)`;
|
23882
|
-
}
|
23883
|
-
if (tablespace)
|
23884
|
-
statement += ` TABLESPACE ${tablespace}`;
|
23885
|
-
statement += ` AS (${definition})`;
|
23886
|
-
if (withNoData)
|
23887
|
-
statement += ` WITH NO DATA`;
|
23888
|
-
statement += `;`;
|
23889
|
-
return statement;
|
23890
|
-
}
|
23891
|
-
};
|
23892
|
-
PgDropViewConvertor = class extends Convertor {
|
23893
|
-
can(statement, dialect7) {
|
23894
|
-
return statement.type === "drop_view" && dialect7 === "postgresql";
|
23895
|
-
}
|
23896
|
-
convert(st) {
|
23897
|
-
const { name: viewName, schema: schema5, materialized } = st;
|
23898
|
-
const name = schema5 ? `"${schema5}"."${viewName}"` : `"${viewName}"`;
|
23899
|
-
return `DROP${materialized ? " MATERIALIZED" : ""} VIEW ${name};`;
|
23900
|
-
}
|
23901
|
-
};
|
23902
|
-
PgRenameViewConvertor = class extends Convertor {
|
23903
|
-
can(statement, dialect7) {
|
23904
|
-
return statement.type === "rename_view" && dialect7 === "postgresql";
|
23905
|
-
}
|
23906
|
-
convert(st) {
|
23907
|
-
const { nameFrom: from, nameTo: to, schema: schema5, materialized } = st;
|
23908
|
-
const nameFrom = `"${schema5}"."${from}"`;
|
23909
|
-
return `ALTER${materialized ? " MATERIALIZED" : ""} VIEW ${nameFrom} RENAME TO "${to}";`;
|
23910
|
-
}
|
23911
|
-
};
|
23912
|
-
PgAlterViewSchemaConvertor = class extends Convertor {
|
23913
|
-
can(statement, dialect7) {
|
23914
|
-
return statement.type === "alter_view_alter_schema" && dialect7 === "postgresql";
|
23915
|
-
}
|
23916
|
-
convert(st) {
|
23917
|
-
const { fromSchema, toSchema, name, materialized } = st;
|
23918
|
-
const statement = `ALTER${materialized ? " MATERIALIZED" : ""} VIEW "${fromSchema}"."${name}" SET SCHEMA "${toSchema}";`;
|
23919
|
-
return statement;
|
23920
|
-
}
|
23921
|
-
};
|
23922
|
-
PgAlterViewAddWithOptionConvertor = class extends Convertor {
|
23923
|
-
can(statement, dialect7) {
|
23924
|
-
return statement.type === "alter_view_add_with_option" && dialect7 === "postgresql";
|
23925
|
-
}
|
23926
|
-
convert(st) {
|
23927
|
-
const { schema: schema5, with: withOption, name, materialized } = st;
|
23928
|
-
let statement = `ALTER${materialized ? " MATERIALIZED" : ""} VIEW "${schema5}"."${name}" SET (`;
|
23929
|
-
const options = [];
|
23930
|
-
Object.entries(withOption).forEach(([key, value]) => {
|
23931
|
-
options.push(`${key.snake_case()} = ${value}`);
|
23932
|
-
});
|
23933
|
-
statement += options.join(", ");
|
23934
|
-
statement += `);`;
|
23935
|
-
return statement;
|
23936
|
-
}
|
23937
|
-
};
|
23938
|
-
PgAlterViewDropWithOptionConvertor = class extends Convertor {
|
23939
|
-
can(statement, dialect7) {
|
23940
|
-
return statement.type === "alter_view_drop_with_option" && dialect7 === "postgresql";
|
23941
|
-
}
|
23942
|
-
convert(st) {
|
23943
|
-
const { schema: schema5, name, materialized, with: withOptions } = st;
|
23944
|
-
let statement = `ALTER${materialized ? " MATERIALIZED" : ""} VIEW "${schema5}"."${name}" RESET (`;
|
23945
|
-
const options = [];
|
23946
|
-
Object.entries(withOptions).forEach(([key, value]) => {
|
23947
|
-
options.push(`${key.snake_case()}`);
|
23948
|
-
});
|
23949
|
-
statement += options.join(", ");
|
23950
|
-
statement += ");";
|
23951
|
-
return statement;
|
23952
|
-
}
|
23953
|
-
};
|
23954
|
-
PgAlterViewAlterTablespaceConvertor = class extends Convertor {
|
23955
|
-
can(statement, dialect7) {
|
23956
|
-
return statement.type === "alter_view_alter_tablespace" && dialect7 === "postgresql";
|
23957
|
-
}
|
23958
|
-
convert(st) {
|
23959
|
-
const { schema: schema5, name, toTablespace } = st;
|
23960
|
-
const statement = `ALTER MATERIALIZED VIEW "${schema5}"."${name}" SET TABLESPACE ${toTablespace};`;
|
23961
|
-
return statement;
|
23962
|
-
}
|
23963
|
-
};
|
23964
|
-
PgAlterViewAlterUsingConvertor = class extends Convertor {
|
23965
|
-
can(statement, dialect7) {
|
23966
|
-
return statement.type === "alter_view_alter_using" && dialect7 === "postgresql";
|
23967
|
-
}
|
23968
|
-
convert(st) {
|
23969
|
-
const { schema: schema5, name, toUsing } = st;
|
23970
|
-
const statement = `ALTER MATERIALIZED VIEW "${schema5}"."${name}" SET ACCESS METHOD "${toUsing}";`;
|
23971
|
-
return statement;
|
23972
|
-
}
|
23973
|
-
};
|
23974
23248
|
PgAlterTableAlterColumnSetGenerated = class extends Convertor {
|
23975
23249
|
can(statement, dialect7) {
|
23976
23250
|
return statement.type === "alter_table_alter_column_set_identity" && dialect7 === "postgresql";
|
@@ -25309,14 +24583,6 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
25309
24583
|
convertors.push(new SQLiteCreateTableConvertor());
|
25310
24584
|
convertors.push(new SQLiteRecreateTableConvertor());
|
25311
24585
|
convertors.push(new LibSQLRecreateTableConvertor());
|
25312
|
-
convertors.push(new PgCreateViewConvertor());
|
25313
|
-
convertors.push(new PgDropViewConvertor());
|
25314
|
-
convertors.push(new PgRenameViewConvertor());
|
25315
|
-
convertors.push(new PgAlterViewSchemaConvertor());
|
25316
|
-
convertors.push(new PgAlterViewAddWithOptionConvertor());
|
25317
|
-
convertors.push(new PgAlterViewDropWithOptionConvertor());
|
25318
|
-
convertors.push(new PgAlterViewAlterTablespaceConvertor());
|
25319
|
-
convertors.push(new PgAlterViewAlterUsingConvertor());
|
25320
24586
|
convertors.push(new CreateTypeEnumConvertor());
|
25321
24587
|
convertors.push(new CreatePgSequenceConvertor());
|
25322
24588
|
convertors.push(new DropPgSequenceConvertor());
|
@@ -25651,7 +24917,7 @@ var init_sqlitePushUtils = __esm({
|
|
25651
24917
|
});
|
25652
24918
|
|
25653
24919
|
// src/jsonStatements.ts
|
25654
|
-
var preparePgCreateTableJson, prepareMySqlCreateTableJson, prepareSQLiteCreateTable, prepareDropTableJson, prepareRenameTableJson, prepareCreateEnumJson, prepareAddValuesToEnumJson, prepareDropEnumJson, prepareMoveEnumJson, prepareRenameEnumJson, prepareCreateSequenceJson, prepareAlterSequenceJson, prepareDropSequenceJson, prepareMoveSequenceJson, prepareRenameSequenceJson, prepareCreateSchemasJson, prepareRenameSchemasJson, prepareDeleteSchemasJson, prepareRenameColumns, _prepareDropColumns, _prepareAddColumns, _prepareSqliteAddColumns, prepareAlterColumnsMysql, preparePgAlterColumns, prepareSqliteAlterColumns, preparePgCreateIndexesJson, prepareCreateIndexesJson, prepareCreateReferencesJson, prepareLibSQLCreateReferencesJson, prepareDropReferencesJson, prepareLibSQLDropReferencesJson, prepareAlterReferencesJson, prepareDropIndexesJson, prepareAddCompositePrimaryKeySqlite, prepareDeleteCompositePrimaryKeySqlite, prepareAlterCompositePrimaryKeySqlite, prepareAddCompositePrimaryKeyPg, prepareDeleteCompositePrimaryKeyPg, prepareAlterCompositePrimaryKeyPg, prepareAddUniqueConstraintPg, prepareDeleteUniqueConstraintPg, prepareAddCompositePrimaryKeyMySql, prepareDeleteCompositePrimaryKeyMySql, prepareAlterCompositePrimaryKeyMySql
|
24920
|
+
var preparePgCreateTableJson, prepareMySqlCreateTableJson, prepareSQLiteCreateTable, prepareDropTableJson, prepareRenameTableJson, prepareCreateEnumJson, prepareAddValuesToEnumJson, prepareDropEnumJson, prepareMoveEnumJson, prepareRenameEnumJson, prepareCreateSequenceJson, prepareAlterSequenceJson, prepareDropSequenceJson, prepareMoveSequenceJson, prepareRenameSequenceJson, prepareCreateSchemasJson, prepareRenameSchemasJson, prepareDeleteSchemasJson, prepareRenameColumns, _prepareDropColumns, _prepareAddColumns, _prepareSqliteAddColumns, prepareAlterColumnsMysql, preparePgAlterColumns, prepareSqliteAlterColumns, preparePgCreateIndexesJson, prepareCreateIndexesJson, prepareCreateReferencesJson, prepareLibSQLCreateReferencesJson, prepareDropReferencesJson, prepareLibSQLDropReferencesJson, prepareAlterReferencesJson, prepareDropIndexesJson, prepareAddCompositePrimaryKeySqlite, prepareDeleteCompositePrimaryKeySqlite, prepareAlterCompositePrimaryKeySqlite, prepareAddCompositePrimaryKeyPg, prepareDeleteCompositePrimaryKeyPg, prepareAlterCompositePrimaryKeyPg, prepareAddUniqueConstraintPg, prepareDeleteUniqueConstraintPg, prepareAddCompositePrimaryKeyMySql, prepareDeleteCompositePrimaryKeyMySql, prepareAlterCompositePrimaryKeyMySql;
|
25655
24921
|
var init_jsonStatements = __esm({
|
25656
24922
|
"src/jsonStatements.ts"() {
|
25657
24923
|
"use strict";
|
@@ -26990,81 +26256,6 @@ var init_jsonStatements = __esm({
|
|
26990
26256
|
};
|
26991
26257
|
});
|
26992
26258
|
};
|
26993
|
-
preparePgCreateViewJson = (name, schema5, definition, materialized, withNoData = false, withOption, using, tablespace) => {
|
26994
|
-
return {
|
26995
|
-
type: "create_view",
|
26996
|
-
name,
|
26997
|
-
schema: schema5,
|
26998
|
-
definition,
|
26999
|
-
with: withOption,
|
27000
|
-
materialized,
|
27001
|
-
withNoData,
|
27002
|
-
using,
|
27003
|
-
tablespace
|
27004
|
-
};
|
27005
|
-
};
|
27006
|
-
preparePgDropViewJson = (name, schema5, materialized) => {
|
27007
|
-
return {
|
27008
|
-
type: "drop_view",
|
27009
|
-
name,
|
27010
|
-
schema: schema5,
|
27011
|
-
materialized
|
27012
|
-
};
|
27013
|
-
};
|
27014
|
-
preparePgRenameViewJson = (to, from, schema5, materialized) => {
|
27015
|
-
return {
|
27016
|
-
type: "rename_view",
|
27017
|
-
nameTo: to,
|
27018
|
-
nameFrom: from,
|
27019
|
-
schema: schema5,
|
27020
|
-
materialized
|
27021
|
-
};
|
27022
|
-
};
|
27023
|
-
preparePgAlterViewAlterSchemaJson = (to, from, name, materialized) => {
|
27024
|
-
return {
|
27025
|
-
type: "alter_view_alter_schema",
|
27026
|
-
fromSchema: from,
|
27027
|
-
toSchema: to,
|
27028
|
-
name,
|
27029
|
-
materialized
|
27030
|
-
};
|
27031
|
-
};
|
27032
|
-
preparePgAlterViewAddWithOptionJson = (name, schema5, materialized, withOption) => {
|
27033
|
-
return {
|
27034
|
-
type: "alter_view_add_with_option",
|
27035
|
-
name,
|
27036
|
-
schema: schema5,
|
27037
|
-
materialized,
|
27038
|
-
with: withOption
|
27039
|
-
};
|
27040
|
-
};
|
27041
|
-
preparePgAlterViewDropWithOptionJson = (name, schema5, materialized, withOption) => {
|
27042
|
-
return {
|
27043
|
-
type: "alter_view_drop_with_option",
|
27044
|
-
name,
|
27045
|
-
schema: schema5,
|
27046
|
-
materialized,
|
27047
|
-
with: withOption
|
27048
|
-
};
|
27049
|
-
};
|
27050
|
-
preparePgAlterViewAlterTablespaceJson = (name, schema5, materialized, to) => {
|
27051
|
-
return {
|
27052
|
-
type: "alter_view_alter_tablespace",
|
27053
|
-
name,
|
27054
|
-
schema: schema5,
|
27055
|
-
materialized,
|
27056
|
-
toTablespace: to
|
27057
|
-
};
|
27058
|
-
};
|
27059
|
-
preparePgAlterViewAlterUsingJson = (name, schema5, materialized, to) => {
|
27060
|
-
return {
|
27061
|
-
type: "alter_view_alter_using",
|
27062
|
-
name,
|
27063
|
-
schema: schema5,
|
27064
|
-
materialized,
|
27065
|
-
toUsing: to
|
27066
|
-
};
|
27067
|
-
};
|
27068
26259
|
}
|
27069
26260
|
});
|
27070
26261
|
|
@@ -27350,7 +26541,7 @@ var init_statementCombiner = __esm({
|
|
27350
26541
|
});
|
27351
26542
|
|
27352
26543
|
// src/snapshotsDiffer.ts
|
27353
|
-
var makeChanged, makeSelfOrChanged, makePatched, columnSchema, alteredColumnSchema, enumSchema2, changedEnumSchema, tableScheme, alteredTableScheme,
|
26544
|
+
var makeChanged, makeSelfOrChanged, makePatched, columnSchema, alteredColumnSchema, enumSchema2, changedEnumSchema, tableScheme, alteredTableScheme, diffResultScheme, diffResultSchemeMysql, diffResultSchemeSQLite, schemaChangeFor, nameChangeFor, nameSchemaChangeFor, columnChangeFor, applyPgSnapshotsDiff, applyMysqlSnapshotsDiff, applySqliteSnapshotsDiff, applyLibSQLSnapshotsDiff;
|
27354
26545
|
var init_snapshotsDiffer = __esm({
|
27355
26546
|
"src/snapshotsDiffer.ts"() {
|
27356
26547
|
"use strict";
|
@@ -27498,42 +26689,10 @@ var init_snapshotsDiffer = __esm({
|
|
27498
26689
|
})
|
27499
26690
|
)
|
27500
26691
|
}).strict();
|
27501
|
-
alteredViewSchema = objectType({
|
27502
|
-
name: stringType(),
|
27503
|
-
schema: stringType(),
|
27504
|
-
deletedWithOption: mergedViewWithOption.optional(),
|
27505
|
-
addedWithOption: mergedViewWithOption.optional(),
|
27506
|
-
alteredWith: objectType({
|
27507
|
-
addedWith: mergedViewWithOption.optional(),
|
27508
|
-
deletedWith: mergedViewWithOption.optional(),
|
27509
|
-
alterWith: mergedViewWithOption.optional()
|
27510
|
-
}).strict(),
|
27511
|
-
alteredSchema: objectType({
|
27512
|
-
__old: stringType(),
|
27513
|
-
__new: stringType()
|
27514
|
-
}).strict().optional(),
|
27515
|
-
alteredDefinition: objectType({
|
27516
|
-
__old: stringType(),
|
27517
|
-
__new: stringType()
|
27518
|
-
}).strict().optional(),
|
27519
|
-
alteredExisting: objectType({
|
27520
|
-
__old: booleanType(),
|
27521
|
-
__new: booleanType()
|
27522
|
-
}).strict().optional(),
|
27523
|
-
alteredTablespace: objectType({
|
27524
|
-
__old: stringType(),
|
27525
|
-
__new: stringType()
|
27526
|
-
}).strict().optional(),
|
27527
|
-
alteredUsing: objectType({
|
27528
|
-
__old: stringType(),
|
27529
|
-
__new: stringType()
|
27530
|
-
}).strict().optional()
|
27531
|
-
}).strict();
|
27532
26692
|
diffResultScheme = objectType({
|
27533
26693
|
alteredTablesWithColumns: alteredTableScheme.array(),
|
27534
26694
|
alteredEnums: changedEnumSchema.array(),
|
27535
|
-
alteredSequences: sequenceSquashed.array()
|
27536
|
-
alteredViews: alteredViewSchema.array()
|
26695
|
+
alteredSequences: sequenceSquashed.array()
|
27537
26696
|
}).strict();
|
27538
26697
|
diffResultSchemeMysql = objectType({
|
27539
26698
|
alteredTablesWithColumns: alteredTableScheme.array(),
|
@@ -27588,7 +26747,7 @@ var init_snapshotsDiffer = __esm({
|
|
27588
26747
|
}
|
27589
26748
|
return column7;
|
27590
26749
|
};
|
27591
|
-
applyPgSnapshotsDiff = async (json1, json2, schemasResolver2, enumsResolver2, sequencesResolver2, tablesResolver2, columnsResolver2,
|
26750
|
+
applyPgSnapshotsDiff = async (json1, json2, schemasResolver2, enumsResolver2, sequencesResolver2, tablesResolver2, columnsResolver2, prevFull, curFull, action) => {
|
27592
26751
|
const schemasDiff = diffSchemasOrTables(json1.schemas, json2.schemas);
|
27593
26752
|
const {
|
27594
26753
|
created: createdSchemas,
|
@@ -27816,40 +26975,7 @@ var init_snapshotsDiffer = __esm({
|
|
27816
26975
|
return [tableKey2, tableValue];
|
27817
26976
|
}
|
27818
26977
|
);
|
27819
|
-
const
|
27820
|
-
const {
|
27821
|
-
created: createdViews,
|
27822
|
-
deleted: deletedViews,
|
27823
|
-
renamed: renamedViews,
|
27824
|
-
moved: movedViews
|
27825
|
-
} = await viewsResolver2({
|
27826
|
-
created: viewsDiff.added,
|
27827
|
-
deleted: viewsDiff.deleted
|
27828
|
-
});
|
27829
|
-
const renamesViewDic = {};
|
27830
|
-
renamedViews.forEach((it) => {
|
27831
|
-
renamesViewDic[`${it.from.schema}.${it.from.name}`] = { to: it.to.name, from: it.from.name };
|
27832
|
-
});
|
27833
|
-
const movedViewDic = {};
|
27834
|
-
movedViews.forEach((it) => {
|
27835
|
-
movedViewDic[`${it.schemaFrom}.${it.name}`] = { to: it.schemaTo, from: it.schemaFrom };
|
27836
|
-
});
|
27837
|
-
const viewsPatchedSnap1 = copy(columnsPatchedSnap1);
|
27838
|
-
viewsPatchedSnap1.views = mapEntries(
|
27839
|
-
viewsPatchedSnap1.views,
|
27840
|
-
(viewKey, viewValue) => {
|
27841
|
-
const rename = renamesViewDic[`${viewValue.schema}.${viewValue.name}`];
|
27842
|
-
const moved = movedViewDic[`${viewValue.schema}.${viewValue.name}`];
|
27843
|
-
if (rename) {
|
27844
|
-
viewValue.name = rename.to;
|
27845
|
-
viewKey = `${viewValue.schema}.${viewValue.name}`;
|
27846
|
-
}
|
27847
|
-
if (moved)
|
27848
|
-
viewKey = `${moved.to}.${viewValue.name}`;
|
27849
|
-
return [viewKey, viewValue];
|
27850
|
-
}
|
27851
|
-
);
|
27852
|
-
const diffResult = applyJsonDiff(viewsPatchedSnap1, json2);
|
26978
|
+
const diffResult = applyJsonDiff(columnsPatchedSnap1, json2);
|
27853
26979
|
const typedResult = diffResultScheme.parse(diffResult);
|
27854
26980
|
const jsonStatements = [];
|
27855
26981
|
const jsonCreateIndexesForCreatedTables = createdTables.map((it) => {
|
@@ -28101,137 +27227,6 @@ var init_snapshotsDiffer = __esm({
|
|
28101
27227
|
const createTables = createdTables.map((it) => {
|
28102
27228
|
return preparePgCreateTableJson(it, curFull);
|
28103
27229
|
});
|
28104
|
-
const createViews = [];
|
28105
|
-
const dropViews = [];
|
28106
|
-
const renameViews = [];
|
28107
|
-
const alterViews = [];
|
28108
|
-
createViews.push(
|
28109
|
-
...createdViews.filter((it) => !it.isExisting).map((it) => {
|
28110
|
-
return preparePgCreateViewJson(
|
28111
|
-
it.name,
|
28112
|
-
it.schema,
|
28113
|
-
it.definition,
|
28114
|
-
it.materialized,
|
28115
|
-
it.withNoData,
|
28116
|
-
it.with,
|
28117
|
-
it.using,
|
28118
|
-
it.tablespace
|
28119
|
-
);
|
28120
|
-
})
|
28121
|
-
);
|
28122
|
-
dropViews.push(
|
28123
|
-
...deletedViews.filter((it) => !it.isExisting).map((it) => {
|
28124
|
-
return preparePgDropViewJson(it.name, it.schema, it.materialized);
|
28125
|
-
})
|
28126
|
-
);
|
28127
|
-
renameViews.push(
|
28128
|
-
...renamedViews.filter((it) => !it.to.isExisting).map((it) => {
|
28129
|
-
return preparePgRenameViewJson(it.to.name, it.from.name, it.to.schema, it.to.materialized);
|
28130
|
-
})
|
28131
|
-
);
|
28132
|
-
alterViews.push(
|
28133
|
-
...movedViews.filter((it) => !json2.views[`${it.schemaTo}.${it.name}`].isExisting).map((it) => {
|
28134
|
-
return preparePgAlterViewAlterSchemaJson(
|
28135
|
-
it.schemaTo,
|
28136
|
-
it.schemaFrom,
|
28137
|
-
it.name,
|
28138
|
-
json2.views[`${it.schemaTo}.${it.name}`].materialized
|
28139
|
-
);
|
28140
|
-
})
|
28141
|
-
);
|
28142
|
-
const alteredViews = typedResult.alteredViews.filter((it) => !json2.views[`${it.schema}.${it.name}`].isExisting);
|
28143
|
-
for (const alteredView of alteredViews) {
|
28144
|
-
const viewKey = `${alteredView.schema}.${alteredView.name}`;
|
28145
|
-
const { materialized, with: withOption, definition, withNoData, using, tablespace } = json2.views[viewKey];
|
28146
|
-
if (alteredView.alteredExisting || alteredView.alteredDefinition && action !== "push") {
|
28147
|
-
dropViews.push(preparePgDropViewJson(alteredView.name, alteredView.schema, materialized));
|
28148
|
-
createViews.push(
|
28149
|
-
preparePgCreateViewJson(
|
28150
|
-
alteredView.name,
|
28151
|
-
alteredView.schema,
|
28152
|
-
definition,
|
28153
|
-
materialized,
|
28154
|
-
withNoData,
|
28155
|
-
withOption,
|
28156
|
-
using,
|
28157
|
-
tablespace
|
28158
|
-
)
|
28159
|
-
);
|
28160
|
-
continue;
|
28161
|
-
}
|
28162
|
-
if (alteredView.addedWithOption) {
|
28163
|
-
alterViews.push(
|
28164
|
-
preparePgAlterViewAddWithOptionJson(
|
28165
|
-
alteredView.name,
|
28166
|
-
alteredView.schema,
|
28167
|
-
materialized,
|
28168
|
-
alteredView.addedWithOption
|
28169
|
-
)
|
28170
|
-
);
|
28171
|
-
}
|
28172
|
-
if (alteredView.deletedWithOption) {
|
28173
|
-
alterViews.push(
|
28174
|
-
preparePgAlterViewDropWithOptionJson(
|
28175
|
-
alteredView.name,
|
28176
|
-
alteredView.schema,
|
28177
|
-
materialized,
|
28178
|
-
alteredView.deletedWithOption
|
28179
|
-
)
|
28180
|
-
);
|
28181
|
-
}
|
28182
|
-
if (alteredView.alteredWith) {
|
28183
|
-
if (alteredView.alteredWith.addedWith) {
|
28184
|
-
alterViews.push(
|
28185
|
-
preparePgAlterViewAddWithOptionJson(
|
28186
|
-
alteredView.name,
|
28187
|
-
alteredView.schema,
|
28188
|
-
materialized,
|
28189
|
-
alteredView.alteredWith.addedWith
|
28190
|
-
)
|
28191
|
-
);
|
28192
|
-
}
|
28193
|
-
if (alteredView.alteredWith.deletedWith) {
|
28194
|
-
alterViews.push(
|
28195
|
-
preparePgAlterViewDropWithOptionJson(
|
28196
|
-
alteredView.name,
|
28197
|
-
alteredView.schema,
|
28198
|
-
materialized,
|
28199
|
-
alteredView.alteredWith.deletedWith
|
28200
|
-
)
|
28201
|
-
);
|
28202
|
-
}
|
28203
|
-
if (alteredView.alteredWith.alterWith) {
|
28204
|
-
alterViews.push(
|
28205
|
-
preparePgAlterViewAddWithOptionJson(
|
28206
|
-
alteredView.name,
|
28207
|
-
alteredView.schema,
|
28208
|
-
materialized,
|
28209
|
-
alteredView.alteredWith.alterWith
|
28210
|
-
)
|
28211
|
-
);
|
28212
|
-
}
|
28213
|
-
}
|
28214
|
-
if (alteredView.alteredTablespace) {
|
28215
|
-
alterViews.push(
|
28216
|
-
preparePgAlterViewAlterTablespaceJson(
|
28217
|
-
alteredView.name,
|
28218
|
-
alteredView.schema,
|
28219
|
-
materialized,
|
28220
|
-
alteredView.alteredTablespace.__new
|
28221
|
-
)
|
28222
|
-
);
|
28223
|
-
}
|
28224
|
-
if (alteredView.alteredUsing) {
|
28225
|
-
alterViews.push(
|
28226
|
-
preparePgAlterViewAlterUsingJson(
|
28227
|
-
alteredView.name,
|
28228
|
-
alteredView.schema,
|
28229
|
-
materialized,
|
28230
|
-
alteredView.alteredUsing.__new
|
28231
|
-
)
|
28232
|
-
);
|
28233
|
-
}
|
28234
|
-
}
|
28235
27230
|
jsonStatements.push(...createSchemas);
|
28236
27231
|
jsonStatements.push(...renameSchemas);
|
28237
27232
|
jsonStatements.push(...createEnums);
|
@@ -28243,9 +27238,6 @@ var init_snapshotsDiffer = __esm({
|
|
28243
27238
|
jsonStatements.push(...renameSequences);
|
28244
27239
|
jsonStatements.push(...jsonAlterSequences);
|
28245
27240
|
jsonStatements.push(...createTables);
|
28246
|
-
jsonStatements.push(...dropViews);
|
28247
|
-
jsonStatements.push(...renameViews);
|
28248
|
-
jsonStatements.push(...alterViews);
|
28249
27241
|
jsonStatements.push(...jsonDropTables);
|
28250
27242
|
jsonStatements.push(...jsonSetTableSchemas);
|
28251
27243
|
jsonStatements.push(...jsonRenameTables);
|
@@ -28265,7 +27257,6 @@ var init_snapshotsDiffer = __esm({
|
|
28265
27257
|
jsonStatements.push(...jsonAlteredCompositePKs);
|
28266
27258
|
jsonStatements.push(...jsonAddedUniqueConstraints);
|
28267
27259
|
jsonStatements.push(...jsonAlteredUniqueConstraints);
|
28268
|
-
jsonStatements.push(...createViews);
|
28269
27260
|
jsonStatements.push(...dropEnums);
|
28270
27261
|
jsonStatements.push(...dropSequences);
|
28271
27262
|
jsonStatements.push(...dropSchemas);
|
@@ -30544,10 +29535,9 @@ __export(migrate_exports, {
|
|
30544
29535
|
schemasResolver: () => schemasResolver,
|
30545
29536
|
sequencesResolver: () => sequencesResolver,
|
30546
29537
|
tablesResolver: () => tablesResolver,
|
30547
|
-
viewsResolver: () => viewsResolver,
|
30548
29538
|
writeResult: () => writeResult
|
30549
29539
|
});
|
30550
|
-
var import_fs5, import_hanji3, import_path4, schemasResolver, tablesResolver,
|
29540
|
+
var import_fs5, import_hanji3, import_path4, schemasResolver, tablesResolver, sequencesResolver, enumsResolver, columnsResolver, prepareAndMigratePg, preparePgPush, prepareMySQLPush, prepareAndMigrateMysql, prepareAndMigrateSqlite, prepareAndMigrateLibSQL, prepareSQLitePush, prepareLibSQLPush, promptColumnsConflicts, promptNamedWithSchemasConflict, promptSchemasConflict, BREAKPOINT, writeResult, embeddedMigrations, prepareSnapshotFolderName, two;
|
30551
29541
|
var init_migrate = __esm({
|
30552
29542
|
"src/cli/commands/migrate.ts"() {
|
30553
29543
|
"use strict";
|
@@ -30594,24 +29584,6 @@ var init_migrate = __esm({
|
|
30594
29584
|
throw e2;
|
30595
29585
|
}
|
30596
29586
|
};
|
30597
|
-
viewsResolver = async (input) => {
|
30598
|
-
try {
|
30599
|
-
const { created, deleted, moved, renamed } = await promptNamedWithSchemasConflict(
|
30600
|
-
input.created,
|
30601
|
-
input.deleted,
|
30602
|
-
"view"
|
30603
|
-
);
|
30604
|
-
return {
|
30605
|
-
created,
|
30606
|
-
deleted,
|
30607
|
-
moved,
|
30608
|
-
renamed
|
30609
|
-
};
|
30610
|
-
} catch (e2) {
|
30611
|
-
console.error(e2);
|
30612
|
-
throw e2;
|
30613
|
-
}
|
30614
|
-
};
|
30615
29587
|
sequencesResolver = async (input) => {
|
30616
29588
|
try {
|
30617
29589
|
const { created, deleted, moved, renamed } = await promptNamedWithSchemasConflict(
|
@@ -30700,7 +29672,6 @@ var init_migrate = __esm({
|
|
30700
29672
|
sequencesResolver,
|
30701
29673
|
tablesResolver,
|
30702
29674
|
columnsResolver,
|
30703
|
-
viewsResolver,
|
30704
29675
|
validatedPrev,
|
30705
29676
|
validatedCur
|
30706
29677
|
);
|
@@ -30735,7 +29706,6 @@ var init_migrate = __esm({
|
|
30735
29706
|
sequencesResolver,
|
30736
29707
|
tablesResolver,
|
30737
29708
|
columnsResolver,
|
30738
|
-
viewsResolver,
|
30739
29709
|
validatedPrev,
|
30740
29710
|
validatedCur,
|
30741
29711
|
"push"
|
@@ -35557,20 +34527,20 @@ var require_ponyfill_es2018 = __commonJS({
|
|
35557
34527
|
;
|
35558
34528
|
ReadableByteStreamControllerRespond(this._associatedReadableByteStreamController, bytesWritten);
|
35559
34529
|
}
|
35560
|
-
respondWithNewView(
|
34530
|
+
respondWithNewView(view) {
|
35561
34531
|
if (!IsReadableStreamBYOBRequest(this)) {
|
35562
34532
|
throw byobRequestBrandCheckException("respondWithNewView");
|
35563
34533
|
}
|
35564
|
-
assertRequiredArgument(
|
35565
|
-
if (!ArrayBuffer.isView(
|
34534
|
+
assertRequiredArgument(view, 1, "respondWithNewView");
|
34535
|
+
if (!ArrayBuffer.isView(view)) {
|
35566
34536
|
throw new TypeError("You can only respond with array buffer views");
|
35567
34537
|
}
|
35568
34538
|
if (this._associatedReadableByteStreamController === void 0) {
|
35569
34539
|
throw new TypeError("This BYOB request has been invalidated");
|
35570
34540
|
}
|
35571
|
-
if (IsDetachedBuffer(
|
34541
|
+
if (IsDetachedBuffer(view.buffer))
|
35572
34542
|
;
|
35573
|
-
ReadableByteStreamControllerRespondWithNewView(this._associatedReadableByteStreamController,
|
34543
|
+
ReadableByteStreamControllerRespondWithNewView(this._associatedReadableByteStreamController, view);
|
35574
34544
|
}
|
35575
34545
|
}
|
35576
34546
|
Object.defineProperties(ReadableStreamBYOBRequest.prototype, {
|
@@ -35671,8 +34641,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
35671
34641
|
const entry = this._queue.shift();
|
35672
34642
|
this._queueTotalSize -= entry.byteLength;
|
35673
34643
|
ReadableByteStreamControllerHandleQueueDrain(this);
|
35674
|
-
const
|
35675
|
-
readRequest._chunkSteps(
|
34644
|
+
const view = new Uint8Array(entry.buffer, entry.byteOffset, entry.byteLength);
|
34645
|
+
readRequest._chunkSteps(view);
|
35676
34646
|
return;
|
35677
34647
|
}
|
35678
34648
|
const autoAllocateChunkSize = this._autoAllocateChunkSize;
|
@@ -35838,19 +34808,19 @@ var require_ponyfill_es2018 = __commonJS({
|
|
35838
34808
|
}
|
35839
34809
|
}
|
35840
34810
|
}
|
35841
|
-
function ReadableByteStreamControllerPullInto(controller,
|
34811
|
+
function ReadableByteStreamControllerPullInto(controller, view, readIntoRequest) {
|
35842
34812
|
const stream = controller._controlledReadableByteStream;
|
35843
34813
|
let elementSize = 1;
|
35844
|
-
if (
|
35845
|
-
elementSize =
|
34814
|
+
if (view.constructor !== DataView) {
|
34815
|
+
elementSize = view.constructor.BYTES_PER_ELEMENT;
|
35846
34816
|
}
|
35847
|
-
const ctor =
|
35848
|
-
const buffer = TransferArrayBuffer(
|
34817
|
+
const ctor = view.constructor;
|
34818
|
+
const buffer = TransferArrayBuffer(view.buffer);
|
35849
34819
|
const pullIntoDescriptor = {
|
35850
34820
|
buffer,
|
35851
34821
|
bufferByteLength: buffer.byteLength,
|
35852
|
-
byteOffset:
|
35853
|
-
byteLength:
|
34822
|
+
byteOffset: view.byteOffset,
|
34823
|
+
byteLength: view.byteLength,
|
35854
34824
|
bytesFilled: 0,
|
35855
34825
|
elementSize,
|
35856
34826
|
viewConstructor: ctor,
|
@@ -36018,9 +34988,9 @@ var require_ponyfill_es2018 = __commonJS({
|
|
36018
34988
|
function ReadableByteStreamControllerGetBYOBRequest(controller) {
|
36019
34989
|
if (controller._byobRequest === null && controller._pendingPullIntos.length > 0) {
|
36020
34990
|
const firstDescriptor = controller._pendingPullIntos.peek();
|
36021
|
-
const
|
34991
|
+
const view = new Uint8Array(firstDescriptor.buffer, firstDescriptor.byteOffset + firstDescriptor.bytesFilled, firstDescriptor.byteLength - firstDescriptor.bytesFilled);
|
36022
34992
|
const byobRequest = Object.create(ReadableStreamBYOBRequest.prototype);
|
36023
|
-
SetUpReadableStreamBYOBRequest(byobRequest, controller,
|
34993
|
+
SetUpReadableStreamBYOBRequest(byobRequest, controller, view);
|
36024
34994
|
controller._byobRequest = byobRequest;
|
36025
34995
|
}
|
36026
34996
|
return controller._byobRequest;
|
@@ -36053,29 +35023,29 @@ var require_ponyfill_es2018 = __commonJS({
|
|
36053
35023
|
firstDescriptor.buffer = TransferArrayBuffer(firstDescriptor.buffer);
|
36054
35024
|
ReadableByteStreamControllerRespondInternal(controller, bytesWritten);
|
36055
35025
|
}
|
36056
|
-
function ReadableByteStreamControllerRespondWithNewView(controller,
|
35026
|
+
function ReadableByteStreamControllerRespondWithNewView(controller, view) {
|
36057
35027
|
const firstDescriptor = controller._pendingPullIntos.peek();
|
36058
35028
|
const state = controller._controlledReadableByteStream._state;
|
36059
35029
|
if (state === "closed") {
|
36060
|
-
if (
|
35030
|
+
if (view.byteLength !== 0) {
|
36061
35031
|
throw new TypeError("The view's length must be 0 when calling respondWithNewView() on a closed stream");
|
36062
35032
|
}
|
36063
35033
|
} else {
|
36064
|
-
if (
|
35034
|
+
if (view.byteLength === 0) {
|
36065
35035
|
throw new TypeError("The view's length must be greater than 0 when calling respondWithNewView() on a readable stream");
|
36066
35036
|
}
|
36067
35037
|
}
|
36068
|
-
if (firstDescriptor.byteOffset + firstDescriptor.bytesFilled !==
|
35038
|
+
if (firstDescriptor.byteOffset + firstDescriptor.bytesFilled !== view.byteOffset) {
|
36069
35039
|
throw new RangeError("The region specified by view does not match byobRequest");
|
36070
35040
|
}
|
36071
|
-
if (firstDescriptor.bufferByteLength !==
|
35041
|
+
if (firstDescriptor.bufferByteLength !== view.buffer.byteLength) {
|
36072
35042
|
throw new RangeError("The buffer of view has different capacity than byobRequest");
|
36073
35043
|
}
|
36074
|
-
if (firstDescriptor.bytesFilled +
|
35044
|
+
if (firstDescriptor.bytesFilled + view.byteLength > firstDescriptor.byteLength) {
|
36075
35045
|
throw new RangeError("The region specified by view is larger than byobRequest");
|
36076
35046
|
}
|
36077
|
-
const viewByteLength =
|
36078
|
-
firstDescriptor.buffer = TransferArrayBuffer(
|
35047
|
+
const viewByteLength = view.byteLength;
|
35048
|
+
firstDescriptor.buffer = TransferArrayBuffer(view.buffer);
|
36079
35049
|
ReadableByteStreamControllerRespondInternal(controller, viewByteLength);
|
36080
35050
|
}
|
36081
35051
|
function SetUpReadableByteStreamController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, autoAllocateChunkSize) {
|
@@ -36121,9 +35091,9 @@ var require_ponyfill_es2018 = __commonJS({
|
|
36121
35091
|
}
|
36122
35092
|
SetUpReadableByteStreamController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, autoAllocateChunkSize);
|
36123
35093
|
}
|
36124
|
-
function SetUpReadableStreamBYOBRequest(request, controller,
|
35094
|
+
function SetUpReadableStreamBYOBRequest(request, controller, view) {
|
36125
35095
|
request._associatedReadableByteStreamController = controller;
|
36126
|
-
request._view =
|
35096
|
+
request._view = view;
|
36127
35097
|
}
|
36128
35098
|
function byobRequestBrandCheckException(name) {
|
36129
35099
|
return new TypeError(`ReadableStreamBYOBRequest.prototype.${name} can only be used on a ReadableStreamBYOBRequest`);
|
@@ -36199,20 +35169,20 @@ var require_ponyfill_es2018 = __commonJS({
|
|
36199
35169
|
*
|
36200
35170
|
* If reading a chunk causes the queue to become empty, more data will be pulled from the underlying source.
|
36201
35171
|
*/
|
36202
|
-
read(
|
35172
|
+
read(view) {
|
36203
35173
|
if (!IsReadableStreamBYOBReader(this)) {
|
36204
35174
|
return promiseRejectedWith(byobReaderBrandCheckException("read"));
|
36205
35175
|
}
|
36206
|
-
if (!ArrayBuffer.isView(
|
35176
|
+
if (!ArrayBuffer.isView(view)) {
|
36207
35177
|
return promiseRejectedWith(new TypeError("view must be an array buffer view"));
|
36208
35178
|
}
|
36209
|
-
if (
|
35179
|
+
if (view.byteLength === 0) {
|
36210
35180
|
return promiseRejectedWith(new TypeError("view must have non-zero byteLength"));
|
36211
35181
|
}
|
36212
|
-
if (
|
35182
|
+
if (view.buffer.byteLength === 0) {
|
36213
35183
|
return promiseRejectedWith(new TypeError(`view's buffer must have non-zero byteLength`));
|
36214
35184
|
}
|
36215
|
-
if (IsDetachedBuffer(
|
35185
|
+
if (IsDetachedBuffer(view.buffer))
|
36216
35186
|
;
|
36217
35187
|
if (this._ownerReadableStream === void 0) {
|
36218
35188
|
return promiseRejectedWith(readerLockException("read from"));
|
@@ -36228,7 +35198,7 @@ var require_ponyfill_es2018 = __commonJS({
|
|
36228
35198
|
_closeSteps: (chunk) => resolvePromise({ value: chunk, done: true }),
|
36229
35199
|
_errorSteps: (e2) => rejectPromise(e2)
|
36230
35200
|
};
|
36231
|
-
ReadableStreamBYOBReaderRead(this,
|
35201
|
+
ReadableStreamBYOBReaderRead(this, view, readIntoRequest);
|
36232
35202
|
return promise;
|
36233
35203
|
}
|
36234
35204
|
/**
|
@@ -36274,13 +35244,13 @@ var require_ponyfill_es2018 = __commonJS({
|
|
36274
35244
|
}
|
36275
35245
|
return x2 instanceof ReadableStreamBYOBReader;
|
36276
35246
|
}
|
36277
|
-
function ReadableStreamBYOBReaderRead(reader,
|
35247
|
+
function ReadableStreamBYOBReaderRead(reader, view, readIntoRequest) {
|
36278
35248
|
const stream = reader._ownerReadableStream;
|
36279
35249
|
stream._disturbed = true;
|
36280
35250
|
if (stream._state === "errored") {
|
36281
35251
|
readIntoRequest._errorSteps(stream._storedError);
|
36282
35252
|
} else {
|
36283
|
-
ReadableByteStreamControllerPullInto(stream._readableStreamController,
|
35253
|
+
ReadableByteStreamControllerPullInto(stream._readableStreamController, view, readIntoRequest);
|
36284
35254
|
}
|
36285
35255
|
}
|
36286
35256
|
function byobReaderBrandCheckException(name) {
|
@@ -37829,7 +36799,7 @@ var require_ponyfill_es2018 = __commonJS({
|
|
37829
36799
|
};
|
37830
36800
|
ReadableStreamDefaultReaderRead(reader, readRequest);
|
37831
36801
|
}
|
37832
|
-
function pullWithBYOBReader(
|
36802
|
+
function pullWithBYOBReader(view, forBranch2) {
|
37833
36803
|
if (IsReadableStreamDefaultReader(reader)) {
|
37834
36804
|
ReadableStreamReaderGenericRelease(reader);
|
37835
36805
|
reader = AcquireReadableStreamBYOBReader(stream);
|
@@ -37895,7 +36865,7 @@ var require_ponyfill_es2018 = __commonJS({
|
|
37895
36865
|
reading = false;
|
37896
36866
|
}
|
37897
36867
|
};
|
37898
|
-
ReadableStreamBYOBReaderRead(reader,
|
36868
|
+
ReadableStreamBYOBReaderRead(reader, view, readIntoRequest);
|
37899
36869
|
}
|
37900
36870
|
function pull1Algorithm() {
|
37901
36871
|
if (reading) {
|
@@ -52754,15 +51724,15 @@ var require_dist_cjs36 = __commonJS({
|
|
52754
51724
|
throw new Error("Int64 buffers must be exactly 8 bytes");
|
52755
51725
|
}
|
52756
51726
|
}
|
52757
|
-
static fromNumber(
|
52758
|
-
if (
|
52759
|
-
throw new Error(`${
|
51727
|
+
static fromNumber(number3) {
|
51728
|
+
if (number3 > 9223372036854776e3 || number3 < -9223372036854776e3) {
|
51729
|
+
throw new Error(`${number3} is too large (or, if negative, too small) to represent as an Int64`);
|
52760
51730
|
}
|
52761
51731
|
const bytes = new Uint8Array(8);
|
52762
|
-
for (let i2 = 7, remaining = Math.abs(Math.round(
|
51732
|
+
for (let i2 = 7, remaining = Math.abs(Math.round(number3)); i2 > -1 && remaining > 0; i2--, remaining /= 256) {
|
52763
51733
|
bytes[i2] = remaining;
|
52764
51734
|
}
|
52765
|
-
if (
|
51735
|
+
if (number3 < 0) {
|
52766
51736
|
negate(bytes);
|
52767
51737
|
}
|
52768
51738
|
return new _Int642(bytes);
|
@@ -64193,16 +63163,16 @@ var require_map_stream = __commonJS({
|
|
64193
63163
|
var writeQueue = {};
|
64194
63164
|
stream.writable = true;
|
64195
63165
|
stream.readable = true;
|
64196
|
-
function queueData(data,
|
63166
|
+
function queueData(data, number3) {
|
64197
63167
|
var nextToWrite = lastWritten + 1;
|
64198
|
-
if (
|
63168
|
+
if (number3 === nextToWrite) {
|
64199
63169
|
if (data !== void 0) {
|
64200
63170
|
stream.emit.apply(stream, ["data", data]);
|
64201
63171
|
}
|
64202
63172
|
lastWritten++;
|
64203
63173
|
nextToWrite++;
|
64204
63174
|
} else {
|
64205
|
-
writeQueue[
|
63175
|
+
writeQueue[number3] = data;
|
64206
63176
|
}
|
64207
63177
|
if (writeQueue.hasOwnProperty(nextToWrite)) {
|
64208
63178
|
var dataToWrite = writeQueue[nextToWrite];
|
@@ -64217,21 +63187,21 @@ var require_map_stream = __commonJS({
|
|
64217
63187
|
end();
|
64218
63188
|
}
|
64219
63189
|
}
|
64220
|
-
function next(err2, data,
|
63190
|
+
function next(err2, data, number3) {
|
64221
63191
|
if (destroyed)
|
64222
63192
|
return;
|
64223
63193
|
inNext = true;
|
64224
63194
|
if (!err2 || self2.opts.failures) {
|
64225
|
-
queueData(data,
|
63195
|
+
queueData(data, number3);
|
64226
63196
|
}
|
64227
63197
|
if (err2) {
|
64228
63198
|
stream.emit.apply(stream, [errorEventName, err2]);
|
64229
63199
|
}
|
64230
63200
|
inNext = false;
|
64231
63201
|
}
|
64232
|
-
function wrappedMapper(input,
|
63202
|
+
function wrappedMapper(input, number3, callback) {
|
64233
63203
|
return mapper.call(null, input, function(err2, data) {
|
64234
|
-
callback(err2, data,
|
63204
|
+
callback(err2, data, number3);
|
64235
63205
|
});
|
64236
63206
|
}
|
64237
63207
|
stream.write = function(data) {
|
@@ -78063,7 +77033,7 @@ var init_selector_ui = __esm({
|
|
78063
77033
|
});
|
78064
77034
|
|
78065
77035
|
// src/cli/commands/libSqlPushUtils.ts
|
78066
|
-
var
|
77036
|
+
var getOldTableName3, _moveDataStatements2, libSqlLogSuggestionsAndReturn;
|
78067
77037
|
var init_libSqlPushUtils = __esm({
|
78068
77038
|
"src/cli/commands/libSqlPushUtils.ts"() {
|
78069
77039
|
"use strict";
|
@@ -78071,7 +77041,7 @@ var init_libSqlPushUtils = __esm({
|
|
78071
77041
|
init_utils();
|
78072
77042
|
init_sqliteSchema();
|
78073
77043
|
init_sqlgenerator();
|
78074
|
-
|
77044
|
+
getOldTableName3 = (tableName, meta) => {
|
78075
77045
|
for (const key of Object.keys(meta.tables)) {
|
78076
77046
|
const value = meta.tables[key];
|
78077
77047
|
if (`"${tableName}"` === value) {
|
@@ -78226,7 +77196,7 @@ var init_libSqlPushUtils = __esm({
|
|
78226
77196
|
} else if (statement.type === "recreate_table") {
|
78227
77197
|
const tableName = statement.tableName;
|
78228
77198
|
let dataLoss = false;
|
78229
|
-
const oldTableName =
|
77199
|
+
const oldTableName = getOldTableName3(tableName, meta);
|
78230
77200
|
const prevColumnNames = Object.keys(json1.tables[oldTableName].columns);
|
78231
77201
|
const currentColumnNames = Object.keys(json2.tables[tableName].columns);
|
78232
77202
|
const { removedColumns, addedColumns } = findAddedAndRemoved(
|
@@ -81904,30 +80874,6 @@ var init_introspect_pg = __esm({
|
|
81904
80874
|
},
|
81905
80875
|
{ pg: [] }
|
81906
80876
|
);
|
81907
|
-
Object.values(schema5.views).forEach((it) => {
|
81908
|
-
if (it.schema && it.schema !== "public" && it.schema !== "") {
|
81909
|
-
imports.pg.push("pgSchema");
|
81910
|
-
} else if (it.schema === "public") {
|
81911
|
-
it.materialized ? imports.pg.push("pgMaterializedView") : imports.pg.push("pgView");
|
81912
|
-
}
|
81913
|
-
Object.values(it.columns).forEach(() => {
|
81914
|
-
const columnImports = Object.values(it.columns).map((col) => {
|
81915
|
-
let patched = (importsPatch2[col.type] || col.type).replace("[]", "");
|
81916
|
-
patched = patched === "double precision" ? "doublePrecision" : patched;
|
81917
|
-
patched = patched.startsWith("varchar(") ? "varchar" : patched;
|
81918
|
-
patched = patched.startsWith("char(") ? "char" : patched;
|
81919
|
-
patched = patched.startsWith("numeric(") ? "numeric" : patched;
|
81920
|
-
patched = patched.startsWith("time(") ? "time" : patched;
|
81921
|
-
patched = patched.startsWith("timestamp(") ? "timestamp" : patched;
|
81922
|
-
patched = patched.startsWith("vector(") ? "vector" : patched;
|
81923
|
-
patched = patched.startsWith("geometry(") ? "geometry" : patched;
|
81924
|
-
return patched;
|
81925
|
-
}).filter((type) => {
|
81926
|
-
return pgImportsList.has(type);
|
81927
|
-
});
|
81928
|
-
imports.pg.push(...columnImports);
|
81929
|
-
});
|
81930
|
-
});
|
81931
80877
|
Object.values(schema5.sequences).forEach((it) => {
|
81932
80878
|
if (it.schema && it.schema !== "public" && it.schema !== "") {
|
81933
80879
|
imports.pg.push("pgSchema");
|
@@ -82022,28 +80968,6 @@ var init_introspect_pg = __esm({
|
|
82022
80968
|
statement += ");";
|
82023
80969
|
return statement;
|
82024
80970
|
});
|
82025
|
-
const viewsStatements = Object.values(schema5.views).map((it) => {
|
82026
|
-
const viewSchema = schemas[it.schema];
|
82027
|
-
const paramName = paramNameFor(it.name, viewSchema);
|
82028
|
-
const func = viewSchema ? it.materialized ? `${viewSchema}.materializedView` : `${viewSchema}.view` : it.materialized ? "pgMaterializedView" : "pgView";
|
82029
|
-
const withOption = it.with ?? "";
|
82030
|
-
const as = `sql\`${it.definition}\``;
|
82031
|
-
const tablespace = it.tablespace ?? "";
|
82032
|
-
const columns = createTableColumns3(
|
82033
|
-
"",
|
82034
|
-
Object.values(it.columns),
|
82035
|
-
[],
|
82036
|
-
enumTypes,
|
82037
|
-
schemas,
|
82038
|
-
casing2,
|
82039
|
-
schema5.internal
|
82040
|
-
);
|
82041
|
-
let statement = `export const ${withCasing2(paramName, casing2)} = ${func}("${it.name}", {${columns}})`;
|
82042
|
-
statement += tablespace ? `.tablespace("${tablespace}")` : "";
|
82043
|
-
statement += withOption ? `.with(${JSON.stringify(withOption)})` : "";
|
82044
|
-
statement += `.as(${as});`;
|
82045
|
-
return statement;
|
82046
|
-
}).join("\n\n");
|
82047
80971
|
const uniquePgImports = ["pgTable", ...new Set(imports.pg)];
|
82048
80972
|
const importsTs = `import { ${uniquePgImports.join(
|
82049
80973
|
", "
|
@@ -82056,8 +80980,6 @@ var init_introspect_pg = __esm({
|
|
82056
80980
|
decalrations += sequencesStatements;
|
82057
80981
|
decalrations += "\n";
|
82058
80982
|
decalrations += tableStatements.join("\n\n");
|
82059
|
-
decalrations += "\n";
|
82060
|
-
decalrations += viewsStatements;
|
82061
80983
|
const file = importsTs + decalrations;
|
82062
80984
|
const schemaEntry = `
|
82063
80985
|
{
|
@@ -82616,7 +81538,6 @@ var init_introspect = __esm({
|
|
82616
81538
|
sequencesResolver,
|
82617
81539
|
tablesResolver,
|
82618
81540
|
columnsResolver,
|
82619
|
-
viewsResolver,
|
82620
81541
|
dryPg,
|
82621
81542
|
schema5
|
82622
81543
|
);
|
@@ -86338,7 +85259,7 @@ init_utils2();
|
|
86338
85259
|
var version2 = async () => {
|
86339
85260
|
const { npmVersion } = await ormCoreVersions();
|
86340
85261
|
const ormVersion = npmVersion ? `drizzle-orm: v${npmVersion}` : "";
|
86341
|
-
const envVersion = "0.25.0-
|
85262
|
+
const envVersion = "0.25.0-b8bf113";
|
86342
85263
|
const kitVersion = envVersion ? `v${envVersion}` : "--";
|
86343
85264
|
const versions = `drizzle-kit: ${kitVersion}
|
86344
85265
|
${ormVersion}`;
|