drizzle-kit 1.0.0-beta.2-84ab15f → 1.0.0-beta.2-b2cf0ac
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/api-postgres.js +35 -37
- package/api-postgres.mjs +35 -37
- package/bin.cjs +38 -40
- package/package.json +1 -1
package/api-postgres.js
CHANGED
|
@@ -15624,8 +15624,8 @@ var init_views = __esm({
|
|
|
15624
15624
|
`;
|
|
15625
15625
|
if (d6.with) cause += `| with: ${formatOptionChanges(d6.with.from, d6.with.to)}`;
|
|
15626
15626
|
}
|
|
15627
|
-
if (st.type === "
|
|
15628
|
-
const { from, to } = st;
|
|
15627
|
+
if (st.type === "drop_view" && st.cause) {
|
|
15628
|
+
const { cause: from, view: to } = st;
|
|
15629
15629
|
const key = `${to.schema}.${to.name}`;
|
|
15630
15630
|
title += `${key} view changed:`;
|
|
15631
15631
|
cause += `\u2502 definition: [${from.definition}] -> [${to.definition}]
|
|
@@ -22799,7 +22799,7 @@ function fromJson(statements) {
|
|
|
22799
22799
|
};
|
|
22800
22800
|
return result2;
|
|
22801
22801
|
}
|
|
22802
|
-
var convertor, createSchemaConvertor, dropSchemaConvertor, renameSchemaConvertor, createViewConvertor, dropViewConvertor, renameViewConvertor, moveViewConvertor, alterViewConvertor,
|
|
22802
|
+
var convertor, createSchemaConvertor, dropSchemaConvertor, renameSchemaConvertor, createViewConvertor, dropViewConvertor, renameViewConvertor, moveViewConvertor, alterViewConvertor, createTableConvertor, dropTableConvertor, renameTableConvertor, moveTableConvertor, addColumnConvertor, dropColumnConvertor, renameColumnConvertor, recreateColumnConvertor, recreateIndexConvertor, alterColumnConvertor, createIndexConvertor, dropIndexConvertor, renameIndexConvertor, addPrimaryKeyConvertor, dropPrimaryKeyConvertor, recreatePrimaryKeyConvertor, renameConstraintConvertor, createForeignKeyConvertor, recreateFKConvertor, dropForeignKeyConvertor, addCheckConvertor, dropCheckConvertor, recreateCheckConvertor, addUniqueConvertor, dropUniqueConvertor, createEnumConvertor, dropEnumConvertor, renameEnumConvertor, moveEnumConvertor, alterEnumConvertor, recreateEnumConvertor, createSequenceConvertor, dropSequenceConvertor, renameSequenceConvertor, moveSequenceConvertor, alterSequenceConvertor, createRoleConvertor, dropRoleConvertor, renameRoleConvertor, alterRoleConvertor, grantPrivilegeConvertor, revokePrivilegeConvertor, regrantPrivilegeConvertor, createPolicyConvertor, dropPolicyConvertor, renamePolicyConvertor, alterPolicyConvertor, recreatePolicy, toggleRlsConvertor, convertors;
|
|
22803
22803
|
var init_convertor = __esm({
|
|
22804
22804
|
"src/dialects/postgres/convertor.ts"() {
|
|
22805
22805
|
"use strict";
|
|
@@ -22888,11 +22888,6 @@ var init_convertor = __esm({
|
|
|
22888
22888
|
}
|
|
22889
22889
|
return statements;
|
|
22890
22890
|
});
|
|
22891
|
-
recreateViewConvertor = convertor("recreate_view", (st) => {
|
|
22892
|
-
const drop = dropViewConvertor.convert({ view: st.from });
|
|
22893
|
-
const create2 = createViewConvertor.convert({ view: st.to });
|
|
22894
|
-
return [drop, create2];
|
|
22895
|
-
});
|
|
22896
22891
|
createTableConvertor = convertor("create_table", (st) => {
|
|
22897
22892
|
const { schema: schema6, name, columns, pk, uniques, checks, policies, isRlsEnabled } = st.table;
|
|
22898
22893
|
const statements = [];
|
|
@@ -23002,7 +22997,7 @@ var init_convertor = __esm({
|
|
|
23002
22997
|
return [drop, add];
|
|
23003
22998
|
});
|
|
23004
22999
|
alterColumnConvertor = convertor("alter_column", (st) => {
|
|
23005
|
-
const { diff: diff2, to: column8, isEnum, wasEnum } = st;
|
|
23000
|
+
const { diff: diff2, to: column8, isEnum, wasEnum, wasSerial } = st;
|
|
23006
23001
|
const statements = [];
|
|
23007
23002
|
const key = column8.schema !== "public" ? `"${column8.schema}"."${column8.table}"` : `"${column8.table}"`;
|
|
23008
23003
|
const recreateDefault = diff2.type && (isEnum || wasEnum) && (column8.default || diff2.default && diff2.default.from);
|
|
@@ -23012,13 +23007,18 @@ var init_convertor = __esm({
|
|
|
23012
23007
|
if (diff2.type) {
|
|
23013
23008
|
const typeSchema = column8.typeSchema && column8.typeSchema !== "public" ? `"${column8.typeSchema}".` : "";
|
|
23014
23009
|
const textProxy = wasEnum && isEnum ? "text::" : "";
|
|
23015
|
-
const suffix = isEnum ? ` USING "${column8.name}"::${textProxy}${typeSchema}"${column8.type}"${"[]".repeat(column8.dimensions)}` : ""
|
|
23010
|
+
const suffix = isEnum ? ` USING "${column8.name}"::${textProxy}${typeSchema}"${column8.type}"${"[]".repeat(column8.dimensions)}` : ` USING "${column8.name}"::${column8.type}${"[]".repeat(column8.dimensions)}`;
|
|
23016
23011
|
let type;
|
|
23017
23012
|
if (diff2.type) {
|
|
23018
23013
|
type = diff2.typeSchema?.to && diff2.typeSchema.to !== "public" ? `"${diff2.typeSchema.to}"."${diff2.type.to}"` : isEnum ? `"${diff2.type.to}"` : diff2.type.to;
|
|
23019
23014
|
} else {
|
|
23020
23015
|
type = `${typeSchema}${column8.typeSchema ? `"${column8.type}"` : column8.type}`;
|
|
23021
23016
|
}
|
|
23017
|
+
if (wasSerial) {
|
|
23018
|
+
statements.push(`ALTER TABLE ${key} ALTER COLUMN "${column8.name}" DROP DEFAULT`);
|
|
23019
|
+
const sequenceKey = column8.schema !== "public" ? `"${column8.schema}"."${column8.table}_${column8.name}_seq"` : `"${column8.table}_${column8.name}_seq"`;
|
|
23020
|
+
statements.push(`DROP SEQUENCE ${sequenceKey}`);
|
|
23021
|
+
}
|
|
23022
23022
|
statements.push(
|
|
23023
23023
|
`ALTER TABLE ${key} ALTER COLUMN "${column8.name}" SET DATA TYPE ${type}${"[]".repeat(column8.dimensions)}${suffix};`
|
|
23024
23024
|
);
|
|
@@ -23053,6 +23053,11 @@ var init_convertor = __esm({
|
|
|
23053
23053
|
const cycle = identity.cycle ? ` CYCLE` : "";
|
|
23054
23054
|
const identityStatement = `GENERATED ${typeClause} AS IDENTITY (sequence name ${identityWithSchema}${incrementClause}${minClause}${maxClause}${startWith}${cache6}${cycle})`;
|
|
23055
23055
|
statements.push(`ALTER TABLE ${key} ALTER COLUMN "${column8.name}" ADD ${identityStatement};`);
|
|
23056
|
+
if (wasSerial && column8.identity) {
|
|
23057
|
+
statements.push(
|
|
23058
|
+
`SELECT setval('${column8.identity.name}'::regclass, (SELECT COALESCE(MAX(id), 1) FROM ${key}), false);`
|
|
23059
|
+
);
|
|
23060
|
+
}
|
|
23056
23061
|
} else if (diff2.identity.to === null) {
|
|
23057
23062
|
statements.push(`ALTER TABLE ${key} ALTER COLUMN "${column8.name}" DROP IDENTITY;`);
|
|
23058
23063
|
} else {
|
|
@@ -23391,7 +23396,6 @@ var init_convertor = __esm({
|
|
|
23391
23396
|
renameViewConvertor,
|
|
23392
23397
|
moveViewConvertor,
|
|
23393
23398
|
alterViewConvertor,
|
|
23394
|
-
recreateViewConvertor,
|
|
23395
23399
|
createTableConvertor,
|
|
23396
23400
|
dropTableConvertor,
|
|
23397
23401
|
renameTableConvertor,
|
|
@@ -24298,11 +24302,15 @@ var init_diff = __esm({
|
|
|
24298
24302
|
return ddl22.columns.hasDiff(it);
|
|
24299
24303
|
}).map((it) => {
|
|
24300
24304
|
const column8 = it.$right;
|
|
24305
|
+
const wasSerial = isSerialType(it.$left.type);
|
|
24306
|
+
const isEnum = ddl22.enums.one({ schema: column8.typeSchema ?? "public", name: column8.type }) !== null;
|
|
24307
|
+
const wasEnum = (it.type && ddl1.enums.one({ schema: column8.typeSchema ?? "public", name: it.type.from }) !== null) ?? false;
|
|
24301
24308
|
return prepareStatement("alter_column", {
|
|
24302
24309
|
diff: it,
|
|
24303
|
-
|
|
24304
|
-
|
|
24305
|
-
|
|
24310
|
+
to: column8,
|
|
24311
|
+
isEnum,
|
|
24312
|
+
wasEnum,
|
|
24313
|
+
wasSerial
|
|
24306
24314
|
});
|
|
24307
24315
|
});
|
|
24308
24316
|
const createSequences = createdSequences.map((it) => prepareStatement("create_sequence", { sequence: it }));
|
|
@@ -24329,7 +24337,7 @@ var init_diff = __esm({
|
|
|
24329
24337
|
const renameSchemas = renamedSchemas.map((it) => prepareStatement("rename_schema", it));
|
|
24330
24338
|
const createTables = createdTables.map((it) => prepareStatement("create_table", { table: tableFromDDL(it, ddl22) }));
|
|
24331
24339
|
const createViews = createdViews.map((it) => prepareStatement("create_view", { view: it }));
|
|
24332
|
-
const jsonDropViews = deletedViews.map((it) => prepareStatement("drop_view", { view: it }));
|
|
24340
|
+
const jsonDropViews = deletedViews.map((it) => prepareStatement("drop_view", { view: it, cause: null }));
|
|
24333
24341
|
const jsonRenameViews = renamedViews.map((it) => prepareStatement("rename_view", it));
|
|
24334
24342
|
const jsonMoveViews = movedViews.map(
|
|
24335
24343
|
(it) => prepareStatement("move_view", { fromSchema: it.from.schema, toSchema: it.to.schema, view: it.to })
|
|
@@ -24354,7 +24362,7 @@ var init_diff = __esm({
|
|
|
24354
24362
|
view: it.view
|
|
24355
24363
|
});
|
|
24356
24364
|
});
|
|
24357
|
-
|
|
24365
|
+
viewsAlters.filter((it) => it.diff.definition).forEach((entry) => {
|
|
24358
24366
|
const it = entry.view;
|
|
24359
24367
|
const schemaRename = renamedSchemas.find((r7) => r7.to.name === it.schema);
|
|
24360
24368
|
const schema6 = schemaRename ? schemaRename.from.name : it.schema;
|
|
@@ -24368,7 +24376,8 @@ var init_diff = __esm({
|
|
|
24368
24376
|
${schema6}:${name}
|
|
24369
24377
|
`);
|
|
24370
24378
|
}
|
|
24371
|
-
|
|
24379
|
+
jsonDropViews.push(prepareStatement("drop_view", { view: it, cause: from }));
|
|
24380
|
+
createViews.push(prepareStatement("create_view", { view: it }));
|
|
24372
24381
|
});
|
|
24373
24382
|
const columnsToRecreate = columnAlters.filter((it) => it.generated && it.generated.to !== null).filter((it) => {
|
|
24374
24383
|
return !(it.generated?.to && it.generated.from && mode === "push");
|
|
@@ -24419,7 +24428,6 @@ var init_diff = __esm({
|
|
|
24419
24428
|
jsonStatements.push(...jsonDropViews);
|
|
24420
24429
|
jsonStatements.push(...jsonRenameViews);
|
|
24421
24430
|
jsonStatements.push(...jsonMoveViews);
|
|
24422
|
-
jsonStatements.push(...jsonRecreateViews);
|
|
24423
24431
|
jsonStatements.push(...jsonAlterViews);
|
|
24424
24432
|
jsonStatements.push(...jsonRenameTables);
|
|
24425
24433
|
jsonStatements.push(...jsonDropPoliciesStatements);
|
|
@@ -24983,12 +24991,6 @@ var init_introspect = __esm({
|
|
|
24983
24991
|
values: it.values
|
|
24984
24992
|
});
|
|
24985
24993
|
}
|
|
24986
|
-
let columnsCount = 0;
|
|
24987
|
-
let indexesCount = 0;
|
|
24988
|
-
let foreignKeysCount = 0;
|
|
24989
|
-
let tableCount = 0;
|
|
24990
|
-
let checksCount = 0;
|
|
24991
|
-
let viewsCount = 0;
|
|
24992
24994
|
for (const seq of sequencesList) {
|
|
24993
24995
|
const depend = dependList.find((it) => it.oid === seq.oid);
|
|
24994
24996
|
if (depend && (depend.deptype === "a" || depend.deptype === "i")) {
|
|
@@ -25006,7 +25008,6 @@ var init_introspect = __esm({
|
|
|
25006
25008
|
cacheSize: Number(stringFromDatabaseIdentityProperty(seq.cacheSize) ?? 1)
|
|
25007
25009
|
});
|
|
25008
25010
|
}
|
|
25009
|
-
progressCallback("enums", Object.keys(groupedEnums).length, "done");
|
|
25010
25011
|
for (const dbRole of rolesList) {
|
|
25011
25012
|
roles.push({
|
|
25012
25013
|
entityType: "roles",
|
|
@@ -25049,7 +25050,6 @@ var init_introspect = __esm({
|
|
|
25049
25050
|
withCheck: it.withCheck ?? null
|
|
25050
25051
|
});
|
|
25051
25052
|
}
|
|
25052
|
-
progressCallback("policies", policiesList.length, "done");
|
|
25053
25053
|
for (const column8 of columnsList.filter((x6) => x6.kind === "r" || x6.kind === "p")) {
|
|
25054
25054
|
const type = column8.type;
|
|
25055
25055
|
if (!(type === "smallint" || type === "bigint" || type === "integer")) {
|
|
@@ -25328,10 +25328,6 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25328
25328
|
forPK
|
|
25329
25329
|
});
|
|
25330
25330
|
}
|
|
25331
|
-
progressCallback("columns", columnsCount, "fetching");
|
|
25332
|
-
progressCallback("checks", checksCount, "fetching");
|
|
25333
|
-
progressCallback("indexes", indexesCount, "fetching");
|
|
25334
|
-
progressCallback("tables", tableCount, "done");
|
|
25335
25331
|
for (const it of columnsList.filter((x6) => x6.kind === "m" || x6.kind === "v")) {
|
|
25336
25332
|
const view6 = viewsList.find((x6) => x6.oid === it.tableId);
|
|
25337
25333
|
const typeDimensions = it.type.split("[]").length - 1;
|
|
@@ -25355,7 +25351,6 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25355
25351
|
});
|
|
25356
25352
|
}
|
|
25357
25353
|
for (const view6 of viewsList) {
|
|
25358
|
-
tableCount += 1;
|
|
25359
25354
|
const accessMethod = view6.accessMethod === 0 ? null : ams.find((it) => it.oid === view6.accessMethod);
|
|
25360
25355
|
const tablespace = view6.tablespaceid === 0 ? null : tablespaces.find((it) => it.oid === view6.tablespaceid).name;
|
|
25361
25356
|
const definition = parseViewDefinition(view6.definition);
|
|
@@ -25407,11 +25402,14 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25407
25402
|
withNoData: null
|
|
25408
25403
|
});
|
|
25409
25404
|
}
|
|
25410
|
-
progressCallback("
|
|
25411
|
-
progressCallback("
|
|
25412
|
-
progressCallback("
|
|
25413
|
-
progressCallback("
|
|
25414
|
-
progressCallback("views",
|
|
25405
|
+
progressCallback("tables", filteredTables.length, "done");
|
|
25406
|
+
progressCallback("columns", columnsList.length, "done");
|
|
25407
|
+
progressCallback("checks", checks.length, "done");
|
|
25408
|
+
progressCallback("indexes", indexes.length, "fetching");
|
|
25409
|
+
progressCallback("views", viewsList.length, "done");
|
|
25410
|
+
progressCallback("fks", fks.length, "done");
|
|
25411
|
+
progressCallback("enums", Object.keys(groupedEnums).length, "done");
|
|
25412
|
+
progressCallback("policies", policiesList.length, "done");
|
|
25415
25413
|
const resultSchemas = schemas.filter((x6) => filter2({ type: "schema", name: x6.name }));
|
|
25416
25414
|
const resultTables = tables.filter((x6) => filter2({ type: "table", schema: x6.schema, name: x6.name }));
|
|
25417
25415
|
const resultEnums = enums.filter((x6) => resultSchemas.some((s7) => s7.name === x6.schema));
|
|
@@ -149567,7 +149565,7 @@ var init_push_postgres = __esm({
|
|
|
149567
149565
|
suggestions = async (db, jsonStatements) => {
|
|
149568
149566
|
const grouped = [];
|
|
149569
149567
|
const filtered = jsonStatements.filter((it) => {
|
|
149570
|
-
if (it.type === "
|
|
149568
|
+
if (it.type === "drop_view" && it.cause) return false;
|
|
149571
149569
|
if (it.type === "alter_column" && it.diff.generated) return false;
|
|
149572
149570
|
return true;
|
|
149573
149571
|
});
|
package/api-postgres.mjs
CHANGED
|
@@ -15630,8 +15630,8 @@ var init_views = __esm({
|
|
|
15630
15630
|
`;
|
|
15631
15631
|
if (d6.with) cause += `| with: ${formatOptionChanges(d6.with.from, d6.with.to)}`;
|
|
15632
15632
|
}
|
|
15633
|
-
if (st.type === "
|
|
15634
|
-
const { from, to } = st;
|
|
15633
|
+
if (st.type === "drop_view" && st.cause) {
|
|
15634
|
+
const { cause: from, view: to } = st;
|
|
15635
15635
|
const key = `${to.schema}.${to.name}`;
|
|
15636
15636
|
title += `${key} view changed:`;
|
|
15637
15637
|
cause += `\u2502 definition: [${from.definition}] -> [${to.definition}]
|
|
@@ -22835,7 +22835,7 @@ function fromJson(statements) {
|
|
|
22835
22835
|
};
|
|
22836
22836
|
return result2;
|
|
22837
22837
|
}
|
|
22838
|
-
var convertor, createSchemaConvertor, dropSchemaConvertor, renameSchemaConvertor, createViewConvertor, dropViewConvertor, renameViewConvertor, moveViewConvertor, alterViewConvertor,
|
|
22838
|
+
var convertor, createSchemaConvertor, dropSchemaConvertor, renameSchemaConvertor, createViewConvertor, dropViewConvertor, renameViewConvertor, moveViewConvertor, alterViewConvertor, createTableConvertor, dropTableConvertor, renameTableConvertor, moveTableConvertor, addColumnConvertor, dropColumnConvertor, renameColumnConvertor, recreateColumnConvertor, recreateIndexConvertor, alterColumnConvertor, createIndexConvertor, dropIndexConvertor, renameIndexConvertor, addPrimaryKeyConvertor, dropPrimaryKeyConvertor, recreatePrimaryKeyConvertor, renameConstraintConvertor, createForeignKeyConvertor, recreateFKConvertor, dropForeignKeyConvertor, addCheckConvertor, dropCheckConvertor, recreateCheckConvertor, addUniqueConvertor, dropUniqueConvertor, createEnumConvertor, dropEnumConvertor, renameEnumConvertor, moveEnumConvertor, alterEnumConvertor, recreateEnumConvertor, createSequenceConvertor, dropSequenceConvertor, renameSequenceConvertor, moveSequenceConvertor, alterSequenceConvertor, createRoleConvertor, dropRoleConvertor, renameRoleConvertor, alterRoleConvertor, grantPrivilegeConvertor, revokePrivilegeConvertor, regrantPrivilegeConvertor, createPolicyConvertor, dropPolicyConvertor, renamePolicyConvertor, alterPolicyConvertor, recreatePolicy, toggleRlsConvertor, convertors;
|
|
22839
22839
|
var init_convertor = __esm({
|
|
22840
22840
|
"src/dialects/postgres/convertor.ts"() {
|
|
22841
22841
|
"use strict";
|
|
@@ -22924,11 +22924,6 @@ var init_convertor = __esm({
|
|
|
22924
22924
|
}
|
|
22925
22925
|
return statements;
|
|
22926
22926
|
});
|
|
22927
|
-
recreateViewConvertor = convertor("recreate_view", (st) => {
|
|
22928
|
-
const drop = dropViewConvertor.convert({ view: st.from });
|
|
22929
|
-
const create2 = createViewConvertor.convert({ view: st.to });
|
|
22930
|
-
return [drop, create2];
|
|
22931
|
-
});
|
|
22932
22927
|
createTableConvertor = convertor("create_table", (st) => {
|
|
22933
22928
|
const { schema: schema6, name, columns, pk, uniques, checks, policies, isRlsEnabled } = st.table;
|
|
22934
22929
|
const statements = [];
|
|
@@ -23038,7 +23033,7 @@ var init_convertor = __esm({
|
|
|
23038
23033
|
return [drop, add];
|
|
23039
23034
|
});
|
|
23040
23035
|
alterColumnConvertor = convertor("alter_column", (st) => {
|
|
23041
|
-
const { diff: diff2, to: column8, isEnum, wasEnum } = st;
|
|
23036
|
+
const { diff: diff2, to: column8, isEnum, wasEnum, wasSerial } = st;
|
|
23042
23037
|
const statements = [];
|
|
23043
23038
|
const key = column8.schema !== "public" ? `"${column8.schema}"."${column8.table}"` : `"${column8.table}"`;
|
|
23044
23039
|
const recreateDefault = diff2.type && (isEnum || wasEnum) && (column8.default || diff2.default && diff2.default.from);
|
|
@@ -23048,13 +23043,18 @@ var init_convertor = __esm({
|
|
|
23048
23043
|
if (diff2.type) {
|
|
23049
23044
|
const typeSchema = column8.typeSchema && column8.typeSchema !== "public" ? `"${column8.typeSchema}".` : "";
|
|
23050
23045
|
const textProxy = wasEnum && isEnum ? "text::" : "";
|
|
23051
|
-
const suffix = isEnum ? ` USING "${column8.name}"::${textProxy}${typeSchema}"${column8.type}"${"[]".repeat(column8.dimensions)}` : ""
|
|
23046
|
+
const suffix = isEnum ? ` USING "${column8.name}"::${textProxy}${typeSchema}"${column8.type}"${"[]".repeat(column8.dimensions)}` : ` USING "${column8.name}"::${column8.type}${"[]".repeat(column8.dimensions)}`;
|
|
23052
23047
|
let type;
|
|
23053
23048
|
if (diff2.type) {
|
|
23054
23049
|
type = diff2.typeSchema?.to && diff2.typeSchema.to !== "public" ? `"${diff2.typeSchema.to}"."${diff2.type.to}"` : isEnum ? `"${diff2.type.to}"` : diff2.type.to;
|
|
23055
23050
|
} else {
|
|
23056
23051
|
type = `${typeSchema}${column8.typeSchema ? `"${column8.type}"` : column8.type}`;
|
|
23057
23052
|
}
|
|
23053
|
+
if (wasSerial) {
|
|
23054
|
+
statements.push(`ALTER TABLE ${key} ALTER COLUMN "${column8.name}" DROP DEFAULT`);
|
|
23055
|
+
const sequenceKey = column8.schema !== "public" ? `"${column8.schema}"."${column8.table}_${column8.name}_seq"` : `"${column8.table}_${column8.name}_seq"`;
|
|
23056
|
+
statements.push(`DROP SEQUENCE ${sequenceKey}`);
|
|
23057
|
+
}
|
|
23058
23058
|
statements.push(
|
|
23059
23059
|
`ALTER TABLE ${key} ALTER COLUMN "${column8.name}" SET DATA TYPE ${type}${"[]".repeat(column8.dimensions)}${suffix};`
|
|
23060
23060
|
);
|
|
@@ -23089,6 +23089,11 @@ var init_convertor = __esm({
|
|
|
23089
23089
|
const cycle = identity.cycle ? ` CYCLE` : "";
|
|
23090
23090
|
const identityStatement = `GENERATED ${typeClause} AS IDENTITY (sequence name ${identityWithSchema}${incrementClause}${minClause}${maxClause}${startWith}${cache6}${cycle})`;
|
|
23091
23091
|
statements.push(`ALTER TABLE ${key} ALTER COLUMN "${column8.name}" ADD ${identityStatement};`);
|
|
23092
|
+
if (wasSerial && column8.identity) {
|
|
23093
|
+
statements.push(
|
|
23094
|
+
`SELECT setval('${column8.identity.name}'::regclass, (SELECT COALESCE(MAX(id), 1) FROM ${key}), false);`
|
|
23095
|
+
);
|
|
23096
|
+
}
|
|
23092
23097
|
} else if (diff2.identity.to === null) {
|
|
23093
23098
|
statements.push(`ALTER TABLE ${key} ALTER COLUMN "${column8.name}" DROP IDENTITY;`);
|
|
23094
23099
|
} else {
|
|
@@ -23427,7 +23432,6 @@ var init_convertor = __esm({
|
|
|
23427
23432
|
renameViewConvertor,
|
|
23428
23433
|
moveViewConvertor,
|
|
23429
23434
|
alterViewConvertor,
|
|
23430
|
-
recreateViewConvertor,
|
|
23431
23435
|
createTableConvertor,
|
|
23432
23436
|
dropTableConvertor,
|
|
23433
23437
|
renameTableConvertor,
|
|
@@ -24334,11 +24338,15 @@ var init_diff = __esm({
|
|
|
24334
24338
|
return ddl22.columns.hasDiff(it);
|
|
24335
24339
|
}).map((it) => {
|
|
24336
24340
|
const column8 = it.$right;
|
|
24341
|
+
const wasSerial = isSerialType(it.$left.type);
|
|
24342
|
+
const isEnum = ddl22.enums.one({ schema: column8.typeSchema ?? "public", name: column8.type }) !== null;
|
|
24343
|
+
const wasEnum = (it.type && ddl1.enums.one({ schema: column8.typeSchema ?? "public", name: it.type.from }) !== null) ?? false;
|
|
24337
24344
|
return prepareStatement("alter_column", {
|
|
24338
24345
|
diff: it,
|
|
24339
|
-
|
|
24340
|
-
|
|
24341
|
-
|
|
24346
|
+
to: column8,
|
|
24347
|
+
isEnum,
|
|
24348
|
+
wasEnum,
|
|
24349
|
+
wasSerial
|
|
24342
24350
|
});
|
|
24343
24351
|
});
|
|
24344
24352
|
const createSequences = createdSequences.map((it) => prepareStatement("create_sequence", { sequence: it }));
|
|
@@ -24365,7 +24373,7 @@ var init_diff = __esm({
|
|
|
24365
24373
|
const renameSchemas = renamedSchemas.map((it) => prepareStatement("rename_schema", it));
|
|
24366
24374
|
const createTables = createdTables.map((it) => prepareStatement("create_table", { table: tableFromDDL(it, ddl22) }));
|
|
24367
24375
|
const createViews = createdViews.map((it) => prepareStatement("create_view", { view: it }));
|
|
24368
|
-
const jsonDropViews = deletedViews.map((it) => prepareStatement("drop_view", { view: it }));
|
|
24376
|
+
const jsonDropViews = deletedViews.map((it) => prepareStatement("drop_view", { view: it, cause: null }));
|
|
24369
24377
|
const jsonRenameViews = renamedViews.map((it) => prepareStatement("rename_view", it));
|
|
24370
24378
|
const jsonMoveViews = movedViews.map(
|
|
24371
24379
|
(it) => prepareStatement("move_view", { fromSchema: it.from.schema, toSchema: it.to.schema, view: it.to })
|
|
@@ -24390,7 +24398,7 @@ var init_diff = __esm({
|
|
|
24390
24398
|
view: it.view
|
|
24391
24399
|
});
|
|
24392
24400
|
});
|
|
24393
|
-
|
|
24401
|
+
viewsAlters.filter((it) => it.diff.definition).forEach((entry) => {
|
|
24394
24402
|
const it = entry.view;
|
|
24395
24403
|
const schemaRename = renamedSchemas.find((r7) => r7.to.name === it.schema);
|
|
24396
24404
|
const schema6 = schemaRename ? schemaRename.from.name : it.schema;
|
|
@@ -24404,7 +24412,8 @@ var init_diff = __esm({
|
|
|
24404
24412
|
${schema6}:${name}
|
|
24405
24413
|
`);
|
|
24406
24414
|
}
|
|
24407
|
-
|
|
24415
|
+
jsonDropViews.push(prepareStatement("drop_view", { view: it, cause: from }));
|
|
24416
|
+
createViews.push(prepareStatement("create_view", { view: it }));
|
|
24408
24417
|
});
|
|
24409
24418
|
const columnsToRecreate = columnAlters.filter((it) => it.generated && it.generated.to !== null).filter((it) => {
|
|
24410
24419
|
return !(it.generated?.to && it.generated.from && mode === "push");
|
|
@@ -24455,7 +24464,6 @@ var init_diff = __esm({
|
|
|
24455
24464
|
jsonStatements.push(...jsonDropViews);
|
|
24456
24465
|
jsonStatements.push(...jsonRenameViews);
|
|
24457
24466
|
jsonStatements.push(...jsonMoveViews);
|
|
24458
|
-
jsonStatements.push(...jsonRecreateViews);
|
|
24459
24467
|
jsonStatements.push(...jsonAlterViews);
|
|
24460
24468
|
jsonStatements.push(...jsonRenameTables);
|
|
24461
24469
|
jsonStatements.push(...jsonDropPoliciesStatements);
|
|
@@ -25019,12 +25027,6 @@ var init_introspect = __esm({
|
|
|
25019
25027
|
values: it.values
|
|
25020
25028
|
});
|
|
25021
25029
|
}
|
|
25022
|
-
let columnsCount = 0;
|
|
25023
|
-
let indexesCount = 0;
|
|
25024
|
-
let foreignKeysCount = 0;
|
|
25025
|
-
let tableCount = 0;
|
|
25026
|
-
let checksCount = 0;
|
|
25027
|
-
let viewsCount = 0;
|
|
25028
25030
|
for (const seq of sequencesList) {
|
|
25029
25031
|
const depend = dependList.find((it) => it.oid === seq.oid);
|
|
25030
25032
|
if (depend && (depend.deptype === "a" || depend.deptype === "i")) {
|
|
@@ -25042,7 +25044,6 @@ var init_introspect = __esm({
|
|
|
25042
25044
|
cacheSize: Number(stringFromDatabaseIdentityProperty(seq.cacheSize) ?? 1)
|
|
25043
25045
|
});
|
|
25044
25046
|
}
|
|
25045
|
-
progressCallback("enums", Object.keys(groupedEnums).length, "done");
|
|
25046
25047
|
for (const dbRole of rolesList) {
|
|
25047
25048
|
roles.push({
|
|
25048
25049
|
entityType: "roles",
|
|
@@ -25085,7 +25086,6 @@ var init_introspect = __esm({
|
|
|
25085
25086
|
withCheck: it.withCheck ?? null
|
|
25086
25087
|
});
|
|
25087
25088
|
}
|
|
25088
|
-
progressCallback("policies", policiesList.length, "done");
|
|
25089
25089
|
for (const column8 of columnsList.filter((x6) => x6.kind === "r" || x6.kind === "p")) {
|
|
25090
25090
|
const type = column8.type;
|
|
25091
25091
|
if (!(type === "smallint" || type === "bigint" || type === "integer")) {
|
|
@@ -25364,10 +25364,6 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25364
25364
|
forPK
|
|
25365
25365
|
});
|
|
25366
25366
|
}
|
|
25367
|
-
progressCallback("columns", columnsCount, "fetching");
|
|
25368
|
-
progressCallback("checks", checksCount, "fetching");
|
|
25369
|
-
progressCallback("indexes", indexesCount, "fetching");
|
|
25370
|
-
progressCallback("tables", tableCount, "done");
|
|
25371
25367
|
for (const it of columnsList.filter((x6) => x6.kind === "m" || x6.kind === "v")) {
|
|
25372
25368
|
const view6 = viewsList.find((x6) => x6.oid === it.tableId);
|
|
25373
25369
|
const typeDimensions = it.type.split("[]").length - 1;
|
|
@@ -25391,7 +25387,6 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25391
25387
|
});
|
|
25392
25388
|
}
|
|
25393
25389
|
for (const view6 of viewsList) {
|
|
25394
|
-
tableCount += 1;
|
|
25395
25390
|
const accessMethod = view6.accessMethod === 0 ? null : ams.find((it) => it.oid === view6.accessMethod);
|
|
25396
25391
|
const tablespace = view6.tablespaceid === 0 ? null : tablespaces.find((it) => it.oid === view6.tablespaceid).name;
|
|
25397
25392
|
const definition = parseViewDefinition(view6.definition);
|
|
@@ -25443,11 +25438,14 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25443
25438
|
withNoData: null
|
|
25444
25439
|
});
|
|
25445
25440
|
}
|
|
25446
|
-
progressCallback("
|
|
25447
|
-
progressCallback("
|
|
25448
|
-
progressCallback("
|
|
25449
|
-
progressCallback("
|
|
25450
|
-
progressCallback("views",
|
|
25441
|
+
progressCallback("tables", filteredTables.length, "done");
|
|
25442
|
+
progressCallback("columns", columnsList.length, "done");
|
|
25443
|
+
progressCallback("checks", checks.length, "done");
|
|
25444
|
+
progressCallback("indexes", indexes.length, "fetching");
|
|
25445
|
+
progressCallback("views", viewsList.length, "done");
|
|
25446
|
+
progressCallback("fks", fks.length, "done");
|
|
25447
|
+
progressCallback("enums", Object.keys(groupedEnums).length, "done");
|
|
25448
|
+
progressCallback("policies", policiesList.length, "done");
|
|
25451
25449
|
const resultSchemas = schemas.filter((x6) => filter2({ type: "schema", name: x6.name }));
|
|
25452
25450
|
const resultTables = tables.filter((x6) => filter2({ type: "table", schema: x6.schema, name: x6.name }));
|
|
25453
25451
|
const resultEnums = enums.filter((x6) => resultSchemas.some((s7) => s7.name === x6.schema));
|
|
@@ -149600,7 +149598,7 @@ var init_push_postgres = __esm({
|
|
|
149600
149598
|
suggestions = async (db, jsonStatements) => {
|
|
149601
149599
|
const grouped = [];
|
|
149602
149600
|
const filtered = jsonStatements.filter((it) => {
|
|
149603
|
-
if (it.type === "
|
|
149601
|
+
if (it.type === "drop_view" && it.cause) return false;
|
|
149604
149602
|
if (it.type === "alter_column" && it.diff.generated) return false;
|
|
149605
149603
|
return true;
|
|
149606
149604
|
});
|
package/bin.cjs
CHANGED
|
@@ -23346,8 +23346,8 @@ var init_views = __esm({
|
|
|
23346
23346
|
`;
|
|
23347
23347
|
if (d5.with) cause += `| with: ${formatOptionChanges(d5.with.from, d5.with.to)}`;
|
|
23348
23348
|
}
|
|
23349
|
-
if (st2.type === "
|
|
23350
|
-
const { from,
|
|
23349
|
+
if (st2.type === "drop_view" && st2.cause) {
|
|
23350
|
+
const { cause: from, view: to2 } = st2;
|
|
23351
23351
|
const key = `${to2.schema}.${to2.name}`;
|
|
23352
23352
|
title += `${key} view changed:`;
|
|
23353
23353
|
cause += `\u2502 definition: [${from.definition}] -> [${to2.definition}]
|
|
@@ -38780,7 +38780,7 @@ function fromJson(statements) {
|
|
|
38780
38780
|
};
|
|
38781
38781
|
return result2;
|
|
38782
38782
|
}
|
|
38783
|
-
var convertor, createSchemaConvertor, dropSchemaConvertor, renameSchemaConvertor, createViewConvertor, dropViewConvertor, renameViewConvertor, moveViewConvertor, alterViewConvertor,
|
|
38783
|
+
var convertor, createSchemaConvertor, dropSchemaConvertor, renameSchemaConvertor, createViewConvertor, dropViewConvertor, renameViewConvertor, moveViewConvertor, alterViewConvertor, createTableConvertor, dropTableConvertor, renameTableConvertor, moveTableConvertor, addColumnConvertor, dropColumnConvertor, renameColumnConvertor, recreateColumnConvertor, recreateIndexConvertor, alterColumnConvertor, createIndexConvertor, dropIndexConvertor, renameIndexConvertor, addPrimaryKeyConvertor, dropPrimaryKeyConvertor, recreatePrimaryKeyConvertor, renameConstraintConvertor, createForeignKeyConvertor, recreateFKConvertor, dropForeignKeyConvertor, addCheckConvertor, dropCheckConvertor, recreateCheckConvertor, addUniqueConvertor, dropUniqueConvertor, createEnumConvertor, dropEnumConvertor, renameEnumConvertor, moveEnumConvertor, alterEnumConvertor, recreateEnumConvertor, createSequenceConvertor, dropSequenceConvertor, renameSequenceConvertor, moveSequenceConvertor, alterSequenceConvertor, createRoleConvertor, dropRoleConvertor, renameRoleConvertor, alterRoleConvertor, grantPrivilegeConvertor, revokePrivilegeConvertor, regrantPrivilegeConvertor, createPolicyConvertor, dropPolicyConvertor, renamePolicyConvertor, alterPolicyConvertor, recreatePolicy, toggleRlsConvertor, convertors;
|
|
38784
38784
|
var init_convertor = __esm({
|
|
38785
38785
|
"src/dialects/postgres/convertor.ts"() {
|
|
38786
38786
|
"use strict";
|
|
@@ -38870,11 +38870,6 @@ var init_convertor = __esm({
|
|
|
38870
38870
|
}
|
|
38871
38871
|
return statements;
|
|
38872
38872
|
});
|
|
38873
|
-
recreateViewConvertor = convertor("recreate_view", (st2) => {
|
|
38874
|
-
const drop = dropViewConvertor.convert({ view: st2.from });
|
|
38875
|
-
const create2 = createViewConvertor.convert({ view: st2.to });
|
|
38876
|
-
return [drop, create2];
|
|
38877
|
-
});
|
|
38878
38873
|
createTableConvertor = convertor("create_table", (st2) => {
|
|
38879
38874
|
var _a5, _b;
|
|
38880
38875
|
const { schema: schema6, name, columns, pk, uniques, checks, policies, isRlsEnabled } = st2.table;
|
|
@@ -38986,7 +38981,7 @@ var init_convertor = __esm({
|
|
|
38986
38981
|
});
|
|
38987
38982
|
alterColumnConvertor = convertor("alter_column", (st2) => {
|
|
38988
38983
|
var _a5;
|
|
38989
|
-
const { diff: diff2, to: column12, isEnum, wasEnum } = st2;
|
|
38984
|
+
const { diff: diff2, to: column12, isEnum, wasEnum, wasSerial } = st2;
|
|
38990
38985
|
const statements = [];
|
|
38991
38986
|
const key = column12.schema !== "public" ? `"${column12.schema}"."${column12.table}"` : `"${column12.table}"`;
|
|
38992
38987
|
const recreateDefault = diff2.type && (isEnum || wasEnum) && (column12.default || diff2.default && diff2.default.from);
|
|
@@ -38996,13 +38991,18 @@ var init_convertor = __esm({
|
|
|
38996
38991
|
if (diff2.type) {
|
|
38997
38992
|
const typeSchema = column12.typeSchema && column12.typeSchema !== "public" ? `"${column12.typeSchema}".` : "";
|
|
38998
38993
|
const textProxy = wasEnum && isEnum ? "text::" : "";
|
|
38999
|
-
const suffix = isEnum ? ` USING "${column12.name}"::${textProxy}${typeSchema}"${column12.type}"${"[]".repeat(column12.dimensions)}` : ""
|
|
38994
|
+
const suffix = isEnum ? ` USING "${column12.name}"::${textProxy}${typeSchema}"${column12.type}"${"[]".repeat(column12.dimensions)}` : ` USING "${column12.name}"::${column12.type}${"[]".repeat(column12.dimensions)}`;
|
|
39000
38995
|
let type;
|
|
39001
38996
|
if (diff2.type) {
|
|
39002
38997
|
type = ((_a5 = diff2.typeSchema) == null ? void 0 : _a5.to) && diff2.typeSchema.to !== "public" ? `"${diff2.typeSchema.to}"."${diff2.type.to}"` : isEnum ? `"${diff2.type.to}"` : diff2.type.to;
|
|
39003
38998
|
} else {
|
|
39004
38999
|
type = `${typeSchema}${column12.typeSchema ? `"${column12.type}"` : column12.type}`;
|
|
39005
39000
|
}
|
|
39001
|
+
if (wasSerial) {
|
|
39002
|
+
statements.push(`ALTER TABLE ${key} ALTER COLUMN "${column12.name}" DROP DEFAULT`);
|
|
39003
|
+
const sequenceKey = column12.schema !== "public" ? `"${column12.schema}"."${column12.table}_${column12.name}_seq"` : `"${column12.table}_${column12.name}_seq"`;
|
|
39004
|
+
statements.push(`DROP SEQUENCE ${sequenceKey}`);
|
|
39005
|
+
}
|
|
39006
39006
|
statements.push(
|
|
39007
39007
|
`ALTER TABLE ${key} ALTER COLUMN "${column12.name}" SET DATA TYPE ${type}${"[]".repeat(column12.dimensions)}${suffix};`
|
|
39008
39008
|
);
|
|
@@ -39037,6 +39037,11 @@ var init_convertor = __esm({
|
|
|
39037
39037
|
const cycle = identity.cycle ? ` CYCLE` : "";
|
|
39038
39038
|
const identityStatement = `GENERATED ${typeClause} AS IDENTITY (sequence name ${identityWithSchema}${incrementClause}${minClause}${maxClause}${startWith}${cache4}${cycle})`;
|
|
39039
39039
|
statements.push(`ALTER TABLE ${key} ALTER COLUMN "${column12.name}" ADD ${identityStatement};`);
|
|
39040
|
+
if (wasSerial && column12.identity) {
|
|
39041
|
+
statements.push(
|
|
39042
|
+
`SELECT setval('${column12.identity.name}'::regclass, (SELECT COALESCE(MAX(id), 1) FROM ${key}), false);`
|
|
39043
|
+
);
|
|
39044
|
+
}
|
|
39040
39045
|
} else if (diff2.identity.to === null) {
|
|
39041
39046
|
statements.push(`ALTER TABLE ${key} ALTER COLUMN "${column12.name}" DROP IDENTITY;`);
|
|
39042
39047
|
} else {
|
|
@@ -39377,7 +39382,6 @@ var init_convertor = __esm({
|
|
|
39377
39382
|
renameViewConvertor,
|
|
39378
39383
|
moveViewConvertor,
|
|
39379
39384
|
alterViewConvertor,
|
|
39380
|
-
recreateViewConvertor,
|
|
39381
39385
|
createTableConvertor,
|
|
39382
39386
|
dropTableConvertor,
|
|
39383
39387
|
renameTableConvertor,
|
|
@@ -40283,11 +40287,15 @@ var init_diff = __esm({
|
|
|
40283
40287
|
return ddl22.columns.hasDiff(it2);
|
|
40284
40288
|
}).map((it2) => {
|
|
40285
40289
|
const column12 = it2.$right;
|
|
40290
|
+
const wasSerial = isSerialType(it2.$left.type);
|
|
40291
|
+
const isEnum = ddl22.enums.one({ schema: column12.typeSchema ?? "public", name: column12.type }) !== null;
|
|
40292
|
+
const wasEnum = (it2.type && ddl1.enums.one({ schema: column12.typeSchema ?? "public", name: it2.type.from }) !== null) ?? false;
|
|
40286
40293
|
return prepareStatement("alter_column", {
|
|
40287
40294
|
diff: it2,
|
|
40288
|
-
|
|
40289
|
-
|
|
40290
|
-
|
|
40295
|
+
to: column12,
|
|
40296
|
+
isEnum,
|
|
40297
|
+
wasEnum,
|
|
40298
|
+
wasSerial
|
|
40291
40299
|
});
|
|
40292
40300
|
});
|
|
40293
40301
|
const createSequences = createdSequences.map((it2) => prepareStatement("create_sequence", { sequence: it2 }));
|
|
@@ -40314,7 +40322,7 @@ var init_diff = __esm({
|
|
|
40314
40322
|
const renameSchemas = renamedSchemas.map((it2) => prepareStatement("rename_schema", it2));
|
|
40315
40323
|
const createTables = createdTables.map((it2) => prepareStatement("create_table", { table: tableFromDDL3(it2, ddl22) }));
|
|
40316
40324
|
const createViews = createdViews.map((it2) => prepareStatement("create_view", { view: it2 }));
|
|
40317
|
-
const jsonDropViews = deletedViews.map((it2) => prepareStatement("drop_view", { view: it2 }));
|
|
40325
|
+
const jsonDropViews = deletedViews.map((it2) => prepareStatement("drop_view", { view: it2, cause: null }));
|
|
40318
40326
|
const jsonRenameViews = renamedViews.map((it2) => prepareStatement("rename_view", it2));
|
|
40319
40327
|
const jsonMoveViews = movedViews.map(
|
|
40320
40328
|
(it2) => prepareStatement("move_view", { fromSchema: it2.from.schema, toSchema: it2.to.schema, view: it2.to })
|
|
@@ -40339,7 +40347,7 @@ var init_diff = __esm({
|
|
|
40339
40347
|
view: it2.view
|
|
40340
40348
|
});
|
|
40341
40349
|
});
|
|
40342
|
-
|
|
40350
|
+
viewsAlters.filter((it2) => it2.diff.definition).forEach((entry) => {
|
|
40343
40351
|
const it2 = entry.view;
|
|
40344
40352
|
const schemaRename = renamedSchemas.find((r6) => r6.to.name === it2.schema);
|
|
40345
40353
|
const schema6 = schemaRename ? schemaRename.from.name : it2.schema;
|
|
@@ -40353,7 +40361,8 @@ var init_diff = __esm({
|
|
|
40353
40361
|
${schema6}:${name}
|
|
40354
40362
|
`);
|
|
40355
40363
|
}
|
|
40356
|
-
|
|
40364
|
+
jsonDropViews.push(prepareStatement("drop_view", { view: it2, cause: from }));
|
|
40365
|
+
createViews.push(prepareStatement("create_view", { view: it2 }));
|
|
40357
40366
|
});
|
|
40358
40367
|
const columnsToRecreate = columnAlters.filter((it2) => it2.generated && it2.generated.to !== null).filter((it2) => {
|
|
40359
40368
|
var _a5;
|
|
@@ -40405,7 +40414,6 @@ var init_diff = __esm({
|
|
|
40405
40414
|
jsonStatements.push(...jsonDropViews);
|
|
40406
40415
|
jsonStatements.push(...jsonRenameViews);
|
|
40407
40416
|
jsonStatements.push(...jsonMoveViews);
|
|
40408
|
-
jsonStatements.push(...jsonRecreateViews);
|
|
40409
40417
|
jsonStatements.push(...jsonAlterViews);
|
|
40410
40418
|
jsonStatements.push(...jsonRenameTables);
|
|
40411
40419
|
jsonStatements.push(...jsonDropPoliciesStatements);
|
|
@@ -45155,7 +45163,7 @@ function fromJson5(statements) {
|
|
|
45155
45163
|
};
|
|
45156
45164
|
return result2;
|
|
45157
45165
|
}
|
|
45158
|
-
var convertor5, createSchemaConvertor2, dropSchemaConvertor2, renameSchemaConvertor2, createViewConvertor2, dropViewConvertor2, renameViewConvertor2, moveViewConvertor2,
|
|
45166
|
+
var convertor5, createSchemaConvertor2, dropSchemaConvertor2, renameSchemaConvertor2, createViewConvertor2, dropViewConvertor2, renameViewConvertor2, moveViewConvertor2, recreateViewConvertor, createTableConvertor2, dropTableConvertor2, renameTableConvertor2, moveTableConvertor2, addColumnConvertor2, dropColumnConvertor2, renameColumnConvertor2, recreateColumnConvertor2, alterColumnConvertor2, alterColumnAddNotNullConvertor, alterColumnDropNotNullConvertor, createIndexConvertor2, dropIndexConvertor2, recreateIndexConvertor2, renameIndexConvertor2, addPrimaryKeyConvertor2, dropPrimaryKeyConvertor2, alterPrimaryKeyConvertor, recreatePrimaryKeyConvertor2, renameConstraintConvertor2, createForeignKeyConvertor2, recreateFKConvertor2, dropForeignKeyConvertor2, addCheckConvertor2, dropCheckConvertor2, recreateCheckConvertor2, createEnumConvertor2, dropEnumConvertor2, renameEnumConvertor2, moveEnumConvertor2, alterEnumConvertor2, recreateEnumConvertor2, createSequenceConvertor2, dropSequenceConvertor2, renameSequenceConvertor2, moveSequenceConvertor2, alterSequenceConvertor2, createRoleConvertor2, dropRoleConvertor2, alterRoleConvertor2, createPolicyConvertor2, dropPolicyConvertor2, renamePolicyConvertor2, alterPolicyConvertor2, recreatePolicy2, toggleRlsConvertor2, convertors5;
|
|
45159
45167
|
var init_convertor5 = __esm({
|
|
45160
45168
|
"src/dialects/cockroach/convertor.ts"() {
|
|
45161
45169
|
"use strict";
|
|
@@ -45206,7 +45214,7 @@ var init_convertor5 = __esm({
|
|
|
45206
45214
|
const from = fromSchema === "public" ? `"${view6.name}"` : `"${fromSchema}"."${view6.name}"`;
|
|
45207
45215
|
return `ALTER${view6.materialized ? " MATERIALIZED" : ""} VIEW ${from} SET SCHEMA "${toSchema}";`;
|
|
45208
45216
|
});
|
|
45209
|
-
|
|
45217
|
+
recreateViewConvertor = convertor5("recreate_view", (st2) => {
|
|
45210
45218
|
const drop = dropViewConvertor2.convert({ view: st2.from });
|
|
45211
45219
|
const create2 = createViewConvertor2.convert({ view: st2.to });
|
|
45212
45220
|
return [drop, create2];
|
|
@@ -45639,7 +45647,7 @@ var init_convertor5 = __esm({
|
|
|
45639
45647
|
dropViewConvertor2,
|
|
45640
45648
|
renameViewConvertor2,
|
|
45641
45649
|
moveViewConvertor2,
|
|
45642
|
-
|
|
45650
|
+
recreateViewConvertor,
|
|
45643
45651
|
createTableConvertor2,
|
|
45644
45652
|
dropTableConvertor2,
|
|
45645
45653
|
renameTableConvertor2,
|
|
@@ -169553,12 +169561,6 @@ var init_introspect2 = __esm({
|
|
|
169553
169561
|
values: it2.values
|
|
169554
169562
|
});
|
|
169555
169563
|
}
|
|
169556
|
-
let columnsCount = 0;
|
|
169557
|
-
let indexesCount = 0;
|
|
169558
|
-
let foreignKeysCount = 0;
|
|
169559
|
-
let tableCount = 0;
|
|
169560
|
-
let checksCount = 0;
|
|
169561
|
-
let viewsCount = 0;
|
|
169562
169564
|
for (const seq of sequencesList) {
|
|
169563
169565
|
const depend = dependList.find((it2) => it2.oid === seq.oid);
|
|
169564
169566
|
if (depend && (depend.deptype === "a" || depend.deptype === "i")) {
|
|
@@ -169576,7 +169578,6 @@ var init_introspect2 = __esm({
|
|
|
169576
169578
|
cacheSize: Number(stringFromDatabaseIdentityProperty(seq.cacheSize) ?? 1)
|
|
169577
169579
|
});
|
|
169578
169580
|
}
|
|
169579
|
-
progressCallback("enums", Object.keys(groupedEnums).length, "done");
|
|
169580
169581
|
for (const dbRole of rolesList) {
|
|
169581
169582
|
roles.push({
|
|
169582
169583
|
entityType: "roles",
|
|
@@ -169619,7 +169620,6 @@ var init_introspect2 = __esm({
|
|
|
169619
169620
|
withCheck: it2.withCheck ?? null
|
|
169620
169621
|
});
|
|
169621
169622
|
}
|
|
169622
|
-
progressCallback("policies", policiesList.length, "done");
|
|
169623
169623
|
for (const column12 of columnsList.filter((x6) => x6.kind === "r" || x6.kind === "p")) {
|
|
169624
169624
|
const type = column12.type;
|
|
169625
169625
|
if (!(type === "smallint" || type === "bigint" || type === "integer")) {
|
|
@@ -169898,10 +169898,6 @@ ${JSON.stringify(column12.metadata)}`
|
|
|
169898
169898
|
forPK
|
|
169899
169899
|
});
|
|
169900
169900
|
}
|
|
169901
|
-
progressCallback("columns", columnsCount, "fetching");
|
|
169902
|
-
progressCallback("checks", checksCount, "fetching");
|
|
169903
|
-
progressCallback("indexes", indexesCount, "fetching");
|
|
169904
|
-
progressCallback("tables", tableCount, "done");
|
|
169905
169901
|
for (const it2 of columnsList.filter((x6) => x6.kind === "m" || x6.kind === "v")) {
|
|
169906
169902
|
const view6 = viewsList.find((x6) => x6.oid === it2.tableId);
|
|
169907
169903
|
const typeDimensions = it2.type.split("[]").length - 1;
|
|
@@ -169925,7 +169921,6 @@ ${JSON.stringify(column12.metadata)}`
|
|
|
169925
169921
|
});
|
|
169926
169922
|
}
|
|
169927
169923
|
for (const view6 of viewsList) {
|
|
169928
|
-
tableCount += 1;
|
|
169929
169924
|
const accessMethod = view6.accessMethod === 0 ? null : ams.find((it2) => it2.oid === view6.accessMethod);
|
|
169930
169925
|
const tablespace = view6.tablespaceid === 0 ? null : tablespaces.find((it2) => it2.oid === view6.tablespaceid).name;
|
|
169931
169926
|
const definition = parseViewDefinition(view6.definition);
|
|
@@ -169977,11 +169972,14 @@ ${JSON.stringify(column12.metadata)}`
|
|
|
169977
169972
|
withNoData: null
|
|
169978
169973
|
});
|
|
169979
169974
|
}
|
|
169980
|
-
progressCallback("
|
|
169981
|
-
progressCallback("
|
|
169982
|
-
progressCallback("
|
|
169983
|
-
progressCallback("
|
|
169984
|
-
progressCallback("views",
|
|
169975
|
+
progressCallback("tables", filteredTables.length, "done");
|
|
169976
|
+
progressCallback("columns", columnsList.length, "done");
|
|
169977
|
+
progressCallback("checks", checks.length, "done");
|
|
169978
|
+
progressCallback("indexes", indexes.length, "fetching");
|
|
169979
|
+
progressCallback("views", viewsList.length, "done");
|
|
169980
|
+
progressCallback("fks", fks.length, "done");
|
|
169981
|
+
progressCallback("enums", Object.keys(groupedEnums).length, "done");
|
|
169982
|
+
progressCallback("policies", policiesList.length, "done");
|
|
169985
169983
|
const resultSchemas = schemas.filter((x6) => filter2({ type: "schema", name: x6.name }));
|
|
169986
169984
|
const resultTables = tables.filter((x6) => filter2({ type: "table", schema: x6.schema, name: x6.name }));
|
|
169987
169985
|
const resultEnums = enums.filter((x6) => resultSchemas.some((s6) => s6.name === x6.schema));
|
|
@@ -170231,7 +170229,7 @@ var init_push_postgres = __esm({
|
|
|
170231
170229
|
suggestions2 = async (db, jsonStatements) => {
|
|
170232
170230
|
const grouped = [];
|
|
170233
170231
|
const filtered = jsonStatements.filter((it2) => {
|
|
170234
|
-
if (it2.type === "
|
|
170232
|
+
if (it2.type === "drop_view" && it2.cause) return false;
|
|
170235
170233
|
if (it2.type === "alter_column" && it2.diff.generated) return false;
|
|
170236
170234
|
return true;
|
|
170237
170235
|
});
|