drizzle-kit 1.0.0-beta.2-f9236e3 → 1.0.0-beta.2-2dc306e
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 +30 -25
- package/api-postgres.mjs +30 -25
- package/bin.cjs +30 -25
- package/package.json +1 -1
package/api-postgres.js
CHANGED
|
@@ -7723,10 +7723,11 @@ var init_grammar = __esm({
|
|
|
7723
7723
|
return {
|
|
7724
7724
|
bool: (key) => {
|
|
7725
7725
|
if (key in it) {
|
|
7726
|
-
|
|
7726
|
+
const value = it[key];
|
|
7727
|
+
if (value === "true" || value === "1" || value === "on" || value === "yes") {
|
|
7727
7728
|
return true;
|
|
7728
7729
|
}
|
|
7729
|
-
if (
|
|
7730
|
+
if (value === "false" || value === "0" || value === "off" || value === "no") {
|
|
7730
7731
|
return false;
|
|
7731
7732
|
}
|
|
7732
7733
|
throw new Error(`Invalid options boolean value for ${key}: ${it[key]}`);
|
|
@@ -23001,7 +23002,7 @@ var init_convertor = __esm({
|
|
|
23001
23002
|
return [drop, add];
|
|
23002
23003
|
});
|
|
23003
23004
|
alterColumnConvertor = convertor("alter_column", (st) => {
|
|
23004
|
-
const { diff: diff2, to: column8, isEnum, wasEnum } = st;
|
|
23005
|
+
const { diff: diff2, to: column8, isEnum, wasEnum, wasSerial } = st;
|
|
23005
23006
|
const statements = [];
|
|
23006
23007
|
const key = column8.schema !== "public" ? `"${column8.schema}"."${column8.table}"` : `"${column8.table}"`;
|
|
23007
23008
|
const recreateDefault = diff2.type && (isEnum || wasEnum) && (column8.default || diff2.default && diff2.default.from);
|
|
@@ -23011,13 +23012,18 @@ var init_convertor = __esm({
|
|
|
23011
23012
|
if (diff2.type) {
|
|
23012
23013
|
const typeSchema = column8.typeSchema && column8.typeSchema !== "public" ? `"${column8.typeSchema}".` : "";
|
|
23013
23014
|
const textProxy = wasEnum && isEnum ? "text::" : "";
|
|
23014
|
-
const suffix = isEnum ? ` USING "${column8.name}"::${textProxy}${typeSchema}"${column8.type}"${"[]".repeat(column8.dimensions)}` : ""
|
|
23015
|
+
const suffix = isEnum ? ` USING "${column8.name}"::${textProxy}${typeSchema}"${column8.type}"${"[]".repeat(column8.dimensions)}` : ` USING "${column8.name}"::${column8.type}${"[]".repeat(column8.dimensions)}`;
|
|
23015
23016
|
let type;
|
|
23016
23017
|
if (diff2.type) {
|
|
23017
23018
|
type = diff2.typeSchema?.to && diff2.typeSchema.to !== "public" ? `"${diff2.typeSchema.to}"."${diff2.type.to}"` : isEnum ? `"${diff2.type.to}"` : diff2.type.to;
|
|
23018
23019
|
} else {
|
|
23019
23020
|
type = `${typeSchema}${column8.typeSchema ? `"${column8.type}"` : column8.type}`;
|
|
23020
23021
|
}
|
|
23022
|
+
if (wasSerial) {
|
|
23023
|
+
statements.push(`ALTER TABLE ${key} ALTER COLUMN "${column8.name}" DROP DEFAULT`);
|
|
23024
|
+
const sequenceKey = column8.schema !== "public" ? `"${column8.schema}"."${column8.table}_${column8.name}_seq"` : `"${column8.table}_${column8.name}_seq"`;
|
|
23025
|
+
statements.push(`DROP SEQUENCE ${sequenceKey}`);
|
|
23026
|
+
}
|
|
23021
23027
|
statements.push(
|
|
23022
23028
|
`ALTER TABLE ${key} ALTER COLUMN "${column8.name}" SET DATA TYPE ${type}${"[]".repeat(column8.dimensions)}${suffix};`
|
|
23023
23029
|
);
|
|
@@ -23052,6 +23058,11 @@ var init_convertor = __esm({
|
|
|
23052
23058
|
const cycle = identity.cycle ? ` CYCLE` : "";
|
|
23053
23059
|
const identityStatement = `GENERATED ${typeClause} AS IDENTITY (sequence name ${identityWithSchema}${incrementClause}${minClause}${maxClause}${startWith}${cache6}${cycle})`;
|
|
23054
23060
|
statements.push(`ALTER TABLE ${key} ALTER COLUMN "${column8.name}" ADD ${identityStatement};`);
|
|
23061
|
+
if (wasSerial && column8.identity) {
|
|
23062
|
+
statements.push(
|
|
23063
|
+
`SELECT setval('${column8.identity.name}'::regclass, (SELECT COALESCE(MAX(id), 1) FROM ${key}), false);`
|
|
23064
|
+
);
|
|
23065
|
+
}
|
|
23055
23066
|
} else if (diff2.identity.to === null) {
|
|
23056
23067
|
statements.push(`ALTER TABLE ${key} ALTER COLUMN "${column8.name}" DROP IDENTITY;`);
|
|
23057
23068
|
} else {
|
|
@@ -24297,11 +24308,15 @@ var init_diff = __esm({
|
|
|
24297
24308
|
return ddl22.columns.hasDiff(it);
|
|
24298
24309
|
}).map((it) => {
|
|
24299
24310
|
const column8 = it.$right;
|
|
24311
|
+
const wasSerial = isSerialType(it.$left.type);
|
|
24312
|
+
const isEnum = ddl22.enums.one({ schema: column8.typeSchema ?? "public", name: column8.type }) !== null;
|
|
24313
|
+
const wasEnum = (it.type && ddl1.enums.one({ schema: column8.typeSchema ?? "public", name: it.type.from }) !== null) ?? false;
|
|
24300
24314
|
return prepareStatement("alter_column", {
|
|
24301
24315
|
diff: it,
|
|
24302
|
-
|
|
24303
|
-
|
|
24304
|
-
|
|
24316
|
+
to: column8,
|
|
24317
|
+
isEnum,
|
|
24318
|
+
wasEnum,
|
|
24319
|
+
wasSerial
|
|
24305
24320
|
});
|
|
24306
24321
|
});
|
|
24307
24322
|
const createSequences = createdSequences.map((it) => prepareStatement("create_sequence", { sequence: it }));
|
|
@@ -24982,12 +24997,6 @@ var init_introspect = __esm({
|
|
|
24982
24997
|
values: it.values
|
|
24983
24998
|
});
|
|
24984
24999
|
}
|
|
24985
|
-
let columnsCount = 0;
|
|
24986
|
-
let indexesCount = 0;
|
|
24987
|
-
let foreignKeysCount = 0;
|
|
24988
|
-
let tableCount = 0;
|
|
24989
|
-
let checksCount = 0;
|
|
24990
|
-
let viewsCount = 0;
|
|
24991
25000
|
for (const seq of sequencesList) {
|
|
24992
25001
|
const depend = dependList.find((it) => it.oid === seq.oid);
|
|
24993
25002
|
if (depend && (depend.deptype === "a" || depend.deptype === "i")) {
|
|
@@ -25005,7 +25014,6 @@ var init_introspect = __esm({
|
|
|
25005
25014
|
cacheSize: Number(stringFromDatabaseIdentityProperty(seq.cacheSize) ?? 1)
|
|
25006
25015
|
});
|
|
25007
25016
|
}
|
|
25008
|
-
progressCallback("enums", Object.keys(groupedEnums).length, "done");
|
|
25009
25017
|
for (const dbRole of rolesList) {
|
|
25010
25018
|
roles.push({
|
|
25011
25019
|
entityType: "roles",
|
|
@@ -25048,7 +25056,6 @@ var init_introspect = __esm({
|
|
|
25048
25056
|
withCheck: it.withCheck ?? null
|
|
25049
25057
|
});
|
|
25050
25058
|
}
|
|
25051
|
-
progressCallback("policies", policiesList.length, "done");
|
|
25052
25059
|
for (const column8 of columnsList.filter((x6) => x6.kind === "r" || x6.kind === "p")) {
|
|
25053
25060
|
const type = column8.type;
|
|
25054
25061
|
if (!(type === "smallint" || type === "bigint" || type === "integer")) {
|
|
@@ -25327,10 +25334,6 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25327
25334
|
forPK
|
|
25328
25335
|
});
|
|
25329
25336
|
}
|
|
25330
|
-
progressCallback("columns", columnsCount, "fetching");
|
|
25331
|
-
progressCallback("checks", checksCount, "fetching");
|
|
25332
|
-
progressCallback("indexes", indexesCount, "fetching");
|
|
25333
|
-
progressCallback("tables", tableCount, "done");
|
|
25334
25337
|
for (const it of columnsList.filter((x6) => x6.kind === "m" || x6.kind === "v")) {
|
|
25335
25338
|
const view6 = viewsList.find((x6) => x6.oid === it.tableId);
|
|
25336
25339
|
const typeDimensions = it.type.split("[]").length - 1;
|
|
@@ -25354,7 +25357,6 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25354
25357
|
});
|
|
25355
25358
|
}
|
|
25356
25359
|
for (const view6 of viewsList) {
|
|
25357
|
-
tableCount += 1;
|
|
25358
25360
|
const accessMethod = view6.accessMethod === 0 ? null : ams.find((it) => it.oid === view6.accessMethod);
|
|
25359
25361
|
const tablespace = view6.tablespaceid === 0 ? null : tablespaces.find((it) => it.oid === view6.tablespaceid).name;
|
|
25360
25362
|
const definition = parseViewDefinition(view6.definition);
|
|
@@ -25406,11 +25408,14 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25406
25408
|
withNoData: null
|
|
25407
25409
|
});
|
|
25408
25410
|
}
|
|
25409
|
-
progressCallback("
|
|
25410
|
-
progressCallback("
|
|
25411
|
-
progressCallback("
|
|
25412
|
-
progressCallback("
|
|
25413
|
-
progressCallback("views",
|
|
25411
|
+
progressCallback("tables", filteredTables.length, "done");
|
|
25412
|
+
progressCallback("columns", columnsList.length, "done");
|
|
25413
|
+
progressCallback("checks", checks.length, "done");
|
|
25414
|
+
progressCallback("indexes", indexes.length, "fetching");
|
|
25415
|
+
progressCallback("views", viewsList.length, "done");
|
|
25416
|
+
progressCallback("fks", fks.length, "done");
|
|
25417
|
+
progressCallback("enums", Object.keys(groupedEnums).length, "done");
|
|
25418
|
+
progressCallback("policies", policiesList.length, "done");
|
|
25414
25419
|
const resultSchemas = schemas.filter((x6) => filter2({ type: "schema", name: x6.name }));
|
|
25415
25420
|
const resultTables = tables.filter((x6) => filter2({ type: "table", schema: x6.schema, name: x6.name }));
|
|
25416
25421
|
const resultEnums = enums.filter((x6) => resultSchemas.some((s7) => s7.name === x6.schema));
|
package/api-postgres.mjs
CHANGED
|
@@ -7729,10 +7729,11 @@ var init_grammar = __esm({
|
|
|
7729
7729
|
return {
|
|
7730
7730
|
bool: (key) => {
|
|
7731
7731
|
if (key in it) {
|
|
7732
|
-
|
|
7732
|
+
const value = it[key];
|
|
7733
|
+
if (value === "true" || value === "1" || value === "on" || value === "yes") {
|
|
7733
7734
|
return true;
|
|
7734
7735
|
}
|
|
7735
|
-
if (
|
|
7736
|
+
if (value === "false" || value === "0" || value === "off" || value === "no") {
|
|
7736
7737
|
return false;
|
|
7737
7738
|
}
|
|
7738
7739
|
throw new Error(`Invalid options boolean value for ${key}: ${it[key]}`);
|
|
@@ -23037,7 +23038,7 @@ var init_convertor = __esm({
|
|
|
23037
23038
|
return [drop, add];
|
|
23038
23039
|
});
|
|
23039
23040
|
alterColumnConvertor = convertor("alter_column", (st) => {
|
|
23040
|
-
const { diff: diff2, to: column8, isEnum, wasEnum } = st;
|
|
23041
|
+
const { diff: diff2, to: column8, isEnum, wasEnum, wasSerial } = st;
|
|
23041
23042
|
const statements = [];
|
|
23042
23043
|
const key = column8.schema !== "public" ? `"${column8.schema}"."${column8.table}"` : `"${column8.table}"`;
|
|
23043
23044
|
const recreateDefault = diff2.type && (isEnum || wasEnum) && (column8.default || diff2.default && diff2.default.from);
|
|
@@ -23047,13 +23048,18 @@ var init_convertor = __esm({
|
|
|
23047
23048
|
if (diff2.type) {
|
|
23048
23049
|
const typeSchema = column8.typeSchema && column8.typeSchema !== "public" ? `"${column8.typeSchema}".` : "";
|
|
23049
23050
|
const textProxy = wasEnum && isEnum ? "text::" : "";
|
|
23050
|
-
const suffix = isEnum ? ` USING "${column8.name}"::${textProxy}${typeSchema}"${column8.type}"${"[]".repeat(column8.dimensions)}` : ""
|
|
23051
|
+
const suffix = isEnum ? ` USING "${column8.name}"::${textProxy}${typeSchema}"${column8.type}"${"[]".repeat(column8.dimensions)}` : ` USING "${column8.name}"::${column8.type}${"[]".repeat(column8.dimensions)}`;
|
|
23051
23052
|
let type;
|
|
23052
23053
|
if (diff2.type) {
|
|
23053
23054
|
type = diff2.typeSchema?.to && diff2.typeSchema.to !== "public" ? `"${diff2.typeSchema.to}"."${diff2.type.to}"` : isEnum ? `"${diff2.type.to}"` : diff2.type.to;
|
|
23054
23055
|
} else {
|
|
23055
23056
|
type = `${typeSchema}${column8.typeSchema ? `"${column8.type}"` : column8.type}`;
|
|
23056
23057
|
}
|
|
23058
|
+
if (wasSerial) {
|
|
23059
|
+
statements.push(`ALTER TABLE ${key} ALTER COLUMN "${column8.name}" DROP DEFAULT`);
|
|
23060
|
+
const sequenceKey = column8.schema !== "public" ? `"${column8.schema}"."${column8.table}_${column8.name}_seq"` : `"${column8.table}_${column8.name}_seq"`;
|
|
23061
|
+
statements.push(`DROP SEQUENCE ${sequenceKey}`);
|
|
23062
|
+
}
|
|
23057
23063
|
statements.push(
|
|
23058
23064
|
`ALTER TABLE ${key} ALTER COLUMN "${column8.name}" SET DATA TYPE ${type}${"[]".repeat(column8.dimensions)}${suffix};`
|
|
23059
23065
|
);
|
|
@@ -23088,6 +23094,11 @@ var init_convertor = __esm({
|
|
|
23088
23094
|
const cycle = identity.cycle ? ` CYCLE` : "";
|
|
23089
23095
|
const identityStatement = `GENERATED ${typeClause} AS IDENTITY (sequence name ${identityWithSchema}${incrementClause}${minClause}${maxClause}${startWith}${cache6}${cycle})`;
|
|
23090
23096
|
statements.push(`ALTER TABLE ${key} ALTER COLUMN "${column8.name}" ADD ${identityStatement};`);
|
|
23097
|
+
if (wasSerial && column8.identity) {
|
|
23098
|
+
statements.push(
|
|
23099
|
+
`SELECT setval('${column8.identity.name}'::regclass, (SELECT COALESCE(MAX(id), 1) FROM ${key}), false);`
|
|
23100
|
+
);
|
|
23101
|
+
}
|
|
23091
23102
|
} else if (diff2.identity.to === null) {
|
|
23092
23103
|
statements.push(`ALTER TABLE ${key} ALTER COLUMN "${column8.name}" DROP IDENTITY;`);
|
|
23093
23104
|
} else {
|
|
@@ -24333,11 +24344,15 @@ var init_diff = __esm({
|
|
|
24333
24344
|
return ddl22.columns.hasDiff(it);
|
|
24334
24345
|
}).map((it) => {
|
|
24335
24346
|
const column8 = it.$right;
|
|
24347
|
+
const wasSerial = isSerialType(it.$left.type);
|
|
24348
|
+
const isEnum = ddl22.enums.one({ schema: column8.typeSchema ?? "public", name: column8.type }) !== null;
|
|
24349
|
+
const wasEnum = (it.type && ddl1.enums.one({ schema: column8.typeSchema ?? "public", name: it.type.from }) !== null) ?? false;
|
|
24336
24350
|
return prepareStatement("alter_column", {
|
|
24337
24351
|
diff: it,
|
|
24338
|
-
|
|
24339
|
-
|
|
24340
|
-
|
|
24352
|
+
to: column8,
|
|
24353
|
+
isEnum,
|
|
24354
|
+
wasEnum,
|
|
24355
|
+
wasSerial
|
|
24341
24356
|
});
|
|
24342
24357
|
});
|
|
24343
24358
|
const createSequences = createdSequences.map((it) => prepareStatement("create_sequence", { sequence: it }));
|
|
@@ -25018,12 +25033,6 @@ var init_introspect = __esm({
|
|
|
25018
25033
|
values: it.values
|
|
25019
25034
|
});
|
|
25020
25035
|
}
|
|
25021
|
-
let columnsCount = 0;
|
|
25022
|
-
let indexesCount = 0;
|
|
25023
|
-
let foreignKeysCount = 0;
|
|
25024
|
-
let tableCount = 0;
|
|
25025
|
-
let checksCount = 0;
|
|
25026
|
-
let viewsCount = 0;
|
|
25027
25036
|
for (const seq of sequencesList) {
|
|
25028
25037
|
const depend = dependList.find((it) => it.oid === seq.oid);
|
|
25029
25038
|
if (depend && (depend.deptype === "a" || depend.deptype === "i")) {
|
|
@@ -25041,7 +25050,6 @@ var init_introspect = __esm({
|
|
|
25041
25050
|
cacheSize: Number(stringFromDatabaseIdentityProperty(seq.cacheSize) ?? 1)
|
|
25042
25051
|
});
|
|
25043
25052
|
}
|
|
25044
|
-
progressCallback("enums", Object.keys(groupedEnums).length, "done");
|
|
25045
25053
|
for (const dbRole of rolesList) {
|
|
25046
25054
|
roles.push({
|
|
25047
25055
|
entityType: "roles",
|
|
@@ -25084,7 +25092,6 @@ var init_introspect = __esm({
|
|
|
25084
25092
|
withCheck: it.withCheck ?? null
|
|
25085
25093
|
});
|
|
25086
25094
|
}
|
|
25087
|
-
progressCallback("policies", policiesList.length, "done");
|
|
25088
25095
|
for (const column8 of columnsList.filter((x6) => x6.kind === "r" || x6.kind === "p")) {
|
|
25089
25096
|
const type = column8.type;
|
|
25090
25097
|
if (!(type === "smallint" || type === "bigint" || type === "integer")) {
|
|
@@ -25363,10 +25370,6 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25363
25370
|
forPK
|
|
25364
25371
|
});
|
|
25365
25372
|
}
|
|
25366
|
-
progressCallback("columns", columnsCount, "fetching");
|
|
25367
|
-
progressCallback("checks", checksCount, "fetching");
|
|
25368
|
-
progressCallback("indexes", indexesCount, "fetching");
|
|
25369
|
-
progressCallback("tables", tableCount, "done");
|
|
25370
25373
|
for (const it of columnsList.filter((x6) => x6.kind === "m" || x6.kind === "v")) {
|
|
25371
25374
|
const view6 = viewsList.find((x6) => x6.oid === it.tableId);
|
|
25372
25375
|
const typeDimensions = it.type.split("[]").length - 1;
|
|
@@ -25390,7 +25393,6 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25390
25393
|
});
|
|
25391
25394
|
}
|
|
25392
25395
|
for (const view6 of viewsList) {
|
|
25393
|
-
tableCount += 1;
|
|
25394
25396
|
const accessMethod = view6.accessMethod === 0 ? null : ams.find((it) => it.oid === view6.accessMethod);
|
|
25395
25397
|
const tablespace = view6.tablespaceid === 0 ? null : tablespaces.find((it) => it.oid === view6.tablespaceid).name;
|
|
25396
25398
|
const definition = parseViewDefinition(view6.definition);
|
|
@@ -25442,11 +25444,14 @@ ${JSON.stringify(column8.metadata)}`
|
|
|
25442
25444
|
withNoData: null
|
|
25443
25445
|
});
|
|
25444
25446
|
}
|
|
25445
|
-
progressCallback("
|
|
25446
|
-
progressCallback("
|
|
25447
|
-
progressCallback("
|
|
25448
|
-
progressCallback("
|
|
25449
|
-
progressCallback("views",
|
|
25447
|
+
progressCallback("tables", filteredTables.length, "done");
|
|
25448
|
+
progressCallback("columns", columnsList.length, "done");
|
|
25449
|
+
progressCallback("checks", checks.length, "done");
|
|
25450
|
+
progressCallback("indexes", indexes.length, "fetching");
|
|
25451
|
+
progressCallback("views", viewsList.length, "done");
|
|
25452
|
+
progressCallback("fks", fks.length, "done");
|
|
25453
|
+
progressCallback("enums", Object.keys(groupedEnums).length, "done");
|
|
25454
|
+
progressCallback("policies", policiesList.length, "done");
|
|
25450
25455
|
const resultSchemas = schemas.filter((x6) => filter2({ type: "schema", name: x6.name }));
|
|
25451
25456
|
const resultTables = tables.filter((x6) => filter2({ type: "table", schema: x6.schema, name: x6.name }));
|
|
25452
25457
|
const resultEnums = enums.filter((x6) => resultSchemas.some((s7) => s7.name === x6.schema));
|
package/bin.cjs
CHANGED
|
@@ -22636,10 +22636,11 @@ var init_grammar2 = __esm({
|
|
|
22636
22636
|
return {
|
|
22637
22637
|
bool: (key) => {
|
|
22638
22638
|
if (key in it2) {
|
|
22639
|
-
|
|
22639
|
+
const value = it2[key];
|
|
22640
|
+
if (value === "true" || value === "1" || value === "on" || value === "yes") {
|
|
22640
22641
|
return true;
|
|
22641
22642
|
}
|
|
22642
|
-
if (
|
|
22643
|
+
if (value === "false" || value === "0" || value === "off" || value === "no") {
|
|
22643
22644
|
return false;
|
|
22644
22645
|
}
|
|
22645
22646
|
throw new Error(`Invalid options boolean value for ${key}: ${it2[key]}`);
|
|
@@ -38985,7 +38986,7 @@ var init_convertor = __esm({
|
|
|
38985
38986
|
});
|
|
38986
38987
|
alterColumnConvertor = convertor("alter_column", (st2) => {
|
|
38987
38988
|
var _a5;
|
|
38988
|
-
const { diff: diff2, to: column12, isEnum, wasEnum } = st2;
|
|
38989
|
+
const { diff: diff2, to: column12, isEnum, wasEnum, wasSerial } = st2;
|
|
38989
38990
|
const statements = [];
|
|
38990
38991
|
const key = column12.schema !== "public" ? `"${column12.schema}"."${column12.table}"` : `"${column12.table}"`;
|
|
38991
38992
|
const recreateDefault = diff2.type && (isEnum || wasEnum) && (column12.default || diff2.default && diff2.default.from);
|
|
@@ -38995,13 +38996,18 @@ var init_convertor = __esm({
|
|
|
38995
38996
|
if (diff2.type) {
|
|
38996
38997
|
const typeSchema = column12.typeSchema && column12.typeSchema !== "public" ? `"${column12.typeSchema}".` : "";
|
|
38997
38998
|
const textProxy = wasEnum && isEnum ? "text::" : "";
|
|
38998
|
-
const suffix = isEnum ? ` USING "${column12.name}"::${textProxy}${typeSchema}"${column12.type}"${"[]".repeat(column12.dimensions)}` : ""
|
|
38999
|
+
const suffix = isEnum ? ` USING "${column12.name}"::${textProxy}${typeSchema}"${column12.type}"${"[]".repeat(column12.dimensions)}` : ` USING "${column12.name}"::${column12.type}${"[]".repeat(column12.dimensions)}`;
|
|
38999
39000
|
let type;
|
|
39000
39001
|
if (diff2.type) {
|
|
39001
39002
|
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;
|
|
39002
39003
|
} else {
|
|
39003
39004
|
type = `${typeSchema}${column12.typeSchema ? `"${column12.type}"` : column12.type}`;
|
|
39004
39005
|
}
|
|
39006
|
+
if (wasSerial) {
|
|
39007
|
+
statements.push(`ALTER TABLE ${key} ALTER COLUMN "${column12.name}" DROP DEFAULT`);
|
|
39008
|
+
const sequenceKey = column12.schema !== "public" ? `"${column12.schema}"."${column12.table}_${column12.name}_seq"` : `"${column12.table}_${column12.name}_seq"`;
|
|
39009
|
+
statements.push(`DROP SEQUENCE ${sequenceKey}`);
|
|
39010
|
+
}
|
|
39005
39011
|
statements.push(
|
|
39006
39012
|
`ALTER TABLE ${key} ALTER COLUMN "${column12.name}" SET DATA TYPE ${type}${"[]".repeat(column12.dimensions)}${suffix};`
|
|
39007
39013
|
);
|
|
@@ -39036,6 +39042,11 @@ var init_convertor = __esm({
|
|
|
39036
39042
|
const cycle = identity.cycle ? ` CYCLE` : "";
|
|
39037
39043
|
const identityStatement = `GENERATED ${typeClause} AS IDENTITY (sequence name ${identityWithSchema}${incrementClause}${minClause}${maxClause}${startWith}${cache4}${cycle})`;
|
|
39038
39044
|
statements.push(`ALTER TABLE ${key} ALTER COLUMN "${column12.name}" ADD ${identityStatement};`);
|
|
39045
|
+
if (wasSerial && column12.identity) {
|
|
39046
|
+
statements.push(
|
|
39047
|
+
`SELECT setval('${column12.identity.name}'::regclass, (SELECT COALESCE(MAX(id), 1) FROM ${key}), false);`
|
|
39048
|
+
);
|
|
39049
|
+
}
|
|
39039
39050
|
} else if (diff2.identity.to === null) {
|
|
39040
39051
|
statements.push(`ALTER TABLE ${key} ALTER COLUMN "${column12.name}" DROP IDENTITY;`);
|
|
39041
39052
|
} else {
|
|
@@ -40282,11 +40293,15 @@ var init_diff = __esm({
|
|
|
40282
40293
|
return ddl22.columns.hasDiff(it2);
|
|
40283
40294
|
}).map((it2) => {
|
|
40284
40295
|
const column12 = it2.$right;
|
|
40296
|
+
const wasSerial = isSerialType(it2.$left.type);
|
|
40297
|
+
const isEnum = ddl22.enums.one({ schema: column12.typeSchema ?? "public", name: column12.type }) !== null;
|
|
40298
|
+
const wasEnum = (it2.type && ddl1.enums.one({ schema: column12.typeSchema ?? "public", name: it2.type.from }) !== null) ?? false;
|
|
40285
40299
|
return prepareStatement("alter_column", {
|
|
40286
40300
|
diff: it2,
|
|
40287
|
-
|
|
40288
|
-
|
|
40289
|
-
|
|
40301
|
+
to: column12,
|
|
40302
|
+
isEnum,
|
|
40303
|
+
wasEnum,
|
|
40304
|
+
wasSerial
|
|
40290
40305
|
});
|
|
40291
40306
|
});
|
|
40292
40307
|
const createSequences = createdSequences.map((it2) => prepareStatement("create_sequence", { sequence: it2 }));
|
|
@@ -169552,12 +169567,6 @@ var init_introspect2 = __esm({
|
|
|
169552
169567
|
values: it2.values
|
|
169553
169568
|
});
|
|
169554
169569
|
}
|
|
169555
|
-
let columnsCount = 0;
|
|
169556
|
-
let indexesCount = 0;
|
|
169557
|
-
let foreignKeysCount = 0;
|
|
169558
|
-
let tableCount = 0;
|
|
169559
|
-
let checksCount = 0;
|
|
169560
|
-
let viewsCount = 0;
|
|
169561
169570
|
for (const seq of sequencesList) {
|
|
169562
169571
|
const depend = dependList.find((it2) => it2.oid === seq.oid);
|
|
169563
169572
|
if (depend && (depend.deptype === "a" || depend.deptype === "i")) {
|
|
@@ -169575,7 +169584,6 @@ var init_introspect2 = __esm({
|
|
|
169575
169584
|
cacheSize: Number(stringFromDatabaseIdentityProperty(seq.cacheSize) ?? 1)
|
|
169576
169585
|
});
|
|
169577
169586
|
}
|
|
169578
|
-
progressCallback("enums", Object.keys(groupedEnums).length, "done");
|
|
169579
169587
|
for (const dbRole of rolesList) {
|
|
169580
169588
|
roles.push({
|
|
169581
169589
|
entityType: "roles",
|
|
@@ -169618,7 +169626,6 @@ var init_introspect2 = __esm({
|
|
|
169618
169626
|
withCheck: it2.withCheck ?? null
|
|
169619
169627
|
});
|
|
169620
169628
|
}
|
|
169621
|
-
progressCallback("policies", policiesList.length, "done");
|
|
169622
169629
|
for (const column12 of columnsList.filter((x6) => x6.kind === "r" || x6.kind === "p")) {
|
|
169623
169630
|
const type = column12.type;
|
|
169624
169631
|
if (!(type === "smallint" || type === "bigint" || type === "integer")) {
|
|
@@ -169897,10 +169904,6 @@ ${JSON.stringify(column12.metadata)}`
|
|
|
169897
169904
|
forPK
|
|
169898
169905
|
});
|
|
169899
169906
|
}
|
|
169900
|
-
progressCallback("columns", columnsCount, "fetching");
|
|
169901
|
-
progressCallback("checks", checksCount, "fetching");
|
|
169902
|
-
progressCallback("indexes", indexesCount, "fetching");
|
|
169903
|
-
progressCallback("tables", tableCount, "done");
|
|
169904
169907
|
for (const it2 of columnsList.filter((x6) => x6.kind === "m" || x6.kind === "v")) {
|
|
169905
169908
|
const view6 = viewsList.find((x6) => x6.oid === it2.tableId);
|
|
169906
169909
|
const typeDimensions = it2.type.split("[]").length - 1;
|
|
@@ -169924,7 +169927,6 @@ ${JSON.stringify(column12.metadata)}`
|
|
|
169924
169927
|
});
|
|
169925
169928
|
}
|
|
169926
169929
|
for (const view6 of viewsList) {
|
|
169927
|
-
tableCount += 1;
|
|
169928
169930
|
const accessMethod = view6.accessMethod === 0 ? null : ams.find((it2) => it2.oid === view6.accessMethod);
|
|
169929
169931
|
const tablespace = view6.tablespaceid === 0 ? null : tablespaces.find((it2) => it2.oid === view6.tablespaceid).name;
|
|
169930
169932
|
const definition = parseViewDefinition(view6.definition);
|
|
@@ -169976,11 +169978,14 @@ ${JSON.stringify(column12.metadata)}`
|
|
|
169976
169978
|
withNoData: null
|
|
169977
169979
|
});
|
|
169978
169980
|
}
|
|
169979
|
-
progressCallback("
|
|
169980
|
-
progressCallback("
|
|
169981
|
-
progressCallback("
|
|
169982
|
-
progressCallback("
|
|
169983
|
-
progressCallback("views",
|
|
169981
|
+
progressCallback("tables", filteredTables.length, "done");
|
|
169982
|
+
progressCallback("columns", columnsList.length, "done");
|
|
169983
|
+
progressCallback("checks", checks.length, "done");
|
|
169984
|
+
progressCallback("indexes", indexes.length, "fetching");
|
|
169985
|
+
progressCallback("views", viewsList.length, "done");
|
|
169986
|
+
progressCallback("fks", fks.length, "done");
|
|
169987
|
+
progressCallback("enums", Object.keys(groupedEnums).length, "done");
|
|
169988
|
+
progressCallback("policies", policiesList.length, "done");
|
|
169984
169989
|
const resultSchemas = schemas.filter((x6) => filter2({ type: "schema", name: x6.name }));
|
|
169985
169990
|
const resultTables = tables.filter((x6) => filter2({ type: "table", schema: x6.schema, name: x6.name }));
|
|
169986
169991
|
const resultEnums = enums.filter((x6) => resultSchemas.some((s6) => s6.name === x6.schema));
|