drizzle-kit 0.20.17-c057923 → 0.20.17-c8aaf94
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/@types/utils.d.ts +1 -0
- package/bin.cjs +116 -184
- package/cli/validations/cli.d.ts +4 -4
- package/cli/views.d.ts +1 -0
- package/package.json +1 -1
- package/payload.js +30 -11
- package/payload.mjs +30 -11
- package/utils-studio.js +3 -0
- package/utils-studio.mjs +3 -0
package/@types/utils.d.ts
CHANGED
package/bin.cjs
CHANGED
|
@@ -1076,7 +1076,7 @@ var require_hanji = __commonJS({
|
|
|
1076
1076
|
});
|
|
1077
1077
|
|
|
1078
1078
|
// src/cli/views.ts
|
|
1079
|
-
var import_hanji, err, info, error, schema, isRenamePromptItem, ResolveColumnSelect, tableKey, ResolveSelect, ResolveSchemasSelect, Spinner, IntrospectProgress, DropMigrationView, trimmedRange;
|
|
1079
|
+
var import_hanji, err, info, grey, error, schema, isRenamePromptItem, ResolveColumnSelect, tableKey, ResolveSelect, ResolveSchemasSelect, Spinner, IntrospectProgress, DropMigrationView, trimmedRange;
|
|
1080
1080
|
var init_views = __esm({
|
|
1081
1081
|
"src/cli/views.ts"() {
|
|
1082
1082
|
"use strict";
|
|
@@ -1089,6 +1089,9 @@ var init_views = __esm({
|
|
|
1089
1089
|
info = (msg, greyMsg = "") => {
|
|
1090
1090
|
return `${source_default.blue.bold("Info:")} ${msg} ${greyMsg ? source_default.grey(greyMsg) : ""}`.trim();
|
|
1091
1091
|
};
|
|
1092
|
+
grey = (msg) => {
|
|
1093
|
+
return source_default.grey(msg);
|
|
1094
|
+
};
|
|
1092
1095
|
error = (error2, greyMsg = "") => {
|
|
1093
1096
|
return `${source_default.red.bold("Err:")} ${error2} ${greyMsg ? source_default.grey(greyMsg) : ""}`.trim();
|
|
1094
1097
|
};
|
|
@@ -1339,14 +1342,14 @@ Is ${source_default.bold.blue(
|
|
|
1339
1342
|
this.requestLayout();
|
|
1340
1343
|
}
|
|
1341
1344
|
render() {
|
|
1342
|
-
let
|
|
1345
|
+
let info4 = "";
|
|
1343
1346
|
const spin = this.spinner.value();
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
return
|
|
1347
|
+
info4 += this.statusText(spin, this.state.tables);
|
|
1348
|
+
info4 += this.statusText(spin, this.state.columns);
|
|
1349
|
+
info4 += this.statusText(spin, this.state.enums);
|
|
1350
|
+
info4 += this.statusText(spin, this.state.indexes);
|
|
1351
|
+
info4 += this.statusText(spin, this.state.fks);
|
|
1352
|
+
return info4;
|
|
1350
1353
|
}
|
|
1351
1354
|
};
|
|
1352
1355
|
DropMigrationView = class extends import_hanji.Prompt {
|
|
@@ -8320,6 +8323,9 @@ var init_utils3 = __esm({
|
|
|
8320
8323
|
String.prototype.camelCase = function() {
|
|
8321
8324
|
return camelCase(String(this));
|
|
8322
8325
|
};
|
|
8326
|
+
String.prototype.capitalise = function() {
|
|
8327
|
+
return this && this.length > 0 ? `${this[0].toUpperCase()}${this.slice(1)}` : String(this);
|
|
8328
|
+
};
|
|
8323
8329
|
String.prototype.concatIf = function(it, condition) {
|
|
8324
8330
|
return condition ? `${this}${it}` : String(this);
|
|
8325
8331
|
};
|
|
@@ -8661,7 +8667,7 @@ var init_cli = __esm({
|
|
|
8661
8667
|
dialect: dialect3,
|
|
8662
8668
|
schema: unionType([stringType(), stringType().array()]).optional(),
|
|
8663
8669
|
tablesFilter: unionType([stringType(), stringType().array()]).optional(),
|
|
8664
|
-
|
|
8670
|
+
schemaFilter: unionType([stringType(), stringType().array()]).optional().default(["public"]),
|
|
8665
8671
|
driver: stringType().optional(),
|
|
8666
8672
|
// pg
|
|
8667
8673
|
connectionString: stringType().optional(),
|
|
@@ -8700,7 +8706,7 @@ var init_cli = __esm({
|
|
|
8700
8706
|
authToken: stringType().optional(),
|
|
8701
8707
|
introspectCasing: casing,
|
|
8702
8708
|
breakpoints: booleanType().optional().default(true)
|
|
8703
|
-
});
|
|
8709
|
+
}).passthrough();
|
|
8704
8710
|
configCheck = objectType({
|
|
8705
8711
|
dialect: dialect3.optional(),
|
|
8706
8712
|
out: stringType().optional()
|
|
@@ -11743,13 +11749,13 @@ var require_node2 = __commonJS({
|
|
|
11743
11749
|
}
|
|
11744
11750
|
function asyncGeneratorStep(gen, resolve2, reject, _next, _throw, key, arg) {
|
|
11745
11751
|
try {
|
|
11746
|
-
var
|
|
11747
|
-
var value =
|
|
11752
|
+
var info4 = gen[key](arg);
|
|
11753
|
+
var value = info4.value;
|
|
11748
11754
|
} catch (error2) {
|
|
11749
11755
|
reject(error2);
|
|
11750
11756
|
return;
|
|
11751
11757
|
}
|
|
11752
|
-
if (
|
|
11758
|
+
if (info4.done) {
|
|
11753
11759
|
resolve2(value);
|
|
11754
11760
|
} else {
|
|
11755
11761
|
Promise.resolve(value).then(_next, _throw);
|
|
@@ -14475,7 +14481,7 @@ var init_utils4 = __esm({
|
|
|
14475
14481
|
}
|
|
14476
14482
|
const tablesFilterConfig = config.tablesFilter;
|
|
14477
14483
|
const tablesFilter = tablesFilterConfig ? typeof tablesFilterConfig === "string" ? [tablesFilterConfig] : tablesFilterConfig : [];
|
|
14478
|
-
const schemasFilterConfig = config.
|
|
14484
|
+
const schemasFilterConfig = config.schemaFilter;
|
|
14479
14485
|
const schemasFilter = schemasFilterConfig ? typeof schemasFilterConfig === "string" ? [schemasFilterConfig] : schemasFilterConfig : [];
|
|
14480
14486
|
if (dialect7 === "postgresql") {
|
|
14481
14487
|
const parsed = postgresCredentials.safeParse(config);
|
|
@@ -19673,7 +19679,7 @@ var init_snapshotsDiffer = __esm({
|
|
|
19673
19679
|
const jsonTableAlternations = alteredTables.map((it) => {
|
|
19674
19680
|
return preparePgAlterColumns(it.name, it.schema, it.altered, json2);
|
|
19675
19681
|
}).flat();
|
|
19676
|
-
const
|
|
19682
|
+
const jsonCreateIndexesFoAlteredTables = alteredTables.map((it) => {
|
|
19677
19683
|
return prepareCreateIndexesJson(
|
|
19678
19684
|
it.name,
|
|
19679
19685
|
it.schema,
|
|
@@ -19702,14 +19708,21 @@ var init_snapshotsDiffer = __esm({
|
|
|
19702
19708
|
},
|
|
19703
19709
|
{}
|
|
19704
19710
|
);
|
|
19705
|
-
|
|
19711
|
+
jsonCreateIndexesFoAlteredTables.push(
|
|
19706
19712
|
...prepareCreateIndexesJson(it.name, it.schema, createdIndexes || {})
|
|
19707
19713
|
);
|
|
19708
19714
|
jsonDropIndexesForAllAlteredTables.push(
|
|
19709
19715
|
...prepareDropIndexesJson(it.name, it.schema, droppedIndexes || {})
|
|
19710
19716
|
);
|
|
19711
19717
|
});
|
|
19712
|
-
const
|
|
19718
|
+
const jsonCreateReferencesForCreatedTables = createdTables.map((it) => {
|
|
19719
|
+
return prepareCreateReferencesJson(
|
|
19720
|
+
it.name,
|
|
19721
|
+
it.schema,
|
|
19722
|
+
it.foreignKeys
|
|
19723
|
+
);
|
|
19724
|
+
}).flat();
|
|
19725
|
+
const jsonReferencesForAlteredTables = alteredTables.map((it) => {
|
|
19713
19726
|
const forAdded = prepareCreateReferencesJson(
|
|
19714
19727
|
it.name,
|
|
19715
19728
|
it.schema,
|
|
@@ -19727,10 +19740,10 @@ var init_snapshotsDiffer = __esm({
|
|
|
19727
19740
|
);
|
|
19728
19741
|
return [...forAdded, ...forAltered, ...alteredFKs];
|
|
19729
19742
|
}).flat();
|
|
19730
|
-
const jsonCreatedReferencesForAlteredTables =
|
|
19743
|
+
const jsonCreatedReferencesForAlteredTables = jsonReferencesForAlteredTables.filter(
|
|
19731
19744
|
(t) => t.type === "create_reference"
|
|
19732
19745
|
);
|
|
19733
|
-
const jsonDroppedReferencesForAlteredTables =
|
|
19746
|
+
const jsonDroppedReferencesForAlteredTables = jsonReferencesForAlteredTables.filter(
|
|
19734
19747
|
(t) => t.type === "delete_reference"
|
|
19735
19748
|
);
|
|
19736
19749
|
const createEnums = createdEnums.map((it) => {
|
|
@@ -19757,7 +19770,7 @@ var init_snapshotsDiffer = __esm({
|
|
|
19757
19770
|
const dropSchemas = prepareDeleteSchemasJson(
|
|
19758
19771
|
deletedSchemas.map((it) => it.name)
|
|
19759
19772
|
);
|
|
19760
|
-
const
|
|
19773
|
+
const createTables = createdTables.map((it) => {
|
|
19761
19774
|
return preparePgCreateTableJson(it, curFull);
|
|
19762
19775
|
});
|
|
19763
19776
|
jsonStatements.push(...createSchemas);
|
|
@@ -19766,7 +19779,7 @@ var init_snapshotsDiffer = __esm({
|
|
|
19766
19779
|
jsonStatements.push(...moveEnums);
|
|
19767
19780
|
jsonStatements.push(...renameEnums);
|
|
19768
19781
|
jsonStatements.push(...jsonAlterEnumsWithAddedValues);
|
|
19769
|
-
jsonStatements.push(...
|
|
19782
|
+
jsonStatements.push(...createTables);
|
|
19770
19783
|
jsonStatements.push(...jsonDropTables);
|
|
19771
19784
|
jsonStatements.push(...jsonSetTableSchemas);
|
|
19772
19785
|
jsonStatements.push(...jsonRenameTables);
|
|
@@ -19777,9 +19790,10 @@ var init_snapshotsDiffer = __esm({
|
|
|
19777
19790
|
jsonStatements.push(...jsonTableAlternations);
|
|
19778
19791
|
jsonStatements.push(...jsonAddedCompositePKs);
|
|
19779
19792
|
jsonStatements.push(...jsonAddColumnsStatemets);
|
|
19793
|
+
jsonStatements.push(...jsonCreateReferencesForCreatedTables);
|
|
19780
19794
|
jsonStatements.push(...jsonCreateIndexesForCreatedTables);
|
|
19781
|
-
jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
|
|
19782
19795
|
jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
|
|
19796
|
+
jsonStatements.push(...jsonCreateIndexesFoAlteredTables);
|
|
19783
19797
|
jsonStatements.push(...jsonDropColumnsStatemets);
|
|
19784
19798
|
jsonStatements.push(...jsonAlteredCompositePKs);
|
|
19785
19799
|
jsonStatements.push(...jsonAlteredUniqueConstraints);
|
|
@@ -20038,6 +20052,13 @@ var init_snapshotsDiffer = __esm({
|
|
|
20038
20052
|
...prepareDropIndexesJson(it.name, it.schema, droppedIndexes || {})
|
|
20039
20053
|
);
|
|
20040
20054
|
});
|
|
20055
|
+
const jsonCreateReferencesForCreatedTables = createdTables.map((it) => {
|
|
20056
|
+
return prepareCreateReferencesJson(
|
|
20057
|
+
it.name,
|
|
20058
|
+
it.schema,
|
|
20059
|
+
it.foreignKeys
|
|
20060
|
+
);
|
|
20061
|
+
}).flat();
|
|
20041
20062
|
const jsonReferencesForAllAlteredTables = alteredTables.map((it) => {
|
|
20042
20063
|
const forAdded = prepareCreateReferencesJson(
|
|
20043
20064
|
it.name,
|
|
@@ -20078,9 +20099,10 @@ var init_snapshotsDiffer = __esm({
|
|
|
20078
20099
|
jsonStatements.push(...jsonAddedUniqueConstraints);
|
|
20079
20100
|
jsonStatements.push(...jsonDeletedUniqueConstraints);
|
|
20080
20101
|
jsonStatements.push(...jsonAddColumnsStatemets);
|
|
20102
|
+
jsonStatements.push(...jsonCreateReferencesForCreatedTables);
|
|
20081
20103
|
jsonStatements.push(...jsonCreateIndexesForCreatedTables);
|
|
20082
|
-
jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
|
|
20083
20104
|
jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
|
|
20105
|
+
jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
|
|
20084
20106
|
jsonStatements.push(...jsonDropColumnsStatemets);
|
|
20085
20107
|
jsonStatements.push(...jsonAlteredCompositePKs);
|
|
20086
20108
|
jsonStatements.push(...jsonAddedUniqueConstraints);
|
|
@@ -28283,7 +28305,7 @@ var require_partial = __commonJS({
|
|
|
28283
28305
|
match(filepath) {
|
|
28284
28306
|
const parts = filepath.split("/");
|
|
28285
28307
|
const levels = parts.length;
|
|
28286
|
-
const patterns = this._storage.filter((
|
|
28308
|
+
const patterns = this._storage.filter((info4) => !info4.complete || info4.segments.length > levels);
|
|
28287
28309
|
for (const pattern of patterns) {
|
|
28288
28310
|
const section = pattern.sections[0];
|
|
28289
28311
|
if (!pattern.complete && levels > section.length) {
|
|
@@ -36936,14 +36958,14 @@ var init_dist = __esm({
|
|
|
36936
36958
|
if (typeof global.crypto === "undefined") {
|
|
36937
36959
|
global.crypto = import_crypto2.default;
|
|
36938
36960
|
}
|
|
36939
|
-
global.fetch = (
|
|
36961
|
+
global.fetch = (info4, init2) => {
|
|
36940
36962
|
init2 = {
|
|
36941
36963
|
// Disable compression handling so people can return the result of a fetch
|
|
36942
36964
|
// directly in the loader without messing with the Content-Encoding header.
|
|
36943
36965
|
compress: false,
|
|
36944
36966
|
...init2
|
|
36945
36967
|
};
|
|
36946
|
-
return webFetch(
|
|
36968
|
+
return webFetch(info4, init2);
|
|
36947
36969
|
};
|
|
36948
36970
|
regBuffer = /^no$/i;
|
|
36949
36971
|
regContentType = /^(application\/json\b|text\/(?!event-stream\b))/i;
|
|
@@ -43593,13 +43615,13 @@ var require_websocket_server = __commonJS({
|
|
|
43593
43615
|
}
|
|
43594
43616
|
}
|
|
43595
43617
|
if (this.options.verifyClient) {
|
|
43596
|
-
const
|
|
43618
|
+
const info4 = {
|
|
43597
43619
|
origin: req.headers[`${version2 === 8 ? "sec-websocket-origin" : "origin"}`],
|
|
43598
43620
|
secure: !!(req.socket.authorized || req.socket.encrypted),
|
|
43599
43621
|
req
|
|
43600
43622
|
};
|
|
43601
43623
|
if (this.options.verifyClient.length === 2) {
|
|
43602
|
-
this.options.verifyClient(
|
|
43624
|
+
this.options.verifyClient(info4, (verified, code, message, headers) => {
|
|
43603
43625
|
if (!verified) {
|
|
43604
43626
|
return abortHandshake(socket, code || 401, message, headers);
|
|
43605
43627
|
}
|
|
@@ -43615,7 +43637,7 @@ var require_websocket_server = __commonJS({
|
|
|
43615
43637
|
});
|
|
43616
43638
|
return;
|
|
43617
43639
|
}
|
|
43618
|
-
if (!this.options.verifyClient(
|
|
43640
|
+
if (!this.options.verifyClient(info4))
|
|
43619
43641
|
return abortHandshake(socket, 401);
|
|
43620
43642
|
}
|
|
43621
43643
|
this.completeUpgrade(extensions, key, protocols, req, socket, head, cb);
|
|
@@ -83218,13 +83240,13 @@ var require_websocket_server2 = __commonJS({
|
|
|
83218
83240
|
}
|
|
83219
83241
|
}
|
|
83220
83242
|
if (this.options.verifyClient) {
|
|
83221
|
-
const
|
|
83243
|
+
const info4 = {
|
|
83222
83244
|
origin: req.headers[`${version2 === 8 ? "sec-websocket-origin" : "origin"}`],
|
|
83223
83245
|
secure: !!(req.socket.authorized || req.socket.encrypted),
|
|
83224
83246
|
req
|
|
83225
83247
|
};
|
|
83226
83248
|
if (this.options.verifyClient.length === 2) {
|
|
83227
|
-
this.options.verifyClient(
|
|
83249
|
+
this.options.verifyClient(info4, (verified, code, message, headers) => {
|
|
83228
83250
|
if (!verified) {
|
|
83229
83251
|
return abortHandshake(socket, code || 401, message, headers);
|
|
83230
83252
|
}
|
|
@@ -83240,7 +83262,7 @@ var require_websocket_server2 = __commonJS({
|
|
|
83240
83262
|
});
|
|
83241
83263
|
return;
|
|
83242
83264
|
}
|
|
83243
|
-
if (!this.options.verifyClient(
|
|
83265
|
+
if (!this.options.verifyClient(info4))
|
|
83244
83266
|
return abortHandshake(socket, 401);
|
|
83245
83267
|
}
|
|
83246
83268
|
this.completeUpgrade(extensions, key, protocols, req, socket, head, cb);
|
|
@@ -99658,7 +99680,7 @@ __export(connections_exports, {
|
|
|
99658
99680
|
connectToSQLite: () => connectToSQLite,
|
|
99659
99681
|
preparePostgresDB: () => preparePostgresDB
|
|
99660
99682
|
});
|
|
99661
|
-
var preparePostgresDB, parseMysqlCredentials, connectToMySQL, prepareSqliteParams, connectToSQLite;
|
|
99683
|
+
var import_pg_core4, preparePostgresDB, parseMysqlCredentials, connectToMySQL, prepareSqliteParams, connectToSQLite;
|
|
99662
99684
|
var init_connections = __esm({
|
|
99663
99685
|
"src/cli/connections.ts"() {
|
|
99664
99686
|
"use strict";
|
|
@@ -99666,143 +99688,37 @@ var init_connections = __esm({
|
|
|
99666
99688
|
init_utils2();
|
|
99667
99689
|
init_global();
|
|
99668
99690
|
init_outputs();
|
|
99691
|
+
import_pg_core4 = require("drizzle-orm/pg-core");
|
|
99669
99692
|
preparePostgresDB = async (credentials2) => {
|
|
99670
99693
|
if ("driver" in credentials2) {
|
|
99671
99694
|
if (credentials2.driver === "aws-data-api") {
|
|
99672
|
-
let getValueFromDataApi2 = function(field) {
|
|
99673
|
-
if (field.stringValue !== void 0) {
|
|
99674
|
-
return field.stringValue;
|
|
99675
|
-
} else if (field.booleanValue !== void 0) {
|
|
99676
|
-
return field.booleanValue;
|
|
99677
|
-
} else if (field.doubleValue !== void 0) {
|
|
99678
|
-
return field.doubleValue;
|
|
99679
|
-
} else if (field.isNull !== void 0) {
|
|
99680
|
-
return null;
|
|
99681
|
-
} else if (field.longValue !== void 0) {
|
|
99682
|
-
return field.longValue;
|
|
99683
|
-
} else if (field.blobValue !== void 0) {
|
|
99684
|
-
return field.blobValue;
|
|
99685
|
-
} else if (field.arrayValue !== void 0) {
|
|
99686
|
-
if (field.arrayValue.stringValues !== void 0) {
|
|
99687
|
-
return field.arrayValue.stringValues;
|
|
99688
|
-
}
|
|
99689
|
-
if (field.arrayValue.longValues !== void 0) {
|
|
99690
|
-
return field.arrayValue.longValues;
|
|
99691
|
-
}
|
|
99692
|
-
if (field.arrayValue.doubleValues !== void 0) {
|
|
99693
|
-
return field.arrayValue.doubleValues;
|
|
99694
|
-
}
|
|
99695
|
-
if (field.arrayValue.booleanValues !== void 0) {
|
|
99696
|
-
return field.arrayValue.booleanValues;
|
|
99697
|
-
}
|
|
99698
|
-
if (field.arrayValue.arrayValues !== void 0) {
|
|
99699
|
-
return field.arrayValue.arrayValues;
|
|
99700
|
-
}
|
|
99701
|
-
throw new Error("Unknown array type");
|
|
99702
|
-
} else {
|
|
99703
|
-
throw new Error("Unknown type");
|
|
99704
|
-
}
|
|
99705
|
-
}, typingsToAwsTypeHint2 = function(typings) {
|
|
99706
|
-
if (typings === "date") {
|
|
99707
|
-
return TypeHint.DATE;
|
|
99708
|
-
} else if (typings === "decimal") {
|
|
99709
|
-
return TypeHint.DECIMAL;
|
|
99710
|
-
} else if (typings === "json") {
|
|
99711
|
-
return TypeHint.JSON;
|
|
99712
|
-
} else if (typings === "time") {
|
|
99713
|
-
return TypeHint.TIME;
|
|
99714
|
-
} else if (typings === "timestamp") {
|
|
99715
|
-
return TypeHint.TIMESTAMP;
|
|
99716
|
-
} else if (typings === "uuid") {
|
|
99717
|
-
return TypeHint.UUID;
|
|
99718
|
-
} else {
|
|
99719
|
-
return void 0;
|
|
99720
|
-
}
|
|
99721
|
-
}, toValueParam2 = function(value, typings) {
|
|
99722
|
-
const response = {
|
|
99723
|
-
value: {},
|
|
99724
|
-
typeHint: typingsToAwsTypeHint2(typings)
|
|
99725
|
-
};
|
|
99726
|
-
if (value === null) {
|
|
99727
|
-
response.value = { isNull: true };
|
|
99728
|
-
} else if (typeof value === "string") {
|
|
99729
|
-
switch (response.typeHint) {
|
|
99730
|
-
case TypeHint.DATE: {
|
|
99731
|
-
response.value = { stringValue: value.split("T")[0] };
|
|
99732
|
-
break;
|
|
99733
|
-
}
|
|
99734
|
-
case TypeHint.TIMESTAMP: {
|
|
99735
|
-
response.value = {
|
|
99736
|
-
stringValue: value.replace("T", " ").replace("Z", "")
|
|
99737
|
-
};
|
|
99738
|
-
break;
|
|
99739
|
-
}
|
|
99740
|
-
default: {
|
|
99741
|
-
response.value = { stringValue: value };
|
|
99742
|
-
break;
|
|
99743
|
-
}
|
|
99744
|
-
}
|
|
99745
|
-
} else if (typeof value === "number" && Number.isInteger(value)) {
|
|
99746
|
-
response.value = { longValue: value };
|
|
99747
|
-
} else if (typeof value === "number" && !Number.isInteger(value)) {
|
|
99748
|
-
response.value = { doubleValue: value };
|
|
99749
|
-
} else if (typeof value === "boolean") {
|
|
99750
|
-
response.value = { booleanValue: value };
|
|
99751
|
-
} else if (value instanceof Date) {
|
|
99752
|
-
response.value = {
|
|
99753
|
-
stringValue: value.toISOString().replace("T", " ").replace("Z", "")
|
|
99754
|
-
};
|
|
99755
|
-
} else {
|
|
99756
|
-
throw new Error(`Unknown type for ${value}`);
|
|
99757
|
-
}
|
|
99758
|
-
return response;
|
|
99759
|
-
};
|
|
99760
|
-
var getValueFromDataApi = getValueFromDataApi2, typingsToAwsTypeHint = typingsToAwsTypeHint2, toValueParam = toValueParam2;
|
|
99761
99695
|
assertPackages("@aws-sdk/client-rds-data");
|
|
99762
99696
|
const { RDSDataClient, ExecuteStatementCommand, TypeHint } = await Promise.resolve().then(() => __toESM(require_dist_cjs54()));
|
|
99697
|
+
const { AwsDataApiSession } = await import("drizzle-orm/aws-data-api/pg");
|
|
99763
99698
|
const rdsClient = new RDSDataClient();
|
|
99764
|
-
const
|
|
99765
|
-
|
|
99766
|
-
|
|
99767
|
-
|
|
99768
|
-
|
|
99769
|
-
|
|
99770
|
-
|
|
99771
|
-
|
|
99772
|
-
|
|
99773
|
-
|
|
99774
|
-
|
|
99775
|
-
|
|
99776
|
-
|
|
99777
|
-
|
|
99778
|
-
|
|
99779
|
-
return
|
|
99780
|
-
}
|
|
99781
|
-
|
|
99782
|
-
|
|
99783
|
-
|
|
99784
|
-
|
|
99785
|
-
const result = await rdsClient.send(
|
|
99786
|
-
new ExecuteStatementCommand({
|
|
99787
|
-
sql: params.sql,
|
|
99788
|
-
parameters: params.params.map((param, index4) => ({
|
|
99789
|
-
name: `${index4 + 1}`,
|
|
99790
|
-
...toValueParam2(param, void 0)
|
|
99791
|
-
})),
|
|
99792
|
-
secretArn: credentials2.secretArn,
|
|
99793
|
-
resourceArn: credentials2.resourceArn,
|
|
99794
|
-
database: credentials2.database
|
|
99795
|
-
})
|
|
99796
|
-
);
|
|
99797
|
-
if (params.mode === "array") {
|
|
99798
|
-
const rows = ((_a = result.records) == null ? void 0 : _a.map((row) => {
|
|
99799
|
-
return row.map((field) => getValueFromDataApi2(field));
|
|
99800
|
-
})) ?? [];
|
|
99801
|
-
return rows;
|
|
99699
|
+
const session = new AwsDataApiSession(
|
|
99700
|
+
rdsClient,
|
|
99701
|
+
new import_pg_core4.PgDialect(),
|
|
99702
|
+
void 0,
|
|
99703
|
+
{
|
|
99704
|
+
database: credentials2.database,
|
|
99705
|
+
resourceArn: credentials2.resourceArn,
|
|
99706
|
+
secretArn: credentials2.secretArn
|
|
99707
|
+
},
|
|
99708
|
+
void 0
|
|
99709
|
+
);
|
|
99710
|
+
return {
|
|
99711
|
+
async query(sql2, params) {
|
|
99712
|
+
const prepared = session.prepareQuery({ sql: sql2, params: params ?? [] }, void 0, void 0, false);
|
|
99713
|
+
const result = await prepared.execute();
|
|
99714
|
+
return result;
|
|
99715
|
+
},
|
|
99716
|
+
async proxy(params) {
|
|
99717
|
+
const prepared = session.prepareQuery({ sql: params.sql, params: params.params ?? [] }, void 0, void 0, params.mode === "array");
|
|
99718
|
+
const result = await prepared.execute();
|
|
99719
|
+
return result;
|
|
99802
99720
|
}
|
|
99803
|
-
return result.records;
|
|
99804
99721
|
};
|
|
99805
|
-
return { query, proxy };
|
|
99806
99722
|
}
|
|
99807
99723
|
assertUnreachable(credentials2.driver);
|
|
99808
99724
|
}
|
|
@@ -99851,7 +99767,7 @@ var init_connections = __esm({
|
|
|
99851
99767
|
);
|
|
99852
99768
|
console.log(
|
|
99853
99769
|
withStyle.fullWarning(
|
|
99854
|
-
"'@neondatabase/serverless'
|
|
99770
|
+
"'@neondatabase/serverless' can only connect to remote Neon/Vercel Postgres/Supabase instances through a websocket"
|
|
99855
99771
|
)
|
|
99856
99772
|
);
|
|
99857
99773
|
const { Client: Client2 } = await Promise.resolve().then(() => (init_serverless(), serverless_exports));
|
|
@@ -99878,7 +99794,7 @@ var init_connections = __esm({
|
|
|
99878
99794
|
);
|
|
99879
99795
|
console.log(
|
|
99880
99796
|
withStyle.fullWarning(
|
|
99881
|
-
"'@vercel/postgres'
|
|
99797
|
+
"'@vercel/postgres' can only connect to remote Neon/Vercel Postgres/Supabase instances through a websocket"
|
|
99882
99798
|
)
|
|
99883
99799
|
);
|
|
99884
99800
|
const { Client: Client2 } = await Promise.resolve().then(() => (init_index_node(), index_node_exports));
|
|
@@ -100084,7 +100000,7 @@ __export(studio_exports, {
|
|
|
100084
100000
|
prepareSQLiteSchema: () => prepareSQLiteSchema,
|
|
100085
100001
|
prepareServer: () => prepareServer
|
|
100086
100002
|
});
|
|
100087
|
-
var import_node_https,
|
|
100003
|
+
var import_node_https, import_pg_core5, import_drizzle_orm8, import_mysql_core4, import_sqlite_core3, preparePgSchema, prepareMySqlSchema, prepareSQLiteSchema, getCustomDefaults, drizzleForPostgres, drizzleForMySQL, drizzleForSQLite, init, proxySchema, defaultsSchema, schema4, jsonStringify, prepareServer;
|
|
100088
100004
|
var init_studio = __esm({
|
|
100089
100005
|
"src/serializer/studio.ts"() {
|
|
100090
100006
|
"use strict";
|
|
@@ -100096,7 +100012,7 @@ var init_studio = __esm({
|
|
|
100096
100012
|
init_dist5();
|
|
100097
100013
|
init_lib();
|
|
100098
100014
|
init_serializer();
|
|
100099
|
-
|
|
100015
|
+
import_pg_core5 = require("drizzle-orm/pg-core");
|
|
100100
100016
|
import_drizzle_orm8 = require("drizzle-orm");
|
|
100101
100017
|
init_utils4();
|
|
100102
100018
|
import_mysql_core4 = require("drizzle-orm/mysql-core");
|
|
@@ -100111,8 +100027,8 @@ var init_studio = __esm({
|
|
|
100111
100027
|
const i0 = require(`${it}`);
|
|
100112
100028
|
const i0values = Object.entries(i0);
|
|
100113
100029
|
i0values.forEach(([k2, t]) => {
|
|
100114
|
-
if ((0, import_drizzle_orm8.is)(t,
|
|
100115
|
-
const schema5 = (0,
|
|
100030
|
+
if ((0, import_drizzle_orm8.is)(t, import_pg_core5.PgTable)) {
|
|
100031
|
+
const schema5 = (0, import_pg_core5.getTableConfig)(t).schema || "public";
|
|
100116
100032
|
pgSchema2[schema5] = pgSchema2[schema5] || {};
|
|
100117
100033
|
pgSchema2[schema5][k2] = t;
|
|
100118
100034
|
}
|
|
@@ -100177,8 +100093,8 @@ var init_studio = __esm({
|
|
|
100177
100093
|
Object.entries(schema5).map(([schema6, tables]) => {
|
|
100178
100094
|
Object.entries(tables).map(([, table4]) => {
|
|
100179
100095
|
let tableConfig;
|
|
100180
|
-
if ((0, import_drizzle_orm8.is)(table4,
|
|
100181
|
-
tableConfig = (0,
|
|
100096
|
+
if ((0, import_drizzle_orm8.is)(table4, import_pg_core5.PgTable)) {
|
|
100097
|
+
tableConfig = (0, import_pg_core5.getTableConfig)(table4);
|
|
100182
100098
|
} else if ((0, import_drizzle_orm8.is)(table4, import_mysql_core4.MySqlTable)) {
|
|
100183
100099
|
tableConfig = (0, import_mysql_core4.getTableConfig)(table4);
|
|
100184
100100
|
} else {
|
|
@@ -103733,7 +103649,7 @@ import { sql } from "drizzle-orm"
|
|
|
103733
103649
|
});
|
|
103734
103650
|
|
|
103735
103651
|
// src/introspect-pg.ts
|
|
103736
|
-
var import_drizzle_orm9, import_relations, pgImportsList, objToStatement23, timeConfig2, possibleIntervals, intervalStrToObj, intervalConfig, importsPatch2, relations3, withCasing2, schemaToTypeScript3, isCyclic3, isSelf3, column6, dimensionsInArray, createTableColumns3, createTableIndexes3, createTablePKs3, createTableUniques3, createTableFKs3;
|
|
103652
|
+
var import_drizzle_orm9, import_relations, pgImportsList, objToStatement23, timeConfig2, possibleIntervals, intervalStrToObj, intervalConfig, importsPatch2, relations3, withCasing2, paramNameFor, schemaToTypeScript3, isCyclic3, isSelf3, column6, dimensionsInArray, createTableColumns3, createTableIndexes3, createTablePKs3, createTableUniques3, createTableFKs3;
|
|
103737
103653
|
var init_introspect_pg = __esm({
|
|
103738
103654
|
"src/introspect-pg.ts"() {
|
|
103739
103655
|
"use strict";
|
|
@@ -103858,6 +103774,10 @@ var init_introspect_pg = __esm({
|
|
|
103858
103774
|
}
|
|
103859
103775
|
assertUnreachable(casing2);
|
|
103860
103776
|
};
|
|
103777
|
+
paramNameFor = (name, schema5) => {
|
|
103778
|
+
const schemaSuffix = schema5 && schema5 !== "public" ? `In${schema5.capitalise()}` : "";
|
|
103779
|
+
return `${name}${schemaSuffix}`;
|
|
103780
|
+
};
|
|
103861
103781
|
schemaToTypeScript3 = (schema5, casing2) => {
|
|
103862
103782
|
Object.values(schema5.tables).forEach((table4) => {
|
|
103863
103783
|
Object.values(table4.foreignKeys).forEach((fk4) => {
|
|
@@ -103914,7 +103834,7 @@ var init_introspect_pg = __esm({
|
|
|
103914
103834
|
);
|
|
103915
103835
|
const enumStatements = Object.values(schema5.enums).map((it) => {
|
|
103916
103836
|
const enumSchema3 = schemas[it.schema];
|
|
103917
|
-
const paramName =
|
|
103837
|
+
const paramName = paramNameFor(it.name, enumSchema3);
|
|
103918
103838
|
const func = enumSchema3 ? `${enumSchema3}.enum` : "pgEnum";
|
|
103919
103839
|
const values2 = Object.values(it.values).map((it2) => `'${it2}'`).join(", ");
|
|
103920
103840
|
return `export const ${withCasing2(paramName, casing2)} = ${func}("${it.name}", [${values2}])
|
|
@@ -103926,7 +103846,7 @@ var init_introspect_pg = __esm({
|
|
|
103926
103846
|
}).join("");
|
|
103927
103847
|
const tableStatements = Object.values(schema5.tables).map((table4) => {
|
|
103928
103848
|
const tableSchema = schemas[table4.schema];
|
|
103929
|
-
const paramName =
|
|
103849
|
+
const paramName = paramNameFor(table4.name, tableSchema);
|
|
103930
103850
|
const func = tableSchema ? `${tableSchema}.table` : "pgTable";
|
|
103931
103851
|
let statement = `export const ${withCasing2(paramName, casing2)} = ${func}("${table4.name}", {
|
|
103932
103852
|
`;
|
|
@@ -103935,6 +103855,7 @@ var init_introspect_pg = __esm({
|
|
|
103935
103855
|
Object.values(table4.columns),
|
|
103936
103856
|
Object.values(table4.foreignKeys),
|
|
103937
103857
|
enumTypes,
|
|
103858
|
+
schemas,
|
|
103938
103859
|
casing2,
|
|
103939
103860
|
schema5.internal
|
|
103940
103861
|
);
|
|
@@ -103951,7 +103872,7 @@ var init_introspect_pg = __esm({
|
|
|
103951
103872
|
Object.values(table4.indexes),
|
|
103952
103873
|
casing2
|
|
103953
103874
|
);
|
|
103954
|
-
statement += createTableFKs3(Object.values(filteredFKs), casing2);
|
|
103875
|
+
statement += createTableFKs3(Object.values(filteredFKs), schemas, casing2);
|
|
103955
103876
|
statement += createTablePKs3(
|
|
103956
103877
|
Object.values(table4.compositePrimaryKeys),
|
|
103957
103878
|
casing2
|
|
@@ -103973,8 +103894,8 @@ var init_introspect_pg = __esm({
|
|
|
103973
103894
|
import { sql } from "drizzle-orm"
|
|
103974
103895
|
|
|
103975
103896
|
`;
|
|
103976
|
-
let decalrations =
|
|
103977
|
-
decalrations +=
|
|
103897
|
+
let decalrations = schemaStatements;
|
|
103898
|
+
decalrations += enumStatements;
|
|
103978
103899
|
decalrations += "\n";
|
|
103979
103900
|
decalrations += tableStatements.join("\n\n");
|
|
103980
103901
|
const file = importsTs + decalrations;
|
|
@@ -104201,7 +104122,7 @@ var init_introspect_pg = __esm({
|
|
|
104201
104122
|
}
|
|
104202
104123
|
return res;
|
|
104203
104124
|
};
|
|
104204
|
-
createTableColumns3 = (tableName, columns, fks, enumTypes, casing2, internals) => {
|
|
104125
|
+
createTableColumns3 = (tableName, columns, fks, enumTypes, schemas, casing2, internals) => {
|
|
104205
104126
|
let statement = "";
|
|
104206
104127
|
const oneColumnsFKs = Object.values(fks).filter((it) => {
|
|
104207
104128
|
return !isSelf3(it);
|
|
@@ -104240,14 +104161,16 @@ var init_introspect_pg = __esm({
|
|
|
104240
104161
|
const params = { onDelete, onUpdate };
|
|
104241
104162
|
const typeSuffix = isCyclic3(it2) ? ": AnyPgColumn" : "";
|
|
104242
104163
|
const paramsStr = objToStatement23(params);
|
|
104164
|
+
const tableSchema = schemas[it2.schemaTo || ""];
|
|
104165
|
+
const paramName = paramNameFor(it2.tableTo, tableSchema);
|
|
104243
104166
|
if (paramsStr) {
|
|
104244
104167
|
return `.references(()${typeSuffix} => ${withCasing2(
|
|
104245
|
-
|
|
104168
|
+
paramName,
|
|
104246
104169
|
casing2
|
|
104247
104170
|
)}.${withCasing2(it2.columnsTo[0], casing2)}, ${paramsStr} )`;
|
|
104248
104171
|
}
|
|
104249
104172
|
return `.references(()${typeSuffix} => ${withCasing2(
|
|
104250
|
-
|
|
104173
|
+
paramName,
|
|
104251
104174
|
casing2
|
|
104252
104175
|
)}.${withCasing2(it2.columnsTo[0], casing2)})`;
|
|
104253
104176
|
}).join("");
|
|
@@ -104303,11 +104226,13 @@ var init_introspect_pg = __esm({
|
|
|
104303
104226
|
});
|
|
104304
104227
|
return statement;
|
|
104305
104228
|
};
|
|
104306
|
-
createTableFKs3 = (fks, casing2) => {
|
|
104229
|
+
createTableFKs3 = (fks, schemas, casing2) => {
|
|
104307
104230
|
let statement = "";
|
|
104308
104231
|
fks.forEach((it) => {
|
|
104232
|
+
const tableSchema = schemas[it.schemaTo || ""];
|
|
104233
|
+
const paramName = paramNameFor(it.tableTo, tableSchema);
|
|
104309
104234
|
const isSelf4 = it.tableTo === it.tableFrom;
|
|
104310
|
-
const tableTo = isSelf4 ? "table" : `${withCasing2(
|
|
104235
|
+
const tableTo = isSelf4 ? "table" : `${withCasing2(paramName, casing2)}`;
|
|
104311
104236
|
statement += ` ${withCasing2(it.name, casing2)}: foreignKey({
|
|
104312
104237
|
`;
|
|
104313
104238
|
statement += ` columns: [${it.columnsFrom.map((i) => `table.${withCasing2(i, casing2)}`).join(", ")}],
|
|
@@ -104946,8 +104871,10 @@ var init_introspect = __esm({
|
|
|
104946
104871
|
const tableRelations = {};
|
|
104947
104872
|
Object.values(schema5.tables).forEach((table4) => {
|
|
104948
104873
|
Object.values(table4.foreignKeys).forEach((fk4) => {
|
|
104949
|
-
const
|
|
104950
|
-
const
|
|
104874
|
+
const tableNameFrom = paramNameFor(fk4.tableFrom, table4.schema);
|
|
104875
|
+
const tableNameTo = paramNameFor(fk4.tableTo, fk4.schemaTo);
|
|
104876
|
+
const tableFrom = withCasing3(tableNameFrom, casing2);
|
|
104877
|
+
const tableTo = withCasing3(tableNameTo, casing2);
|
|
104951
104878
|
const columnFrom = withCasing3(fk4.columnsFrom[0], casing2);
|
|
104952
104879
|
const columnTo = withCasing3(fk4.columnsTo[0], casing2);
|
|
104953
104880
|
imports.push(tableTo, tableFrom);
|
|
@@ -106489,6 +106416,11 @@ var pullCommand = new import_commander.Command("introspect").option("--config <c
|
|
|
106489
106416
|
tablesFilter,
|
|
106490
106417
|
schemasFilter
|
|
106491
106418
|
} = await preparePullConfig(options);
|
|
106419
|
+
console.log(
|
|
106420
|
+
grey(
|
|
106421
|
+
`Pulling from [${schemasFilter.map((it) => `'${it}'`).join(", ")}] list of schemas`
|
|
106422
|
+
)
|
|
106423
|
+
);
|
|
106492
106424
|
try {
|
|
106493
106425
|
if (dialect7 === "postgresql") {
|
|
106494
106426
|
const { introspectPostgres: introspectPostgres2 } = await Promise.resolve().then(() => (init_introspect(), introspect_exports));
|
|
@@ -106617,8 +106549,8 @@ Drizzle Studio is up and running on ${source_default.blue(
|
|
|
106617
106549
|
});
|
|
106618
106550
|
} catch (e) {
|
|
106619
106551
|
console.error(e);
|
|
106552
|
+
process.exit(0);
|
|
106620
106553
|
}
|
|
106621
|
-
process.exit(0);
|
|
106622
106554
|
});
|
|
106623
106555
|
var main = async () => {
|
|
106624
106556
|
const version2 = await versions();
|
package/cli/validations/cli.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export declare const pushParams: import("zod").ZodObject<{
|
|
|
29
29
|
dialect: import("zod").ZodEnum<["postgresql", "mysql", "sqlite"]>;
|
|
30
30
|
schema: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString, "many">]>>;
|
|
31
31
|
tablesFilter: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString, "many">]>>;
|
|
32
|
-
|
|
32
|
+
schemaFilter: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString, "many">]>>>;
|
|
33
33
|
driver: import("zod").ZodOptional<import("zod").ZodString>;
|
|
34
34
|
connectionString: import("zod").ZodOptional<import("zod").ZodString>;
|
|
35
35
|
uri: import("zod").ZodOptional<import("zod").ZodString>;
|
|
@@ -60,7 +60,7 @@ export declare const pushParams: import("zod").ZodObject<{
|
|
|
60
60
|
tablesFilter?: string | string[] | undefined;
|
|
61
61
|
verbose?: boolean | undefined;
|
|
62
62
|
dialect: "mysql" | "postgresql" | "sqlite";
|
|
63
|
-
|
|
63
|
+
schemaFilter: string | string[];
|
|
64
64
|
}, {
|
|
65
65
|
strict?: boolean | undefined;
|
|
66
66
|
schema?: string | string[] | undefined;
|
|
@@ -76,8 +76,8 @@ export declare const pushParams: import("zod").ZodObject<{
|
|
|
76
76
|
ssl?: string | undefined;
|
|
77
77
|
authToken?: string | undefined;
|
|
78
78
|
tablesFilter?: string | string[] | undefined;
|
|
79
|
+
schemaFilter?: string | string[] | undefined;
|
|
79
80
|
verbose?: boolean | undefined;
|
|
80
|
-
schemaFilters?: string | string[] | undefined;
|
|
81
81
|
dialect: "mysql" | "postgresql" | "sqlite";
|
|
82
82
|
}>;
|
|
83
83
|
export type PushParams = TypeOf<typeof pushParams>;
|
|
@@ -100,7 +100,7 @@ export declare const pullParams: import("zod").ZodObject<{
|
|
|
100
100
|
authToken: import("zod").ZodOptional<import("zod").ZodString>;
|
|
101
101
|
introspectCasing: import("zod").ZodDefault<import("zod").ZodUnion<[import("zod").ZodLiteral<"camel">, import("zod").ZodLiteral<"preserve">]>>;
|
|
102
102
|
breakpoints: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodBoolean>>;
|
|
103
|
-
}, "
|
|
103
|
+
}, "passthrough", import("zod").ZodTypeAny, {
|
|
104
104
|
dialect?: "mysql" | "postgresql" | "sqlite" | undefined;
|
|
105
105
|
url?: string | undefined;
|
|
106
106
|
host?: string | undefined;
|
package/cli/views.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { Named, NamedWithSchema } from "./commands/migrate";
|
|
|
4
4
|
export declare const warning: (msg: string) => void;
|
|
5
5
|
export declare const err: (msg: string) => void;
|
|
6
6
|
export declare const info: (msg: string, greyMsg?: string) => string;
|
|
7
|
+
export declare const grey: (msg: string) => string;
|
|
7
8
|
export declare const error: (error: string, greyMsg?: string) => string;
|
|
8
9
|
export declare const schema: (schema: CommonSchema) => string;
|
|
9
10
|
export interface RenamePropmtItem<T> {
|
package/package.json
CHANGED
package/payload.js
CHANGED
|
@@ -5511,7 +5511,7 @@ var init_cli = __esm({
|
|
|
5511
5511
|
dialect: dialect3,
|
|
5512
5512
|
schema: unionType([stringType(), stringType().array()]).optional(),
|
|
5513
5513
|
tablesFilter: unionType([stringType(), stringType().array()]).optional(),
|
|
5514
|
-
|
|
5514
|
+
schemaFilter: unionType([stringType(), stringType().array()]).optional().default(["public"]),
|
|
5515
5515
|
driver: stringType().optional(),
|
|
5516
5516
|
// pg
|
|
5517
5517
|
connectionString: stringType().optional(),
|
|
@@ -5550,7 +5550,7 @@ var init_cli = __esm({
|
|
|
5550
5550
|
authToken: stringType().optional(),
|
|
5551
5551
|
introspectCasing: casing,
|
|
5552
5552
|
breakpoints: booleanType().optional().default(true)
|
|
5553
|
-
});
|
|
5553
|
+
}).passthrough();
|
|
5554
5554
|
configCheck = objectType({
|
|
5555
5555
|
dialect: dialect3.optional(),
|
|
5556
5556
|
out: stringType().optional()
|
|
@@ -15088,7 +15088,7 @@ var init_snapshotsDiffer = __esm({
|
|
|
15088
15088
|
const jsonTableAlternations = alteredTables.map((it) => {
|
|
15089
15089
|
return preparePgAlterColumns(it.name, it.schema, it.altered, json2);
|
|
15090
15090
|
}).flat();
|
|
15091
|
-
const
|
|
15091
|
+
const jsonCreateIndexesFoAlteredTables = alteredTables.map((it) => {
|
|
15092
15092
|
return prepareCreateIndexesJson(
|
|
15093
15093
|
it.name,
|
|
15094
15094
|
it.schema,
|
|
@@ -15117,14 +15117,21 @@ var init_snapshotsDiffer = __esm({
|
|
|
15117
15117
|
},
|
|
15118
15118
|
{}
|
|
15119
15119
|
);
|
|
15120
|
-
|
|
15120
|
+
jsonCreateIndexesFoAlteredTables.push(
|
|
15121
15121
|
...prepareCreateIndexesJson(it.name, it.schema, createdIndexes || {})
|
|
15122
15122
|
);
|
|
15123
15123
|
jsonDropIndexesForAllAlteredTables.push(
|
|
15124
15124
|
...prepareDropIndexesJson(it.name, it.schema, droppedIndexes || {})
|
|
15125
15125
|
);
|
|
15126
15126
|
});
|
|
15127
|
-
const
|
|
15127
|
+
const jsonCreateReferencesForCreatedTables = createdTables.map((it) => {
|
|
15128
|
+
return prepareCreateReferencesJson(
|
|
15129
|
+
it.name,
|
|
15130
|
+
it.schema,
|
|
15131
|
+
it.foreignKeys
|
|
15132
|
+
);
|
|
15133
|
+
}).flat();
|
|
15134
|
+
const jsonReferencesForAlteredTables = alteredTables.map((it) => {
|
|
15128
15135
|
const forAdded = prepareCreateReferencesJson(
|
|
15129
15136
|
it.name,
|
|
15130
15137
|
it.schema,
|
|
@@ -15142,10 +15149,10 @@ var init_snapshotsDiffer = __esm({
|
|
|
15142
15149
|
);
|
|
15143
15150
|
return [...forAdded, ...forAltered, ...alteredFKs];
|
|
15144
15151
|
}).flat();
|
|
15145
|
-
const jsonCreatedReferencesForAlteredTables =
|
|
15152
|
+
const jsonCreatedReferencesForAlteredTables = jsonReferencesForAlteredTables.filter(
|
|
15146
15153
|
(t) => t.type === "create_reference"
|
|
15147
15154
|
);
|
|
15148
|
-
const jsonDroppedReferencesForAlteredTables =
|
|
15155
|
+
const jsonDroppedReferencesForAlteredTables = jsonReferencesForAlteredTables.filter(
|
|
15149
15156
|
(t) => t.type === "delete_reference"
|
|
15150
15157
|
);
|
|
15151
15158
|
const createEnums = createdEnums.map((it) => {
|
|
@@ -15172,7 +15179,7 @@ var init_snapshotsDiffer = __esm({
|
|
|
15172
15179
|
const dropSchemas = prepareDeleteSchemasJson(
|
|
15173
15180
|
deletedSchemas.map((it) => it.name)
|
|
15174
15181
|
);
|
|
15175
|
-
const
|
|
15182
|
+
const createTables = createdTables.map((it) => {
|
|
15176
15183
|
return preparePgCreateTableJson(it, curFull);
|
|
15177
15184
|
});
|
|
15178
15185
|
jsonStatements.push(...createSchemas);
|
|
@@ -15181,7 +15188,7 @@ var init_snapshotsDiffer = __esm({
|
|
|
15181
15188
|
jsonStatements.push(...moveEnums);
|
|
15182
15189
|
jsonStatements.push(...renameEnums);
|
|
15183
15190
|
jsonStatements.push(...jsonAlterEnumsWithAddedValues);
|
|
15184
|
-
jsonStatements.push(...
|
|
15191
|
+
jsonStatements.push(...createTables);
|
|
15185
15192
|
jsonStatements.push(...jsonDropTables);
|
|
15186
15193
|
jsonStatements.push(...jsonSetTableSchemas);
|
|
15187
15194
|
jsonStatements.push(...jsonRenameTables);
|
|
@@ -15192,9 +15199,10 @@ var init_snapshotsDiffer = __esm({
|
|
|
15192
15199
|
jsonStatements.push(...jsonTableAlternations);
|
|
15193
15200
|
jsonStatements.push(...jsonAddedCompositePKs);
|
|
15194
15201
|
jsonStatements.push(...jsonAddColumnsStatemets);
|
|
15202
|
+
jsonStatements.push(...jsonCreateReferencesForCreatedTables);
|
|
15195
15203
|
jsonStatements.push(...jsonCreateIndexesForCreatedTables);
|
|
15196
|
-
jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
|
|
15197
15204
|
jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
|
|
15205
|
+
jsonStatements.push(...jsonCreateIndexesFoAlteredTables);
|
|
15198
15206
|
jsonStatements.push(...jsonDropColumnsStatemets);
|
|
15199
15207
|
jsonStatements.push(...jsonAlteredCompositePKs);
|
|
15200
15208
|
jsonStatements.push(...jsonAlteredUniqueConstraints);
|
|
@@ -15453,6 +15461,13 @@ var init_snapshotsDiffer = __esm({
|
|
|
15453
15461
|
...prepareDropIndexesJson(it.name, it.schema, droppedIndexes || {})
|
|
15454
15462
|
);
|
|
15455
15463
|
});
|
|
15464
|
+
const jsonCreateReferencesForCreatedTables = createdTables.map((it) => {
|
|
15465
|
+
return prepareCreateReferencesJson(
|
|
15466
|
+
it.name,
|
|
15467
|
+
it.schema,
|
|
15468
|
+
it.foreignKeys
|
|
15469
|
+
);
|
|
15470
|
+
}).flat();
|
|
15456
15471
|
const jsonReferencesForAllAlteredTables = alteredTables.map((it) => {
|
|
15457
15472
|
const forAdded = prepareCreateReferencesJson(
|
|
15458
15473
|
it.name,
|
|
@@ -15493,9 +15508,10 @@ var init_snapshotsDiffer = __esm({
|
|
|
15493
15508
|
jsonStatements.push(...jsonAddedUniqueConstraints);
|
|
15494
15509
|
jsonStatements.push(...jsonDeletedUniqueConstraints);
|
|
15495
15510
|
jsonStatements.push(...jsonAddColumnsStatemets);
|
|
15511
|
+
jsonStatements.push(...jsonCreateReferencesForCreatedTables);
|
|
15496
15512
|
jsonStatements.push(...jsonCreateIndexesForCreatedTables);
|
|
15497
|
-
jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
|
|
15498
15513
|
jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
|
|
15514
|
+
jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
|
|
15499
15515
|
jsonStatements.push(...jsonDropColumnsStatemets);
|
|
15500
15516
|
jsonStatements.push(...jsonAlteredCompositePKs);
|
|
15501
15517
|
jsonStatements.push(...jsonAddedUniqueConstraints);
|
|
@@ -19048,6 +19064,9 @@ String.prototype.squashSpaces = function() {
|
|
|
19048
19064
|
String.prototype.camelCase = function() {
|
|
19049
19065
|
return camelCase(String(this));
|
|
19050
19066
|
};
|
|
19067
|
+
String.prototype.capitalise = function() {
|
|
19068
|
+
return this && this.length > 0 ? `${this[0].toUpperCase()}${this.slice(1)}` : String(this);
|
|
19069
|
+
};
|
|
19051
19070
|
String.prototype.concatIf = function(it, condition) {
|
|
19052
19071
|
return condition ? `${this}${it}` : String(this);
|
|
19053
19072
|
};
|
package/payload.mjs
CHANGED
|
@@ -5517,7 +5517,7 @@ var init_cli = __esm({
|
|
|
5517
5517
|
dialect: dialect3,
|
|
5518
5518
|
schema: unionType([stringType(), stringType().array()]).optional(),
|
|
5519
5519
|
tablesFilter: unionType([stringType(), stringType().array()]).optional(),
|
|
5520
|
-
|
|
5520
|
+
schemaFilter: unionType([stringType(), stringType().array()]).optional().default(["public"]),
|
|
5521
5521
|
driver: stringType().optional(),
|
|
5522
5522
|
// pg
|
|
5523
5523
|
connectionString: stringType().optional(),
|
|
@@ -5556,7 +5556,7 @@ var init_cli = __esm({
|
|
|
5556
5556
|
authToken: stringType().optional(),
|
|
5557
5557
|
introspectCasing: casing,
|
|
5558
5558
|
breakpoints: booleanType().optional().default(true)
|
|
5559
|
-
});
|
|
5559
|
+
}).passthrough();
|
|
5560
5560
|
configCheck = objectType({
|
|
5561
5561
|
dialect: dialect3.optional(),
|
|
5562
5562
|
out: stringType().optional()
|
|
@@ -15102,7 +15102,7 @@ var init_snapshotsDiffer = __esm({
|
|
|
15102
15102
|
const jsonTableAlternations = alteredTables.map((it) => {
|
|
15103
15103
|
return preparePgAlterColumns(it.name, it.schema, it.altered, json2);
|
|
15104
15104
|
}).flat();
|
|
15105
|
-
const
|
|
15105
|
+
const jsonCreateIndexesFoAlteredTables = alteredTables.map((it) => {
|
|
15106
15106
|
return prepareCreateIndexesJson(
|
|
15107
15107
|
it.name,
|
|
15108
15108
|
it.schema,
|
|
@@ -15131,14 +15131,21 @@ var init_snapshotsDiffer = __esm({
|
|
|
15131
15131
|
},
|
|
15132
15132
|
{}
|
|
15133
15133
|
);
|
|
15134
|
-
|
|
15134
|
+
jsonCreateIndexesFoAlteredTables.push(
|
|
15135
15135
|
...prepareCreateIndexesJson(it.name, it.schema, createdIndexes || {})
|
|
15136
15136
|
);
|
|
15137
15137
|
jsonDropIndexesForAllAlteredTables.push(
|
|
15138
15138
|
...prepareDropIndexesJson(it.name, it.schema, droppedIndexes || {})
|
|
15139
15139
|
);
|
|
15140
15140
|
});
|
|
15141
|
-
const
|
|
15141
|
+
const jsonCreateReferencesForCreatedTables = createdTables.map((it) => {
|
|
15142
|
+
return prepareCreateReferencesJson(
|
|
15143
|
+
it.name,
|
|
15144
|
+
it.schema,
|
|
15145
|
+
it.foreignKeys
|
|
15146
|
+
);
|
|
15147
|
+
}).flat();
|
|
15148
|
+
const jsonReferencesForAlteredTables = alteredTables.map((it) => {
|
|
15142
15149
|
const forAdded = prepareCreateReferencesJson(
|
|
15143
15150
|
it.name,
|
|
15144
15151
|
it.schema,
|
|
@@ -15156,10 +15163,10 @@ var init_snapshotsDiffer = __esm({
|
|
|
15156
15163
|
);
|
|
15157
15164
|
return [...forAdded, ...forAltered, ...alteredFKs];
|
|
15158
15165
|
}).flat();
|
|
15159
|
-
const jsonCreatedReferencesForAlteredTables =
|
|
15166
|
+
const jsonCreatedReferencesForAlteredTables = jsonReferencesForAlteredTables.filter(
|
|
15160
15167
|
(t) => t.type === "create_reference"
|
|
15161
15168
|
);
|
|
15162
|
-
const jsonDroppedReferencesForAlteredTables =
|
|
15169
|
+
const jsonDroppedReferencesForAlteredTables = jsonReferencesForAlteredTables.filter(
|
|
15163
15170
|
(t) => t.type === "delete_reference"
|
|
15164
15171
|
);
|
|
15165
15172
|
const createEnums = createdEnums.map((it) => {
|
|
@@ -15186,7 +15193,7 @@ var init_snapshotsDiffer = __esm({
|
|
|
15186
15193
|
const dropSchemas = prepareDeleteSchemasJson(
|
|
15187
15194
|
deletedSchemas.map((it) => it.name)
|
|
15188
15195
|
);
|
|
15189
|
-
const
|
|
15196
|
+
const createTables = createdTables.map((it) => {
|
|
15190
15197
|
return preparePgCreateTableJson(it, curFull);
|
|
15191
15198
|
});
|
|
15192
15199
|
jsonStatements.push(...createSchemas);
|
|
@@ -15195,7 +15202,7 @@ var init_snapshotsDiffer = __esm({
|
|
|
15195
15202
|
jsonStatements.push(...moveEnums);
|
|
15196
15203
|
jsonStatements.push(...renameEnums);
|
|
15197
15204
|
jsonStatements.push(...jsonAlterEnumsWithAddedValues);
|
|
15198
|
-
jsonStatements.push(...
|
|
15205
|
+
jsonStatements.push(...createTables);
|
|
15199
15206
|
jsonStatements.push(...jsonDropTables);
|
|
15200
15207
|
jsonStatements.push(...jsonSetTableSchemas);
|
|
15201
15208
|
jsonStatements.push(...jsonRenameTables);
|
|
@@ -15206,9 +15213,10 @@ var init_snapshotsDiffer = __esm({
|
|
|
15206
15213
|
jsonStatements.push(...jsonTableAlternations);
|
|
15207
15214
|
jsonStatements.push(...jsonAddedCompositePKs);
|
|
15208
15215
|
jsonStatements.push(...jsonAddColumnsStatemets);
|
|
15216
|
+
jsonStatements.push(...jsonCreateReferencesForCreatedTables);
|
|
15209
15217
|
jsonStatements.push(...jsonCreateIndexesForCreatedTables);
|
|
15210
|
-
jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
|
|
15211
15218
|
jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
|
|
15219
|
+
jsonStatements.push(...jsonCreateIndexesFoAlteredTables);
|
|
15212
15220
|
jsonStatements.push(...jsonDropColumnsStatemets);
|
|
15213
15221
|
jsonStatements.push(...jsonAlteredCompositePKs);
|
|
15214
15222
|
jsonStatements.push(...jsonAlteredUniqueConstraints);
|
|
@@ -15467,6 +15475,13 @@ var init_snapshotsDiffer = __esm({
|
|
|
15467
15475
|
...prepareDropIndexesJson(it.name, it.schema, droppedIndexes || {})
|
|
15468
15476
|
);
|
|
15469
15477
|
});
|
|
15478
|
+
const jsonCreateReferencesForCreatedTables = createdTables.map((it) => {
|
|
15479
|
+
return prepareCreateReferencesJson(
|
|
15480
|
+
it.name,
|
|
15481
|
+
it.schema,
|
|
15482
|
+
it.foreignKeys
|
|
15483
|
+
);
|
|
15484
|
+
}).flat();
|
|
15470
15485
|
const jsonReferencesForAllAlteredTables = alteredTables.map((it) => {
|
|
15471
15486
|
const forAdded = prepareCreateReferencesJson(
|
|
15472
15487
|
it.name,
|
|
@@ -15507,9 +15522,10 @@ var init_snapshotsDiffer = __esm({
|
|
|
15507
15522
|
jsonStatements.push(...jsonAddedUniqueConstraints);
|
|
15508
15523
|
jsonStatements.push(...jsonDeletedUniqueConstraints);
|
|
15509
15524
|
jsonStatements.push(...jsonAddColumnsStatemets);
|
|
15525
|
+
jsonStatements.push(...jsonCreateReferencesForCreatedTables);
|
|
15510
15526
|
jsonStatements.push(...jsonCreateIndexesForCreatedTables);
|
|
15511
|
-
jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
|
|
15512
15527
|
jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
|
|
15528
|
+
jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
|
|
15513
15529
|
jsonStatements.push(...jsonDropColumnsStatemets);
|
|
15514
15530
|
jsonStatements.push(...jsonAlteredCompositePKs);
|
|
15515
15531
|
jsonStatements.push(...jsonAddedUniqueConstraints);
|
|
@@ -19057,6 +19073,9 @@ String.prototype.squashSpaces = function() {
|
|
|
19057
19073
|
String.prototype.camelCase = function() {
|
|
19058
19074
|
return camelCase(String(this));
|
|
19059
19075
|
};
|
|
19076
|
+
String.prototype.capitalise = function() {
|
|
19077
|
+
return this && this.length > 0 ? `${this[0].toUpperCase()}${this.slice(1)}` : String(this);
|
|
19078
|
+
};
|
|
19060
19079
|
String.prototype.concatIf = function(it, condition) {
|
|
19061
19080
|
return condition ? `${this}${it}` : String(this);
|
|
19062
19081
|
};
|
package/utils-studio.js
CHANGED
|
@@ -5933,6 +5933,9 @@ String.prototype.squashSpaces = function() {
|
|
|
5933
5933
|
String.prototype.camelCase = function() {
|
|
5934
5934
|
return camelCase(String(this));
|
|
5935
5935
|
};
|
|
5936
|
+
String.prototype.capitalise = function() {
|
|
5937
|
+
return this && this.length > 0 ? `${this[0].toUpperCase()}${this.slice(1)}` : String(this);
|
|
5938
|
+
};
|
|
5936
5939
|
String.prototype.concatIf = function(it, condition) {
|
|
5937
5940
|
return condition ? `${this}${it}` : String(this);
|
|
5938
5941
|
};
|
package/utils-studio.mjs
CHANGED
|
@@ -5969,6 +5969,9 @@ String.prototype.squashSpaces = function() {
|
|
|
5969
5969
|
String.prototype.camelCase = function() {
|
|
5970
5970
|
return camelCase(String(this));
|
|
5971
5971
|
};
|
|
5972
|
+
String.prototype.capitalise = function() {
|
|
5973
|
+
return this && this.length > 0 ? `${this[0].toUpperCase()}${this.slice(1)}` : String(this);
|
|
5974
|
+
};
|
|
5972
5975
|
String.prototype.concatIf = function(it, condition) {
|
|
5973
5976
|
return condition ? `${this}${it}` : String(this);
|
|
5974
5977
|
};
|