drizzle-kit 0.27.1-e1194ce → 0.27.2-96d338b
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.d.mts +17 -2
- package/api.d.ts +17 -2
- package/api.js +314 -218
- package/api.mjs +314 -218
- package/bin.cjs +358 -272
- package/index-BfiZoTqG.d.mts +293 -0
- package/index-BfiZoTqG.d.ts +293 -0
- package/index.d.mts +2 -287
- package/index.d.ts +2 -287
- package/package.json +1 -1
- package/utils.js +13 -1
- package/utils.mjs +11 -1
- package/common-DYjgLS6u.d.mts +0 -8
- package/common-DYjgLS6u.d.ts +0 -8
package/bin.cjs
CHANGED
@@ -5813,30 +5813,11 @@ var init_mysqlSchema = __esm({
|
|
5813
5813
|
}
|
5814
5814
|
});
|
5815
5815
|
|
5816
|
-
// src/extensions/vector.ts
|
5817
|
-
var vectorOps;
|
5818
|
-
var init_vector = __esm({
|
5819
|
-
"src/extensions/vector.ts"() {
|
5820
|
-
"use strict";
|
5821
|
-
vectorOps = [
|
5822
|
-
"vector_l2_ops",
|
5823
|
-
"vector_ip_ops",
|
5824
|
-
"vector_cosine_ops",
|
5825
|
-
"vector_l1_ops",
|
5826
|
-
"bit_hamming_ops",
|
5827
|
-
"bit_jaccard_ops",
|
5828
|
-
"halfvec_l2_ops",
|
5829
|
-
"sparsevec_l2_ops"
|
5830
|
-
];
|
5831
|
-
}
|
5832
|
-
});
|
5833
|
-
|
5834
5816
|
// src/serializer/pgSchema.ts
|
5835
5817
|
var indexV2, columnV2, tableV2, enumSchemaV1, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, indexColumn, index2, indexV4, indexV5, indexV6, fk2, sequenceSchema, roleSchema, sequenceSquashed, columnV7, column2, checkConstraint2, columnSquashed, tableV32, compositePK2, uniqueConstraint2, policy, policySquashed, viewWithOption, matViewWithOption, mergedViewWithOption, view2, tableV42, tableV5, tableV6, tableV7, table2, schemaHash2, kitInternals2, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaInternalV5, pgSchemaInternalV6, pgSchemaExternal, pgSchemaInternalV7, pgSchemaInternal, tableSquashed2, tableSquashedV42, pgSchemaSquashedV4, pgSchemaSquashedV6, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchemaV5, pgSchemaV6, pgSchemaV7, pgSchema, backwardCompatiblePgSchema, PgSquasher, squashPgScheme, dryPg;
|
5836
5818
|
var init_pgSchema = __esm({
|
5837
5819
|
"src/serializer/pgSchema.ts"() {
|
5838
5820
|
"use strict";
|
5839
|
-
init_vector();
|
5840
5821
|
init_global();
|
5841
5822
|
init_lib();
|
5842
5823
|
indexV2 = objectType({
|
@@ -6044,7 +6025,8 @@ var init_pgSchema = __esm({
|
|
6044
6025
|
to: stringType().array().optional(),
|
6045
6026
|
using: stringType().optional(),
|
6046
6027
|
withCheck: stringType().optional(),
|
6047
|
-
on: stringType().optional()
|
6028
|
+
on: stringType().optional(),
|
6029
|
+
schema: stringType().optional()
|
6048
6030
|
}).strict();
|
6049
6031
|
policySquashed = objectType({
|
6050
6032
|
name: stringType(),
|
@@ -6295,7 +6277,7 @@ var init_pgSchema = __esm({
|
|
6295
6277
|
squashIdx: (idx) => {
|
6296
6278
|
index2.parse(idx);
|
6297
6279
|
return `${idx.name};${idx.columns.map(
|
6298
|
-
(c) => `${c.expression}--${c.isExpression}--${c.asc}--${c.nulls}--${c.opclass
|
6280
|
+
(c) => `${c.expression}--${c.isExpression}--${c.asc}--${c.nulls}--${c.opclass ? c.opclass : ""}`
|
6299
6281
|
).join(",,")};${idx.isUnique};${idx.concurrently};${idx.method};${idx.where};${JSON.stringify(idx.with)}`;
|
6300
6282
|
},
|
6301
6283
|
unsquashIdx: (input) => {
|
@@ -6361,12 +6343,12 @@ var init_pgSchema = __esm({
|
|
6361
6343
|
squashFK: (fk4) => {
|
6362
6344
|
return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""};${fk4.schemaTo || "public"}`;
|
6363
6345
|
},
|
6364
|
-
squashPolicy: (
|
6346
|
+
squashPolicy: (policy3) => {
|
6365
6347
|
var _a;
|
6366
|
-
return `${
|
6348
|
+
return `${policy3.name}--${policy3.as}--${policy3.for}--${(_a = policy3.to) == null ? void 0 : _a.join(",")}--${policy3.using}--${policy3.withCheck}--${policy3.on}`;
|
6367
6349
|
},
|
6368
|
-
unsquashPolicy: (
|
6369
|
-
const splitted =
|
6350
|
+
unsquashPolicy: (policy3) => {
|
6351
|
+
const splitted = policy3.split("--");
|
6370
6352
|
return {
|
6371
6353
|
name: splitted[0],
|
6372
6354
|
as: splitted[1],
|
@@ -6377,9 +6359,19 @@ var init_pgSchema = __esm({
|
|
6377
6359
|
on: splitted[6] !== "undefined" ? splitted[6] : void 0
|
6378
6360
|
};
|
6379
6361
|
},
|
6380
|
-
squashPolicyPush: (
|
6362
|
+
squashPolicyPush: (policy3) => {
|
6381
6363
|
var _a;
|
6382
|
-
return `${
|
6364
|
+
return `${policy3.name}--${policy3.as}--${policy3.for}--${(_a = policy3.to) == null ? void 0 : _a.join(",")}--${policy3.on}`;
|
6365
|
+
},
|
6366
|
+
unsquashPolicyPush: (policy3) => {
|
6367
|
+
const splitted = policy3.split("--");
|
6368
|
+
return {
|
6369
|
+
name: splitted[0],
|
6370
|
+
as: splitted[1],
|
6371
|
+
for: splitted[2],
|
6372
|
+
to: splitted[3].split(","),
|
6373
|
+
on: splitted[4] !== "undefined" ? splitted[4] : void 0
|
6374
|
+
};
|
6383
6375
|
},
|
6384
6376
|
squashPK: (pk) => {
|
6385
6377
|
return `${pk.columns.join(",")};${pk.name}`;
|
@@ -6493,8 +6485,8 @@ var init_pgSchema = __esm({
|
|
6493
6485
|
return PgSquasher.squashUnique(unq);
|
6494
6486
|
}
|
6495
6487
|
);
|
6496
|
-
const squashedPolicies = mapValues(it[1].policies, (
|
6497
|
-
return action === "push" ? PgSquasher.squashPolicyPush(
|
6488
|
+
const squashedPolicies = mapValues(it[1].policies, (policy3) => {
|
6489
|
+
return action === "push" ? PgSquasher.squashPolicyPush(policy3) : PgSquasher.squashPolicy(policy3);
|
6498
6490
|
});
|
6499
6491
|
const squashedChecksContraints = mapValues(
|
6500
6492
|
it[1].checkConstraints,
|
@@ -6882,6 +6874,13 @@ function findAddedAndRemoved(columnNames1, columnNames2) {
|
|
6882
6874
|
const removedColumns = columnNames1.filter((it) => !set2.has(it));
|
6883
6875
|
return { addedColumns, removedColumns };
|
6884
6876
|
}
|
6877
|
+
function escapeSingleQuotes(str) {
|
6878
|
+
return str.replace(/'/g, "''");
|
6879
|
+
}
|
6880
|
+
function unescapeSingleQuotes(str, ignoreFirstAndLastChar) {
|
6881
|
+
const regex = ignoreFirstAndLastChar ? /(?<!^)'(?!$)/g : /'/g;
|
6882
|
+
return str.replace(/''/g, "'").replace(regex, "\\'");
|
6883
|
+
}
|
6885
6884
|
var import_fs, import_path, import_url, copy, objectValues, assertV1OutFolder, dryJournal, prepareOutFolder, validatorForDialect, validateWithReport, prepareMigrationFolder, prepareMigrationMeta, schemaRenameKey, tableRenameKey, columnRenameKey, normaliseSQLiteUrl, normalisePGliteUrl;
|
6886
6885
|
var init_utils = __esm({
|
6887
6886
|
"src/utils.ts"() {
|
@@ -11447,6 +11446,25 @@ var require_glob = __commonJS({
|
|
11447
11446
|
}
|
11448
11447
|
});
|
11449
11448
|
|
11449
|
+
// src/extensions/getTablesFilterByExtensions.ts
|
11450
|
+
var getTablesFilterByExtensions;
|
11451
|
+
var init_getTablesFilterByExtensions = __esm({
|
11452
|
+
"src/extensions/getTablesFilterByExtensions.ts"() {
|
11453
|
+
"use strict";
|
11454
|
+
getTablesFilterByExtensions = ({
|
11455
|
+
extensionsFilters,
|
11456
|
+
dialect: dialect4
|
11457
|
+
}) => {
|
11458
|
+
if (extensionsFilters) {
|
11459
|
+
if (extensionsFilters.includes("postgis") && dialect4 === "postgresql") {
|
11460
|
+
return ["!geography_columns", "!geometry_columns", "!spatial_ref_sys"];
|
11461
|
+
}
|
11462
|
+
}
|
11463
|
+
return [];
|
11464
|
+
};
|
11465
|
+
}
|
11466
|
+
});
|
11467
|
+
|
11450
11468
|
// src/schemaValidator.ts
|
11451
11469
|
var dialects, dialect3, commonSquashedSchema, commonSchema;
|
11452
11470
|
var init_schemaValidator = __esm({
|
@@ -11494,7 +11512,7 @@ var init_outputs = __esm({
|
|
11494
11512
|
`Please specify a 'driver' param in config. It will help drizzle to know how to query you database. You can read more about drizzle.config: https://orm.drizzle.team/kit-docs/config-reference`
|
11495
11513
|
),
|
11496
11514
|
noDialect: () => withStyle.error(
|
11497
|
-
`Please specify 'dialect' param in config, either of '
|
11515
|
+
`Please specify 'dialect' param in config, either of 'postgresql', 'mysql', 'sqlite' or 'turso'`
|
11498
11516
|
)
|
11499
11517
|
},
|
11500
11518
|
common: {
|
@@ -17651,6 +17669,7 @@ var init_utils4 = __esm({
|
|
17651
17669
|
import_hanji2 = __toESM(require_hanji());
|
17652
17670
|
import_path2 = require("path");
|
17653
17671
|
init_lib();
|
17672
|
+
init_getTablesFilterByExtensions();
|
17654
17673
|
init_global();
|
17655
17674
|
init_schemaValidator();
|
17656
17675
|
init_serializer();
|
@@ -17741,7 +17760,7 @@ var init_utils4 = __esm({
|
|
17741
17760
|
name: options.name,
|
17742
17761
|
custom: options.custom || false,
|
17743
17762
|
prefix: prefix2,
|
17744
|
-
breakpoints: breakpoints
|
17763
|
+
breakpoints: breakpoints ?? true,
|
17745
17764
|
schema: schema5,
|
17746
17765
|
out: out || "drizzle",
|
17747
17766
|
bundle: driver2 === "expo",
|
@@ -17792,13 +17811,7 @@ var init_utils4 = __esm({
|
|
17792
17811
|
const tablesFilter = tablesFilterConfig ? typeof tablesFilterConfig === "string" ? [tablesFilterConfig] : tablesFilterConfig : [];
|
17793
17812
|
const schemasFilterConfig = config.schemaFilter;
|
17794
17813
|
const schemasFilter = schemasFilterConfig ? typeof schemasFilterConfig === "string" ? [schemasFilterConfig] : schemasFilterConfig : [];
|
17795
|
-
|
17796
|
-
if (config.extensionsFilters.includes("postgis") && config.dialect === "postgresql") {
|
17797
|
-
tablesFilter.push(
|
17798
|
-
...["!geography_columns", "!geometry_columns", "!spatial_ref_sys"]
|
17799
|
-
);
|
17800
|
-
}
|
17801
|
-
}
|
17814
|
+
tablesFilter.push(...getTablesFilterByExtensions(config));
|
17802
17815
|
if (config.dialect === "postgresql") {
|
17803
17816
|
const parsed2 = postgresCredentials.safeParse(config);
|
17804
17817
|
if (!parsed2.success) {
|
@@ -18255,15 +18268,15 @@ function clearDefaults(defaultValue, collate) {
|
|
18255
18268
|
if (defaultValue.startsWith(collate)) {
|
18256
18269
|
resultDefault = resultDefault.substring(collate.length, defaultValue.length).replace(/\\/g, "");
|
18257
18270
|
if (resultDefault.startsWith("'") && resultDefault.endsWith("'")) {
|
18258
|
-
return `('${resultDefault.substring(1, resultDefault.length - 1)}')`;
|
18271
|
+
return `('${escapeSingleQuotes(resultDefault.substring(1, resultDefault.length - 1))}')`;
|
18259
18272
|
} else {
|
18260
|
-
return `'${resultDefault}'`;
|
18273
|
+
return `'${escapeSingleQuotes(resultDefault.substring(1, resultDefault.length - 1))}'`;
|
18261
18274
|
}
|
18262
18275
|
} else {
|
18263
18276
|
return `(${resultDefault})`;
|
18264
18277
|
}
|
18265
18278
|
}
|
18266
|
-
var import_drizzle_orm2, import_mysql_core2, indexName, generateMySqlSnapshot, fromDatabase;
|
18279
|
+
var import_drizzle_orm2, import_mysql_core2, indexName, handleEnumType, generateMySqlSnapshot, fromDatabase;
|
18267
18280
|
var init_mysqlSerializer = __esm({
|
18268
18281
|
"src/serializer/mysqlSerializer.ts"() {
|
18269
18282
|
"use strict";
|
@@ -18271,10 +18284,17 @@ var init_mysqlSerializer = __esm({
|
|
18271
18284
|
import_drizzle_orm2 = require("drizzle-orm");
|
18272
18285
|
import_mysql_core2 = require("drizzle-orm/mysql-core");
|
18273
18286
|
init_outputs();
|
18287
|
+
init_utils();
|
18274
18288
|
init_utils5();
|
18275
18289
|
indexName = (tableName, columns) => {
|
18276
18290
|
return `${tableName}_${columns.join("_")}_index`;
|
18277
18291
|
};
|
18292
|
+
handleEnumType = (type) => {
|
18293
|
+
let str = type.split("(")[1];
|
18294
|
+
str = str.substring(0, str.length - 1);
|
18295
|
+
const values = str.split(",").map((v) => `'${escapeSingleQuotes(v.substring(1, v.length - 1))}'`);
|
18296
|
+
return `enum(${values.join(",")})`;
|
18297
|
+
};
|
18278
18298
|
generateMySqlSnapshot = (tables, views, casing2) => {
|
18279
18299
|
const dialect4 = new import_mysql_core2.MySqlDialect({ casing: casing2 });
|
18280
18300
|
const result = {};
|
@@ -18301,12 +18321,13 @@ var init_mysqlSerializer = __esm({
|
|
18301
18321
|
columns.forEach((column7) => {
|
18302
18322
|
const name = getColumnCasing(column7, casing2);
|
18303
18323
|
const notNull = column7.notNull;
|
18304
|
-
const
|
18324
|
+
const sqlType = column7.getSQLType();
|
18325
|
+
const sqlTypeLowered = sqlType.toLowerCase();
|
18305
18326
|
const autoIncrement = typeof column7.autoIncrement === "undefined" ? false : column7.autoIncrement;
|
18306
18327
|
const generated = column7.generated;
|
18307
18328
|
const columnToSet = {
|
18308
18329
|
name,
|
18309
|
-
type:
|
18330
|
+
type: sqlType.startsWith("enum") ? handleEnumType(sqlType) : sqlType,
|
18310
18331
|
primaryKey: false,
|
18311
18332
|
// If field is autoincrement it's notNull by default
|
18312
18333
|
// notNull: autoIncrement ? true : notNull,
|
@@ -18353,7 +18374,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
|
|
18353
18374
|
columnToSet.default = sqlToStr(column7.default, casing2);
|
18354
18375
|
} else {
|
18355
18376
|
if (typeof column7.default === "string") {
|
18356
|
-
columnToSet.default = `'${column7.default}'`;
|
18377
|
+
columnToSet.default = `'${escapeSingleQuotes(column7.default)}'`;
|
18357
18378
|
} else {
|
18358
18379
|
if (sqlTypeLowered === "json") {
|
18359
18380
|
columnToSet.default = `'${JSON.stringify(column7.default)}'`;
|
@@ -18724,15 +18745,15 @@ ${withStyle.errorWarning(
|
|
18724
18745
|
changedType = columnType.replace("bigint unsigned", "serial");
|
18725
18746
|
}
|
18726
18747
|
}
|
18727
|
-
if (columnType.
|
18728
|
-
changedType = "
|
18748
|
+
if (columnType.includes("decimal(10,0)")) {
|
18749
|
+
changedType = columnType.replace("decimal(10,0)", "decimal");
|
18729
18750
|
}
|
18730
18751
|
let onUpdate = void 0;
|
18731
18752
|
if (columnType.startsWith("timestamp") && typeof columnExtra !== "undefined" && columnExtra.includes("on update CURRENT_TIMESTAMP")) {
|
18732
18753
|
onUpdate = true;
|
18733
18754
|
}
|
18734
18755
|
const newColumn = {
|
18735
|
-
default: columnDefault === null ? void 0 : /^-?[\d.]+(?:e-?\d+)?$/.test(columnDefault) && !["decimal", "char", "varchar"].some((type) => columnType.startsWith(type)) ? Number(columnDefault) : isDefaultAnExpression ? clearDefaults(columnDefault, collation) : `'${columnDefault}'`,
|
18756
|
+
default: columnDefault === null || columnDefault === void 0 ? void 0 : /^-?[\d.]+(?:e-?\d+)?$/.test(columnDefault) && !["decimal", "char", "varchar"].some((type) => columnType.startsWith(type)) ? Number(columnDefault) : isDefaultAnExpression ? clearDefaults(columnDefault, collation) : `'${escapeSingleQuotes(columnDefault)}'`,
|
18736
18757
|
autoincrement: isAutoincrement,
|
18737
18758
|
name: columnName,
|
18738
18759
|
type: changedType,
|
@@ -19081,6 +19102,24 @@ var init_pgImports = __esm({
|
|
19081
19102
|
}
|
19082
19103
|
});
|
19083
19104
|
|
19105
|
+
// src/extensions/vector.ts
|
19106
|
+
var vectorOps;
|
19107
|
+
var init_vector = __esm({
|
19108
|
+
"src/extensions/vector.ts"() {
|
19109
|
+
"use strict";
|
19110
|
+
vectorOps = [
|
19111
|
+
"vector_l2_ops",
|
19112
|
+
"vector_ip_ops",
|
19113
|
+
"vector_cosine_ops",
|
19114
|
+
"vector_l1_ops",
|
19115
|
+
"bit_hamming_ops",
|
19116
|
+
"bit_jaccard_ops",
|
19117
|
+
"halfvec_l2_ops",
|
19118
|
+
"sparsevec_l2_ops"
|
19119
|
+
];
|
19120
|
+
}
|
19121
|
+
});
|
19122
|
+
|
19084
19123
|
// src/serializer/pgSerializer.ts
|
19085
19124
|
var pgSerializer_exports = {};
|
19086
19125
|
__export(pgSerializer_exports, {
|
@@ -19272,7 +19311,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
|
|
19272
19311
|
columnToSet.default = sqlToStr(column7.default, casing2);
|
19273
19312
|
} else {
|
19274
19313
|
if (typeof column7.default === "string") {
|
19275
|
-
columnToSet.default = `'${column7.default}'`;
|
19314
|
+
columnToSet.default = `'${escapeSingleQuotes(column7.default)}'`;
|
19276
19315
|
} else {
|
19277
19316
|
if (sqlTypeLowered === "jsonb" || sqlTypeLowered === "json") {
|
19278
19317
|
columnToSet.default = `'${JSON.stringify(column7.default)}'::${sqlTypeLowered}`;
|
@@ -19455,18 +19494,18 @@ ${withStyle.errorWarning(
|
|
19455
19494
|
with: value.config.with ?? {}
|
19456
19495
|
};
|
19457
19496
|
});
|
19458
|
-
policies2.forEach((
|
19497
|
+
policies2.forEach((policy3) => {
|
19459
19498
|
var _a2, _b2;
|
19460
19499
|
const mappedTo = [];
|
19461
|
-
if (!
|
19500
|
+
if (!policy3.to) {
|
19462
19501
|
mappedTo.push("public");
|
19463
19502
|
} else {
|
19464
|
-
if (
|
19465
|
-
mappedTo.push(
|
19466
|
-
} else if (
|
19467
|
-
mappedTo.push(
|
19468
|
-
} else if (
|
19469
|
-
|
19503
|
+
if (policy3.to && typeof policy3.to === "string") {
|
19504
|
+
mappedTo.push(policy3.to);
|
19505
|
+
} else if (policy3.to && (0, import_drizzle_orm4.is)(policy3.to, import_pg_core2.PgRole)) {
|
19506
|
+
mappedTo.push(policy3.to.name);
|
19507
|
+
} else if (policy3.to && Array.isArray(policy3.to)) {
|
19508
|
+
policy3.to.forEach((it) => {
|
19470
19509
|
if (typeof it === "string") {
|
19471
19510
|
mappedTo.push(it);
|
19472
19511
|
} else if ((0, import_drizzle_orm4.is)(it, import_pg_core2.PgRole)) {
|
@@ -19475,24 +19514,24 @@ ${withStyle.errorWarning(
|
|
19475
19514
|
});
|
19476
19515
|
}
|
19477
19516
|
}
|
19478
|
-
if (policiesObject[
|
19517
|
+
if (policiesObject[policy3.name] !== void 0) {
|
19479
19518
|
console.log(
|
19480
19519
|
`
|
19481
19520
|
${withStyle.errorWarning(
|
19482
19521
|
`We've found duplicated policy name across ${source_default.underline.blue(tableKey2)} table. Please rename one of the policies with ${source_default.underline.blue(
|
19483
|
-
|
19522
|
+
policy3.name
|
19484
19523
|
)} name`
|
19485
19524
|
)}`
|
19486
19525
|
);
|
19487
19526
|
process.exit(1);
|
19488
19527
|
}
|
19489
|
-
policiesObject[
|
19490
|
-
name:
|
19491
|
-
as: ((_a2 =
|
19492
|
-
for: ((_b2 =
|
19528
|
+
policiesObject[policy3.name] = {
|
19529
|
+
name: policy3.name,
|
19530
|
+
as: ((_a2 = policy3.as) == null ? void 0 : _a2.toUpperCase()) ?? "PERMISSIVE",
|
19531
|
+
for: ((_b2 = policy3.for) == null ? void 0 : _b2.toUpperCase()) ?? "ALL",
|
19493
19532
|
to: mappedTo.sort(),
|
19494
|
-
using: (0, import_drizzle_orm4.is)(
|
19495
|
-
withCheck: (0, import_drizzle_orm4.is)(
|
19533
|
+
using: (0, import_drizzle_orm4.is)(policy3.using, import_drizzle_orm4.SQL) ? dialect4.sqlToQuery(policy3.using).sql : void 0,
|
19534
|
+
withCheck: (0, import_drizzle_orm4.is)(policy3.withCheck, import_drizzle_orm4.SQL) ? dialect4.sqlToQuery(policy3.withCheck).sql : void 0
|
19496
19535
|
};
|
19497
19536
|
});
|
19498
19537
|
checks.forEach((check2) => {
|
@@ -19536,28 +19575,28 @@ ${withStyle.errorWarning(
|
|
19536
19575
|
isRLSEnabled: enableRLS
|
19537
19576
|
};
|
19538
19577
|
}
|
19539
|
-
for (const
|
19540
|
-
if (!
|
19578
|
+
for (const policy3 of policies) {
|
19579
|
+
if (!policy3._linkedTable) {
|
19541
19580
|
console.log(
|
19542
19581
|
`
|
19543
19582
|
${withStyle.errorWarning(
|
19544
|
-
`"Policy ${
|
19583
|
+
`"Policy ${policy3.name} was skipped because it was not linked to any table. You should either include the policy in a table or use .link() on the policy to link it to any table you have. For more information, please check:`
|
19545
19584
|
)}`
|
19546
19585
|
);
|
19547
19586
|
continue;
|
19548
19587
|
}
|
19549
|
-
const tableConfig = (0, import_pg_core2.getTableConfig)(
|
19588
|
+
const tableConfig = (0, import_pg_core2.getTableConfig)(policy3._linkedTable);
|
19550
19589
|
const tableKey2 = `${tableConfig.schema ?? "public"}.${tableConfig.name}`;
|
19551
19590
|
const mappedTo = [];
|
19552
|
-
if (!
|
19591
|
+
if (!policy3.to) {
|
19553
19592
|
mappedTo.push("public");
|
19554
19593
|
} else {
|
19555
|
-
if (
|
19556
|
-
mappedTo.push(
|
19557
|
-
} else if (
|
19558
|
-
mappedTo.push(
|
19559
|
-
} else if (
|
19560
|
-
|
19594
|
+
if (policy3.to && typeof policy3.to === "string") {
|
19595
|
+
mappedTo.push(policy3.to);
|
19596
|
+
} else if (policy3.to && (0, import_drizzle_orm4.is)(policy3.to, import_pg_core2.PgRole)) {
|
19597
|
+
mappedTo.push(policy3.to.name);
|
19598
|
+
} else if (policy3.to && Array.isArray(policy3.to)) {
|
19599
|
+
policy3.to.forEach((it) => {
|
19561
19600
|
if (typeof it === "string") {
|
19562
19601
|
mappedTo.push(it);
|
19563
19602
|
} else if ((0, import_drizzle_orm4.is)(it, import_pg_core2.PgRole)) {
|
@@ -19566,30 +19605,31 @@ ${withStyle.errorWarning(
|
|
19566
19605
|
});
|
19567
19606
|
}
|
19568
19607
|
}
|
19569
|
-
if (((_a = result[tableKey2]) == null ? void 0 : _a.policies[
|
19608
|
+
if (((_a = result[tableKey2]) == null ? void 0 : _a.policies[policy3.name]) !== void 0 || policiesToReturn[policy3.name] !== void 0) {
|
19570
19609
|
console.log(
|
19571
19610
|
`
|
19572
19611
|
${withStyle.errorWarning(
|
19573
19612
|
`We've found duplicated policy name across ${source_default.underline.blue(tableKey2)} table. Please rename one of the policies with ${source_default.underline.blue(
|
19574
|
-
|
19613
|
+
policy3.name
|
19575
19614
|
)} name`
|
19576
19615
|
)}`
|
19577
19616
|
);
|
19578
19617
|
process.exit(1);
|
19579
19618
|
}
|
19580
19619
|
const mappedPolicy = {
|
19581
|
-
name:
|
19582
|
-
as: ((_b =
|
19583
|
-
for: ((_c =
|
19620
|
+
name: policy3.name,
|
19621
|
+
as: ((_b = policy3.as) == null ? void 0 : _b.toUpperCase()) ?? "PERMISSIVE",
|
19622
|
+
for: ((_c = policy3.for) == null ? void 0 : _c.toUpperCase()) ?? "ALL",
|
19584
19623
|
to: mappedTo.sort(),
|
19585
|
-
using: (0, import_drizzle_orm4.is)(
|
19586
|
-
withCheck: (0, import_drizzle_orm4.is)(
|
19624
|
+
using: (0, import_drizzle_orm4.is)(policy3.using, import_drizzle_orm4.SQL) ? dialect4.sqlToQuery(policy3.using).sql : void 0,
|
19625
|
+
withCheck: (0, import_drizzle_orm4.is)(policy3.withCheck, import_drizzle_orm4.SQL) ? dialect4.sqlToQuery(policy3.withCheck).sql : void 0
|
19587
19626
|
};
|
19588
19627
|
if (result[tableKey2]) {
|
19589
|
-
result[tableKey2].policies[
|
19628
|
+
result[tableKey2].policies[policy3.name] = mappedPolicy;
|
19590
19629
|
} else {
|
19591
|
-
policiesToReturn[
|
19630
|
+
policiesToReturn[policy3.name] = {
|
19592
19631
|
...mappedPolicy,
|
19632
|
+
schema: tableConfig.schema ?? "public",
|
19593
19633
|
on: `"${tableConfig.schema ?? "public"}"."${tableConfig.name}"`
|
19594
19634
|
};
|
19595
19635
|
}
|
@@ -19800,9 +19840,10 @@ ${withStyle.errorWarning(
|
|
19800
19840
|
--end;
|
19801
19841
|
return start > 0 || end < str.length ? str.substring(start, end) : str.toString();
|
19802
19842
|
};
|
19803
|
-
fromDatabase2 = async (db, tablesFilter = () => true, schemaFilters, entities, progressCallback) => {
|
19843
|
+
fromDatabase2 = async (db, tablesFilter = () => true, schemaFilters, entities, progressCallback, tsSchema) => {
|
19804
19844
|
const result = {};
|
19805
19845
|
const views = {};
|
19846
|
+
const policies = {};
|
19806
19847
|
const internals = { tables: {} };
|
19807
19848
|
const where = schemaFilters.map((t2) => `n.nspname = '${t2}'`).join(" or ");
|
19808
19849
|
const allTables = await db.query(
|
@@ -19932,7 +19973,8 @@ WHERE
|
|
19932
19973
|
}
|
19933
19974
|
}
|
19934
19975
|
}
|
19935
|
-
const
|
19976
|
+
const schemasForLinkedPoliciesInSchema = Object.values((tsSchema == null ? void 0 : tsSchema.policies) ?? {}).map((it) => it.schema);
|
19977
|
+
const wherePolicies = [...schemaFilters, ...schemasForLinkedPoliciesInSchema].map((t2) => `schemaname = '${t2}'`).join(" or ");
|
19936
19978
|
const policiesByTable = {};
|
19937
19979
|
const allPolicies = await db.query(`SELECT schemaname, tablename, policyname as name, permissive as "as", roles as to, cmd as for, qual as using, with_check as "withCheck" FROM pg_policies${wherePolicies === "" ? "" : ` WHERE ${wherePolicies}`};`);
|
19938
19980
|
for (const dbPolicy of allPolicies) {
|
@@ -19948,6 +19990,15 @@ WHERE
|
|
19948
19990
|
[dbPolicy.name]: { ...rest, to: parsedTo, withCheck: parsedWithCheck, using: parsedUsing }
|
19949
19991
|
};
|
19950
19992
|
}
|
19993
|
+
if (tsSchema == null ? void 0 : tsSchema.policies[dbPolicy.name]) {
|
19994
|
+
policies[dbPolicy.name] = {
|
19995
|
+
...rest,
|
19996
|
+
to: parsedTo,
|
19997
|
+
withCheck: parsedWithCheck,
|
19998
|
+
using: parsedUsing,
|
19999
|
+
on: tsSchema == null ? void 0 : tsSchema.policies[dbPolicy.name].on
|
20000
|
+
};
|
20001
|
+
}
|
19951
20002
|
}
|
19952
20003
|
if (progressCallback) {
|
19953
20004
|
progressCallback(
|
@@ -20545,7 +20596,7 @@ WHERE
|
|
20545
20596
|
schemas: schemasObject,
|
20546
20597
|
sequences: sequencesToReturn,
|
20547
20598
|
roles: rolesToReturn,
|
20548
|
-
policies
|
20599
|
+
policies,
|
20549
20600
|
views,
|
20550
20601
|
_meta: {
|
20551
20602
|
schemas: {},
|
@@ -20559,10 +20610,7 @@ WHERE
|
|
20559
20610
|
var _a, _b;
|
20560
20611
|
const columnName = column7.column_name;
|
20561
20612
|
const isArray3 = ((_b = (_a = internals == null ? void 0 : internals.tables[tableName]) == null ? void 0 : _a.columns[columnName]) == null ? void 0 : _b.isArray) ?? false;
|
20562
|
-
if (column7.column_default === null) {
|
20563
|
-
return void 0;
|
20564
|
-
}
|
20565
|
-
if (column7.data_type === "serial" || column7.data_type === "smallserial" || column7.data_type === "bigserial") {
|
20613
|
+
if (column7.column_default === null || column7.column_default === void 0 || column7.data_type === "serial" || column7.data_type === "smallserial" || column7.data_type === "bigserial") {
|
20566
20614
|
return void 0;
|
20567
20615
|
}
|
20568
20616
|
if (column7.column_default.endsWith("[]")) {
|
@@ -20816,6 +20864,7 @@ var init_sqliteSerializer = __esm({
|
|
20816
20864
|
import_drizzle_orm6 = require("drizzle-orm");
|
20817
20865
|
import_sqlite_core2 = require("drizzle-orm/sqlite-core");
|
20818
20866
|
init_outputs();
|
20867
|
+
init_utils();
|
20819
20868
|
init_utils5();
|
20820
20869
|
generateSqliteSnapshot = (tables, views, casing2) => {
|
20821
20870
|
const dialect4 = new import_sqlite_core2.SQLiteSyncDialect({ casing: casing2 });
|
@@ -20859,7 +20908,7 @@ var init_sqliteSerializer = __esm({
|
|
20859
20908
|
if ((0, import_drizzle_orm6.is)(column7.default, import_drizzle_orm6.SQL)) {
|
20860
20909
|
columnToSet.default = sqlToStr(column7.default, casing2);
|
20861
20910
|
} else {
|
20862
|
-
columnToSet.default = typeof column7.default === "string" ? `'${column7.default}'` : typeof column7.default === "object" || Array.isArray(column7.default) ? `'${JSON.stringify(column7.default)}'` : column7.default;
|
20911
|
+
columnToSet.default = typeof column7.default === "string" ? `'${escapeSingleQuotes(column7.default)}'` : typeof column7.default === "object" || Array.isArray(column7.default) ? `'${JSON.stringify(column7.default)}'` : column7.default;
|
20863
20912
|
}
|
20864
20913
|
}
|
20865
20914
|
columnsObject[name] = columnToSet;
|
@@ -21488,7 +21537,7 @@ ${filenames.join("\n")}
|
|
21488
21537
|
});
|
21489
21538
|
|
21490
21539
|
// src/migrationPreparator.ts
|
21491
|
-
var import_crypto, import_fs4, prepareMySqlDbPushSnapshot, prepareSQLiteDbPushSnapshot,
|
21540
|
+
var import_crypto, import_fs4, prepareMySqlDbPushSnapshot, prepareSQLiteDbPushSnapshot, prepareMySqlMigrationSnapshot, prepareSqliteMigrationSnapshot, fillPgSnapshot, preparePgMigrationSnapshot, preparePrevSnapshot;
|
21492
21541
|
var init_migrationPreparator = __esm({
|
21493
21542
|
"src/migrationPreparator.ts"() {
|
21494
21543
|
"use strict";
|
@@ -21520,14 +21569,6 @@ var init_migrationPreparator = __esm({
|
|
21520
21569
|
};
|
21521
21570
|
return { prev, cur: result };
|
21522
21571
|
};
|
21523
|
-
preparePgDbPushSnapshot = async (prev, schemaPath, casing2, schemaFilter = ["public"]) => {
|
21524
|
-
const serialized = await serializePg(schemaPath, casing2, schemaFilter);
|
21525
|
-
const id = (0, import_crypto.randomUUID)();
|
21526
|
-
const idPrev = prev.id;
|
21527
|
-
const { version: version3, dialect: dialect4, ...rest } = serialized;
|
21528
|
-
const result = { version: version3, dialect: dialect4, id, prevId: idPrev, ...rest };
|
21529
|
-
return { prev, cur: result };
|
21530
|
-
};
|
21531
21572
|
prepareMySqlMigrationSnapshot = async (migrationFolders, schemaPath, casing2) => {
|
21532
21573
|
const prevSnapshot = mysqlSchema.parse(
|
21533
21574
|
preparePrevSnapshot(migrationFolders, dryMySql)
|
@@ -24601,7 +24642,7 @@ function fromJson(statements, dialect4, action, json2) {
|
|
24601
24642
|
}).filter((it) => it !== "");
|
24602
24643
|
return result;
|
24603
24644
|
}
|
24604
|
-
var
|
24645
|
+
var parseType, Convertor, PgCreateRoleConvertor, PgDropRoleConvertor, PgRenameRoleConvertor, PgAlterRoleConvertor, PgCreatePolicyConvertor, PgDropPolicyConvertor, PgRenamePolicyConvertor, PgAlterPolicyConvertor, PgCreateIndPolicyConvertor, PgDropIndPolicyConvertor, PgRenameIndPolicyConvertor, PgAlterIndPolicyConvertor, PgEnableRlsConvertor, PgDisableRlsConvertor, PgCreateTableConvertor, MySqlCreateTableConvertor, SQLiteCreateTableConvertor, PgCreateViewConvertor, MySqlCreateViewConvertor, SqliteCreateViewConvertor, PgDropViewConvertor, MySqlDropViewConvertor, SqliteDropViewConvertor, MySqlAlterViewConvertor, PgRenameViewConvertor, MySqlRenameViewConvertor, PgAlterViewSchemaConvertor, PgAlterViewAddWithOptionConvertor, PgAlterViewDropWithOptionConvertor, PgAlterViewAlterTablespaceConvertor, PgAlterViewAlterUsingConvertor, PgAlterTableAlterColumnSetGenerated, PgAlterTableAlterColumnDropGenerated, PgAlterTableAlterColumnAlterGenerated, PgAlterTableAddUniqueConstraintConvertor, PgAlterTableDropUniqueConstraintConvertor, PgAlterTableAddCheckConstraintConvertor, PgAlterTableDeleteCheckConstraintConvertor, MySQLAlterTableAddUniqueConstraintConvertor, MySQLAlterTableDropUniqueConstraintConvertor, MySqlAlterTableAddCheckConstraintConvertor, MySqlAlterTableDeleteCheckConstraintConvertor, CreatePgSequenceConvertor, DropPgSequenceConvertor, RenamePgSequenceConvertor, MovePgSequenceConvertor, AlterPgSequenceConvertor, CreateTypeEnumConvertor, DropTypeEnumConvertor, AlterTypeAddValueConvertor, AlterTypeSetSchemaConvertor, AlterRenameTypeConvertor, AlterTypeDropValueConvertor, PgDropTableConvertor, MySQLDropTableConvertor, SQLiteDropTableConvertor, PgRenameTableConvertor, SqliteRenameTableConvertor, MySqlRenameTableConvertor, PgAlterTableRenameColumnConvertor, MySqlAlterTableRenameColumnConvertor, SQLiteAlterTableRenameColumnConvertor, PgAlterTableDropColumnConvertor, MySqlAlterTableDropColumnConvertor, SQLiteAlterTableDropColumnConvertor, PgAlterTableAddColumnConvertor, MySqlAlterTableAddColumnConvertor, SQLiteAlterTableAddColumnConvertor, PgAlterTableAlterColumnSetTypeConvertor, PgAlterTableAlterColumnSetDefaultConvertor, PgAlterTableAlterColumnDropDefaultConvertor, PgAlterTableAlterColumnDropGeneratedConvertor, PgAlterTableAlterColumnSetExpressionConvertor, PgAlterTableAlterColumnAlterrGeneratedConvertor, SqliteAlterTableAlterColumnDropGeneratedConvertor, SqliteAlterTableAlterColumnSetExpressionConvertor, SqliteAlterTableAlterColumnAlterGeneratedConvertor, MySqlAlterTableAlterColumnAlterrGeneratedConvertor, MySqlAlterTableAddPk, MySqlAlterTableDropPk, LibSQLModifyColumn, MySqlModifyColumn, PgAlterTableCreateCompositePrimaryKeyConvertor, PgAlterTableDeleteCompositePrimaryKeyConvertor, PgAlterTableAlterCompositePrimaryKeyConvertor, MySqlAlterTableCreateCompositePrimaryKeyConvertor, MySqlAlterTableDeleteCompositePrimaryKeyConvertor, MySqlAlterTableAlterCompositePrimaryKeyConvertor, PgAlterTableAlterColumnSetPrimaryKeyConvertor, PgAlterTableAlterColumnDropPrimaryKeyConvertor, PgAlterTableAlterColumnSetNotNullConvertor, PgAlterTableAlterColumnDropNotNullConvertor, PgCreateForeignKeyConvertor, LibSQLCreateForeignKeyConvertor, MySqlCreateForeignKeyConvertor, PgAlterForeignKeyConvertor, PgDeleteForeignKeyConvertor, MySqlDeleteForeignKeyConvertor, CreatePgIndexConvertor, CreateMySqlIndexConvertor, CreateSqliteIndexConvertor, PgDropIndexConvertor, PgCreateSchemaConvertor, PgRenameSchemaConvertor, PgDropSchemaConvertor, PgAlterTableSetSchemaConvertor, PgAlterTableSetNewSchemaConvertor, PgAlterTableRemoveFromSchemaConvertor, SqliteDropIndexConvertor, MySqlDropIndexConvertor, SQLiteRecreateTableConvertor, LibSQLRecreateTableConvertor, convertors;
|
24605
24646
|
var init_sqlgenerator = __esm({
|
24606
24647
|
"src/sqlgenerator.ts"() {
|
24607
24648
|
"use strict";
|
@@ -24609,52 +24650,56 @@ var init_sqlgenerator = __esm({
|
|
24609
24650
|
init_mysqlSchema();
|
24610
24651
|
init_pgSchema();
|
24611
24652
|
init_sqliteSchema();
|
24612
|
-
|
24613
|
-
|
24614
|
-
|
24615
|
-
|
24616
|
-
|
24617
|
-
|
24618
|
-
|
24619
|
-
|
24620
|
-
|
24621
|
-
|
24622
|
-
|
24623
|
-
|
24624
|
-
|
24625
|
-
|
24626
|
-
|
24627
|
-
|
24628
|
-
|
24629
|
-
|
24630
|
-
|
24631
|
-
|
24632
|
-
|
24633
|
-
|
24634
|
-
|
24635
|
-
|
24636
|
-
|
24637
|
-
|
24638
|
-
|
24639
|
-
|
24640
|
-
|
24641
|
-
|
24642
|
-
|
24643
|
-
|
24644
|
-
|
24645
|
-
|
24646
|
-
|
24647
|
-
|
24648
|
-
|
24649
|
-
|
24650
|
-
|
24651
|
-
|
24652
|
-
|
24653
|
-
|
24654
|
-
|
24655
|
-
|
24656
|
-
|
24657
|
-
|
24653
|
+
init_utils();
|
24654
|
+
parseType = (schemaPrefix, type) => {
|
24655
|
+
const pgNativeTypes = [
|
24656
|
+
"uuid",
|
24657
|
+
"smallint",
|
24658
|
+
"integer",
|
24659
|
+
"bigint",
|
24660
|
+
"boolean",
|
24661
|
+
"text",
|
24662
|
+
"varchar",
|
24663
|
+
"serial",
|
24664
|
+
"bigserial",
|
24665
|
+
"decimal",
|
24666
|
+
"numeric",
|
24667
|
+
"real",
|
24668
|
+
"json",
|
24669
|
+
"jsonb",
|
24670
|
+
"time",
|
24671
|
+
"time with time zone",
|
24672
|
+
"time without time zone",
|
24673
|
+
"time",
|
24674
|
+
"timestamp",
|
24675
|
+
"timestamp with time zone",
|
24676
|
+
"timestamp without time zone",
|
24677
|
+
"date",
|
24678
|
+
"interval",
|
24679
|
+
"bigint",
|
24680
|
+
"bigserial",
|
24681
|
+
"double precision",
|
24682
|
+
"interval year",
|
24683
|
+
"interval month",
|
24684
|
+
"interval day",
|
24685
|
+
"interval hour",
|
24686
|
+
"interval minute",
|
24687
|
+
"interval second",
|
24688
|
+
"interval year to month",
|
24689
|
+
"interval day to hour",
|
24690
|
+
"interval day to minute",
|
24691
|
+
"interval day to second",
|
24692
|
+
"interval hour to minute",
|
24693
|
+
"interval hour to second",
|
24694
|
+
"interval minute to second",
|
24695
|
+
"char",
|
24696
|
+
"vector",
|
24697
|
+
"geometry"
|
24698
|
+
];
|
24699
|
+
const arrayDefinitionRegex = /\[\d*(?:\[\d*\])*\]/g;
|
24700
|
+
const arrayDefinition = (type.match(arrayDefinitionRegex) ?? []).join("");
|
24701
|
+
const withoutArrayDefinition = type.replace(arrayDefinitionRegex, "");
|
24702
|
+
return pgNativeTypes.some((it) => type.startsWith(it)) ? `${withoutArrayDefinition}${arrayDefinition}` : `${schemaPrefix}"${withoutArrayDefinition}"${arrayDefinition}`;
|
24658
24703
|
};
|
24659
24704
|
Convertor = class {
|
24660
24705
|
};
|
@@ -24696,14 +24741,14 @@ var init_sqlgenerator = __esm({
|
|
24696
24741
|
}
|
24697
24742
|
convert(statement) {
|
24698
24743
|
var _a, _b, _c;
|
24699
|
-
const
|
24744
|
+
const policy3 = statement.data;
|
24700
24745
|
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
24701
|
-
const usingPart =
|
24702
|
-
const withCheckPart =
|
24703
|
-
const policyToPart = (_a =
|
24746
|
+
const usingPart = policy3.using ? ` USING (${policy3.using})` : "";
|
24747
|
+
const withCheckPart = policy3.withCheck ? ` WITH CHECK (${policy3.withCheck})` : "";
|
24748
|
+
const policyToPart = (_a = policy3.to) == null ? void 0 : _a.map(
|
24704
24749
|
(v) => ["current_user", "current_role", "session_user", "public"].includes(v) ? v : `"${v}"`
|
24705
24750
|
).join(", ");
|
24706
|
-
return `CREATE POLICY "${
|
24751
|
+
return `CREATE POLICY "${policy3.name}" ON ${tableNameWithSchema} AS ${(_b = policy3.as) == null ? void 0 : _b.toUpperCase()} FOR ${(_c = policy3.for) == null ? void 0 : _c.toUpperCase()} TO ${policyToPart}${usingPart}${withCheckPart};`;
|
24707
24752
|
}
|
24708
24753
|
};
|
24709
24754
|
PgDropPolicyConvertor = class extends Convertor {
|
@@ -24711,9 +24756,9 @@ var init_sqlgenerator = __esm({
|
|
24711
24756
|
return statement.type === "drop_policy" && dialect4 === "postgresql";
|
24712
24757
|
}
|
24713
24758
|
convert(statement) {
|
24714
|
-
const
|
24759
|
+
const policy3 = statement.data;
|
24715
24760
|
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
24716
|
-
return `DROP POLICY "${
|
24761
|
+
return `DROP POLICY "${policy3.name}" ON ${tableNameWithSchema} CASCADE;`;
|
24717
24762
|
}
|
24718
24763
|
};
|
24719
24764
|
PgRenamePolicyConvertor = class extends Convertor {
|
@@ -24729,9 +24774,9 @@ var init_sqlgenerator = __esm({
|
|
24729
24774
|
can(statement, dialect4) {
|
24730
24775
|
return statement.type === "alter_policy" && dialect4 === "postgresql";
|
24731
24776
|
}
|
24732
|
-
convert(statement) {
|
24733
|
-
const newPolicy = PgSquasher.unsquashPolicy(statement.newData);
|
24734
|
-
const oldPolicy = PgSquasher.unsquashPolicy(statement.oldData);
|
24777
|
+
convert(statement, _dialect, action) {
|
24778
|
+
const newPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(statement.newData) : PgSquasher.unsquashPolicy(statement.newData);
|
24779
|
+
const oldPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(statement.oldData) : PgSquasher.unsquashPolicy(statement.oldData);
|
24735
24780
|
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
24736
24781
|
const usingPart = newPolicy.using ? ` USING (${newPolicy.using})` : oldPolicy.using ? ` USING (${oldPolicy.using})` : "";
|
24737
24782
|
const withCheckPart = newPolicy.withCheck ? ` WITH CHECK (${newPolicy.withCheck})` : oldPolicy.withCheck ? ` WITH CHECK (${oldPolicy.withCheck})` : "";
|
@@ -24744,13 +24789,13 @@ var init_sqlgenerator = __esm({
|
|
24744
24789
|
}
|
24745
24790
|
convert(statement) {
|
24746
24791
|
var _a, _b, _c;
|
24747
|
-
const
|
24748
|
-
const usingPart =
|
24749
|
-
const withCheckPart =
|
24750
|
-
const policyToPart = (_a =
|
24792
|
+
const policy3 = statement.data;
|
24793
|
+
const usingPart = policy3.using ? ` USING (${policy3.using})` : "";
|
24794
|
+
const withCheckPart = policy3.withCheck ? ` WITH CHECK (${policy3.withCheck})` : "";
|
24795
|
+
const policyToPart = (_a = policy3.to) == null ? void 0 : _a.map(
|
24751
24796
|
(v) => ["current_user", "current_role", "session_user", "public"].includes(v) ? v : `"${v}"`
|
24752
24797
|
).join(", ");
|
24753
|
-
return `CREATE POLICY "${
|
24798
|
+
return `CREATE POLICY "${policy3.name}" ON ${policy3.on} AS ${(_b = policy3.as) == null ? void 0 : _b.toUpperCase()} FOR ${(_c = policy3.for) == null ? void 0 : _c.toUpperCase()} TO ${policyToPart}${usingPart}${withCheckPart};`;
|
24754
24799
|
}
|
24755
24800
|
};
|
24756
24801
|
PgDropIndPolicyConvertor = class extends Convertor {
|
@@ -24758,8 +24803,8 @@ var init_sqlgenerator = __esm({
|
|
24758
24803
|
return statement.type === "drop_ind_policy" && dialect4 === "postgresql";
|
24759
24804
|
}
|
24760
24805
|
convert(statement) {
|
24761
|
-
const
|
24762
|
-
return `DROP POLICY "${
|
24806
|
+
const policy3 = statement.data;
|
24807
|
+
return `DROP POLICY "${policy3.name}" ON ${policy3.on} CASCADE;`;
|
24763
24808
|
}
|
24764
24809
|
};
|
24765
24810
|
PgRenameIndPolicyConvertor = class extends Convertor {
|
@@ -24817,7 +24862,7 @@ var init_sqlgenerator = __esm({
|
|
24817
24862
|
const defaultStatement = column7.default !== void 0 ? ` DEFAULT ${column7.default}` : "";
|
24818
24863
|
const uniqueConstraint4 = column7.isUnique ? ` CONSTRAINT "${column7.uniqueName}" UNIQUE${column7.nullsNotDistinct ? " NULLS NOT DISTINCT" : ""}` : "";
|
24819
24864
|
const schemaPrefix = column7.typeSchema && column7.typeSchema !== "public" ? `"${column7.typeSchema}".` : "";
|
24820
|
-
const type =
|
24865
|
+
const type = parseType(schemaPrefix, column7.type);
|
24821
24866
|
const generated = column7.generated;
|
24822
24867
|
const generatedStatement = generated ? ` GENERATED ALWAYS AS (${generated == null ? void 0 : generated.as}) STORED` : "";
|
24823
24868
|
const unsquashedIdentity = column7.identity ? PgSquasher.unsquashIdentity(column7.identity) : void 0;
|
@@ -25380,7 +25425,7 @@ WITH ${withCheckOption} CHECK OPTION` : "";
|
|
25380
25425
|
const { name, values, schema: schema5 } = st;
|
25381
25426
|
const enumNameWithSchema = schema5 ? `"${schema5}"."${name}"` : `"${name}"`;
|
25382
25427
|
let valuesStatement = "(";
|
25383
|
-
valuesStatement += values.map((it) => `'${it}'`).join(", ");
|
25428
|
+
valuesStatement += values.map((it) => `'${escapeSingleQuotes(it)}'`).join(", ");
|
25384
25429
|
valuesStatement += ")";
|
25385
25430
|
let statement = `CREATE TYPE ${enumNameWithSchema} AS ENUM${valuesStatement};`;
|
25386
25431
|
return statement;
|
@@ -25458,7 +25503,7 @@ WITH ${withCheckOption} CHECK OPTION` : "";
|
|
25458
25503
|
can(statement, dialect4) {
|
25459
25504
|
return statement.type === "drop_table" && dialect4 === "postgresql";
|
25460
25505
|
}
|
25461
|
-
convert(statement) {
|
25506
|
+
convert(statement, _d, action) {
|
25462
25507
|
const { tableName, schema: schema5, policies } = statement;
|
25463
25508
|
const tableNameWithSchema = schema5 ? `"${schema5}"."${tableName}"` : `"${tableName}"`;
|
25464
25509
|
const dropPolicyConvertor = new PgDropPolicyConvertor();
|
@@ -25466,7 +25511,7 @@ WITH ${withCheckOption} CHECK OPTION` : "";
|
|
25466
25511
|
return dropPolicyConvertor.convert({
|
25467
25512
|
type: "drop_policy",
|
25468
25513
|
tableName,
|
25469
|
-
data: PgSquasher.unsquashPolicy(p2),
|
25514
|
+
data: action === "push" ? PgSquasher.unsquashPolicyPush(p2) : PgSquasher.unsquashPolicy(p2),
|
25470
25515
|
schema: schema5
|
25471
25516
|
});
|
25472
25517
|
})) ?? [];
|
@@ -25590,7 +25635,7 @@ WITH ${withCheckOption} CHECK OPTION` : "";
|
|
25590
25635
|
const tableNameWithSchema = schema5 ? `"${schema5}"."${tableName}"` : `"${tableName}"`;
|
25591
25636
|
const defaultStatement = `${column7.default !== void 0 ? ` DEFAULT ${column7.default}` : ""}`;
|
25592
25637
|
const schemaPrefix = column7.typeSchema && column7.typeSchema !== "public" ? `"${column7.typeSchema}".` : "";
|
25593
|
-
const fixedType =
|
25638
|
+
const fixedType = parseType(schemaPrefix, column7.type);
|
25594
25639
|
const notNullStatement = `${notNull ? " NOT NULL" : ""}`;
|
25595
25640
|
const unsquashedIdentity = identity ? PgSquasher.unsquashIdentity(identity) : void 0;
|
25596
25641
|
const identityWithSchema = schema5 ? `"${schema5}"."${unsquashedIdentity == null ? void 0 : unsquashedIdentity.name}"` : `"${unsquashedIdentity == null ? void 0 : unsquashedIdentity.name}"`;
|
@@ -26161,8 +26206,9 @@ WITH ${withCheckOption} CHECK OPTION` : "";
|
|
26161
26206
|
statement.new
|
26162
26207
|
);
|
26163
26208
|
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
26164
|
-
|
26165
|
-
|
26209
|
+
console.log(statement.oldConstraintName, statement.newConstraintName);
|
26210
|
+
return `ALTER TABLE ${tableNameWithSchema} DROP CONSTRAINT "${statement.oldConstraintName}";
|
26211
|
+
${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${statement.newConstraintName}" PRIMARY KEY("${newColumns.join('","')}");`;
|
26166
26212
|
}
|
26167
26213
|
};
|
26168
26214
|
MySqlAlterTableCreateCompositePrimaryKeyConvertor = class extends Convertor {
|
@@ -28374,30 +28420,29 @@ var init_jsonStatements = __esm({
|
|
28374
28420
|
};
|
28375
28421
|
});
|
28376
28422
|
};
|
28377
|
-
prepareAddCompositePrimaryKeyPg = (tableName, schema5, pks
|
28423
|
+
prepareAddCompositePrimaryKeyPg = (tableName, schema5, pks) => {
|
28378
28424
|
return Object.values(pks).map((it) => {
|
28379
|
-
const unsquashed = PgSquasher.unsquashPK(it);
|
28380
28425
|
return {
|
28381
28426
|
type: "create_composite_pk",
|
28382
28427
|
tableName,
|
28383
28428
|
data: it,
|
28384
28429
|
schema: schema5,
|
28385
|
-
constraintName:
|
28430
|
+
constraintName: PgSquasher.unsquashPK(it).name
|
28386
28431
|
};
|
28387
28432
|
});
|
28388
28433
|
};
|
28389
|
-
prepareDeleteCompositePrimaryKeyPg = (tableName, schema5, pks
|
28434
|
+
prepareDeleteCompositePrimaryKeyPg = (tableName, schema5, pks) => {
|
28390
28435
|
return Object.values(pks).map((it) => {
|
28391
28436
|
return {
|
28392
28437
|
type: "delete_composite_pk",
|
28393
28438
|
tableName,
|
28394
28439
|
data: it,
|
28395
28440
|
schema: schema5,
|
28396
|
-
constraintName:
|
28441
|
+
constraintName: PgSquasher.unsquashPK(it).name
|
28397
28442
|
};
|
28398
28443
|
});
|
28399
28444
|
};
|
28400
|
-
prepareAlterCompositePrimaryKeyPg = (tableName, schema5, pks
|
28445
|
+
prepareAlterCompositePrimaryKeyPg = (tableName, schema5, pks) => {
|
28401
28446
|
return Object.values(pks).map((it) => {
|
28402
28447
|
return {
|
28403
28448
|
type: "alter_composite_pk",
|
@@ -28405,8 +28450,8 @@ var init_jsonStatements = __esm({
|
|
28405
28450
|
old: it.__old,
|
28406
28451
|
new: it.__new,
|
28407
28452
|
schema: schema5,
|
28408
|
-
oldConstraintName:
|
28409
|
-
newConstraintName:
|
28453
|
+
oldConstraintName: PgSquasher.unsquashPK(it.__old).name,
|
28454
|
+
newConstraintName: PgSquasher.unsquashPK(it.__new).name
|
28410
28455
|
};
|
28411
28456
|
});
|
28412
28457
|
};
|
@@ -28462,18 +28507,19 @@ var init_jsonStatements = __esm({
|
|
28462
28507
|
type: "create_composite_pk",
|
28463
28508
|
tableName,
|
28464
28509
|
data: it,
|
28465
|
-
constraintName:
|
28510
|
+
constraintName: unsquashed.name
|
28466
28511
|
});
|
28467
28512
|
}
|
28468
28513
|
return res;
|
28469
28514
|
};
|
28470
28515
|
prepareDeleteCompositePrimaryKeyMySql = (tableName, pks, json1) => {
|
28471
28516
|
return Object.values(pks).map((it) => {
|
28517
|
+
const unsquashed = MySqlSquasher.unsquashPK(it);
|
28472
28518
|
return {
|
28473
28519
|
type: "delete_composite_pk",
|
28474
28520
|
tableName,
|
28475
28521
|
data: it,
|
28476
|
-
constraintName:
|
28522
|
+
constraintName: unsquashed.name
|
28477
28523
|
};
|
28478
28524
|
});
|
28479
28525
|
};
|
@@ -29434,8 +29480,10 @@ var init_snapshotsDiffer = __esm({
|
|
29434
29480
|
const { renamed, created: created2, deleted: deleted2 } = await policyResolver2({
|
29435
29481
|
tableName: entry.name,
|
29436
29482
|
schema: entry.schema,
|
29437
|
-
deleted: entry.policies.deleted.map(
|
29438
|
-
|
29483
|
+
deleted: entry.policies.deleted.map(
|
29484
|
+
action === "push" ? PgSquasher.unsquashPolicyPush : PgSquasher.unsquashPolicy
|
29485
|
+
),
|
29486
|
+
created: entry.policies.added.map(action === "push" ? PgSquasher.unsquashPolicyPush : PgSquasher.unsquashPolicy)
|
29439
29487
|
});
|
29440
29488
|
if (created2.length > 0) {
|
29441
29489
|
policyCreates.push({
|
@@ -29472,12 +29520,12 @@ var init_snapshotsDiffer = __esm({
|
|
29472
29520
|
(tableKey2, tableValue) => {
|
29473
29521
|
const patchedPolicies = mapKeys(
|
29474
29522
|
tableValue.policies,
|
29475
|
-
(policyKey,
|
29523
|
+
(policyKey, policy3) => {
|
29476
29524
|
const rens = policyRenamesDict[`${tableValue.schema || "public"}.${tableValue.name}`] || [];
|
29477
29525
|
const newName = columnChangeFor(policyKey, rens);
|
29478
|
-
const unsquashedPolicy = PgSquasher.unsquashPolicy(
|
29526
|
+
const unsquashedPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(policy3) : PgSquasher.unsquashPolicy(policy3);
|
29479
29527
|
unsquashedPolicy.name = newName;
|
29480
|
-
|
29528
|
+
policy3 = PgSquasher.squashPolicy(unsquashedPolicy);
|
29481
29529
|
return newName;
|
29482
29530
|
}
|
29483
29531
|
);
|
@@ -29489,8 +29537,12 @@ var init_snapshotsDiffer = __esm({
|
|
29489
29537
|
const indPolicyCreates = [];
|
29490
29538
|
const indPolicyDeletes = [];
|
29491
29539
|
const { renamed: indPolicyRenames, created, deleted } = await indPolicyResolver2({
|
29492
|
-
deleted: indPolicyRes.deleted.map(
|
29493
|
-
|
29540
|
+
deleted: indPolicyRes.deleted.map(
|
29541
|
+
(t2) => action === "push" ? PgSquasher.unsquashPolicyPush(t2.values) : PgSquasher.unsquashPolicy(t2.values)
|
29542
|
+
),
|
29543
|
+
created: indPolicyRes.added.map(
|
29544
|
+
(t2) => action === "push" ? PgSquasher.unsquashPolicyPush(t2.values) : PgSquasher.unsquashPolicy(t2.values)
|
29545
|
+
)
|
29494
29546
|
});
|
29495
29547
|
if (created.length > 0) {
|
29496
29548
|
indPolicyCreates.push({
|
@@ -29614,17 +29666,17 @@ var init_snapshotsDiffer = __esm({
|
|
29614
29666
|
const jsonDeletedCheckConstraints = [];
|
29615
29667
|
const jsonCreatedCheckConstraints = [];
|
29616
29668
|
for (let it of alteredTables) {
|
29617
|
-
let addedColumns
|
29669
|
+
let addedColumns;
|
29618
29670
|
for (const addedPkName of Object.keys(it.addedCompositePKs)) {
|
29619
29671
|
const addedPkColumns = it.addedCompositePKs[addedPkName];
|
29620
|
-
addedColumns =
|
29672
|
+
addedColumns = PgSquasher.unsquashPK(addedPkColumns);
|
29621
29673
|
}
|
29622
|
-
let deletedColumns
|
29674
|
+
let deletedColumns;
|
29623
29675
|
for (const deletedPkName of Object.keys(it.deletedCompositePKs)) {
|
29624
29676
|
const deletedPkColumns = it.deletedCompositePKs[deletedPkName];
|
29625
|
-
deletedColumns =
|
29677
|
+
deletedColumns = PgSquasher.unsquashPK(deletedPkColumns);
|
29626
29678
|
}
|
29627
|
-
const doPerformDeleteAndCreate = JSON.stringify(addedColumns) !== JSON.stringify(deletedColumns);
|
29679
|
+
const doPerformDeleteAndCreate = JSON.stringify(addedColumns ?? {}) !== JSON.stringify(deletedColumns ?? {});
|
29628
29680
|
let addedCompositePKs = [];
|
29629
29681
|
let deletedCompositePKs = [];
|
29630
29682
|
let alteredCompositePKs = [];
|
@@ -29632,22 +29684,18 @@ var init_snapshotsDiffer = __esm({
|
|
29632
29684
|
addedCompositePKs = prepareAddCompositePrimaryKeyPg(
|
29633
29685
|
it.name,
|
29634
29686
|
it.schema,
|
29635
|
-
it.addedCompositePKs
|
29636
|
-
curFull
|
29687
|
+
it.addedCompositePKs
|
29637
29688
|
);
|
29638
29689
|
deletedCompositePKs = prepareDeleteCompositePrimaryKeyPg(
|
29639
29690
|
it.name,
|
29640
29691
|
it.schema,
|
29641
|
-
it.deletedCompositePKs
|
29642
|
-
prevFull
|
29692
|
+
it.deletedCompositePKs
|
29643
29693
|
);
|
29644
29694
|
}
|
29645
29695
|
alteredCompositePKs = prepareAlterCompositePrimaryKeyPg(
|
29646
29696
|
it.name,
|
29647
29697
|
it.schema,
|
29648
|
-
it.alteredCompositePKs
|
29649
|
-
prevFull,
|
29650
|
-
curFull
|
29698
|
+
it.alteredCompositePKs
|
29651
29699
|
);
|
29652
29700
|
let addedUniqueConstraints = [];
|
29653
29701
|
let deletedUniqueConstraints = [];
|
@@ -29766,9 +29814,9 @@ var init_snapshotsDiffer = __esm({
|
|
29766
29814
|
);
|
29767
29815
|
}
|
29768
29816
|
typedResult.alteredPolicies.forEach(({ values }) => {
|
29769
|
-
const
|
29770
|
-
const newPolicy = PgSquasher.unsquashPolicy(json2.policies[
|
29771
|
-
const oldPolicy = PgSquasher.unsquashPolicy(json1.policies[
|
29817
|
+
const policy3 = action === "push" ? PgSquasher.unsquashPolicyPush(values) : PgSquasher.unsquashPolicy(values);
|
29818
|
+
const newPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(json2.policies[policy3.name].values) : PgSquasher.unsquashPolicy(json2.policies[policy3.name].values);
|
29819
|
+
const oldPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(json2.policies[policy3.name].values) : PgSquasher.unsquashPolicy(json1.policies[policy3.name].values);
|
29772
29820
|
if (newPolicy.as !== oldPolicy.as) {
|
29773
29821
|
jsonDropIndPoliciesStatements.push(
|
29774
29822
|
...prepareDropIndPolicyJsons(
|
@@ -29827,8 +29875,8 @@ var init_snapshotsDiffer = __esm({
|
|
29827
29875
|
}
|
29828
29876
|
alteredTables.forEach((it) => {
|
29829
29877
|
Object.keys(it.alteredPolicies).forEach((policyName) => {
|
29830
|
-
const newPolicy = PgSquasher.unsquashPolicy(it.alteredPolicies[policyName].__new);
|
29831
|
-
const oldPolicy = PgSquasher.unsquashPolicy(it.alteredPolicies[policyName].__old);
|
29878
|
+
const newPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(it.alteredPolicies[policyName].__new) : PgSquasher.unsquashPolicy(it.alteredPolicies[policyName].__new);
|
29879
|
+
const oldPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(it.alteredPolicies[policyName].__old) : PgSquasher.unsquashPolicy(it.alteredPolicies[policyName].__old);
|
29832
29880
|
if (newPolicy.as !== oldPolicy.as) {
|
29833
29881
|
jsonDropPoliciesStatements.push(
|
29834
29882
|
...prepareDropPolicyJsons(
|
@@ -29882,7 +29930,8 @@ var init_snapshotsDiffer = __esm({
|
|
29882
29930
|
if (policiesInPreviousState.length > 0 && policiesInCurrentState.length === 0 && !table4.isRLSEnabled) {
|
29883
29931
|
jsonDisableRLSStatements.push({ type: "disable_rls", tableName: table4.name, schema: table4.schema });
|
29884
29932
|
}
|
29885
|
-
|
29933
|
+
const wasRlsEnabled = tableInPreviousState ? tableInPreviousState.isRLSEnabled : false;
|
29934
|
+
if (table4.isRLSEnabled !== wasRlsEnabled) {
|
29886
29935
|
if (table4.isRLSEnabled) {
|
29887
29936
|
jsonEnableRLSStatements.push({ type: "enable_rls", tableName: table4.name, schema: table4.schema });
|
29888
29937
|
} else if (!table4.isRLSEnabled && policiesInCurrentState.length === 0) {
|
@@ -30009,7 +30058,11 @@ var init_snapshotsDiffer = __esm({
|
|
30009
30058
|
});
|
30010
30059
|
jsonCreatePoliciesStatements.push(...[].concat(
|
30011
30060
|
...createdTables.map(
|
30012
|
-
(it) => prepareCreatePolicyJsons(
|
30061
|
+
(it) => prepareCreatePolicyJsons(
|
30062
|
+
it.name,
|
30063
|
+
it.schema,
|
30064
|
+
Object.values(it.policies).map(action === "push" ? PgSquasher.unsquashPolicyPush : PgSquasher.unsquashPolicy)
|
30065
|
+
)
|
30013
30066
|
)
|
30014
30067
|
));
|
30015
30068
|
const createViews = [];
|
@@ -30224,7 +30277,7 @@ var init_snapshotsDiffer = __esm({
|
|
30224
30277
|
}
|
30225
30278
|
return true;
|
30226
30279
|
});
|
30227
|
-
const sqlStatements = fromJson(filteredEnumsJsonStatements, "postgresql");
|
30280
|
+
const sqlStatements = fromJson(filteredEnumsJsonStatements, "postgresql", action);
|
30228
30281
|
const uniqueSqlStatements = [];
|
30229
30282
|
sqlStatements.forEach((ss) => {
|
30230
30283
|
if (!uniqueSqlStatements.includes(ss)) {
|
@@ -30641,9 +30694,9 @@ var init_snapshotsDiffer = __esm({
|
|
30641
30694
|
jsonStatements.push(...jsonDeletedCompositePKs);
|
30642
30695
|
jsonStatements.push(...jsonTableAlternations);
|
30643
30696
|
jsonStatements.push(...jsonAddedCompositePKs);
|
30697
|
+
jsonStatements.push(...jsonAddColumnsStatemets);
|
30644
30698
|
jsonStatements.push(...jsonAddedUniqueConstraints);
|
30645
30699
|
jsonStatements.push(...jsonDeletedUniqueConstraints);
|
30646
|
-
jsonStatements.push(...jsonAddColumnsStatemets);
|
30647
30700
|
jsonStatements.push(...jsonCreateReferencesForCreatedTables);
|
30648
30701
|
jsonStatements.push(...jsonCreateIndexesForCreatedTables);
|
30649
30702
|
jsonStatements.push(...jsonCreatedCheckConstraints);
|
@@ -33050,13 +33103,7 @@ var init_migrate = __esm({
|
|
33050
33103
|
console.error(e2);
|
33051
33104
|
}
|
33052
33105
|
};
|
33053
|
-
preparePgPush = async (
|
33054
|
-
const { prev, cur } = await preparePgDbPushSnapshot(
|
33055
|
-
snapshot,
|
33056
|
-
schemaPath,
|
33057
|
-
casing2,
|
33058
|
-
schemaFilter
|
33059
|
-
);
|
33106
|
+
preparePgPush = async (cur, prev) => {
|
33060
33107
|
const validatedPrev = pgSchema.parse(prev);
|
33061
33108
|
const validatedCur = pgSchema.parse(cur);
|
33062
33109
|
const squashedPrev = squashPgScheme(validatedPrev, "push");
|
@@ -53660,7 +53707,7 @@ function determineRequestsReferrer(request, { referrerURLCallback, referrerOrigi
|
|
53660
53707
|
if (request.referrer === "no-referrer" || request.referrerPolicy === "") {
|
53661
53708
|
return null;
|
53662
53709
|
}
|
53663
|
-
const
|
53710
|
+
const policy3 = request.referrerPolicy;
|
53664
53711
|
if (request.referrer === "about:client") {
|
53665
53712
|
return "no-referrer";
|
53666
53713
|
}
|
@@ -53677,7 +53724,7 @@ function determineRequestsReferrer(request, { referrerURLCallback, referrerOrigi
|
|
53677
53724
|
referrerOrigin = referrerOriginCallback(referrerOrigin);
|
53678
53725
|
}
|
53679
53726
|
const currentURL = new URL(request.url);
|
53680
|
-
switch (
|
53727
|
+
switch (policy3) {
|
53681
53728
|
case "no-referrer":
|
53682
53729
|
return "no-referrer";
|
53683
53730
|
case "origin":
|
@@ -53713,18 +53760,18 @@ function determineRequestsReferrer(request, { referrerURLCallback, referrerOrigi
|
|
53713
53760
|
}
|
53714
53761
|
return referrerURL;
|
53715
53762
|
default:
|
53716
|
-
throw new TypeError(`Invalid referrerPolicy: ${
|
53763
|
+
throw new TypeError(`Invalid referrerPolicy: ${policy3}`);
|
53717
53764
|
}
|
53718
53765
|
}
|
53719
53766
|
function parseReferrerPolicyFromHeader(headers) {
|
53720
53767
|
const policyTokens = (headers.get("referrer-policy") || "").split(/[,\s]+/);
|
53721
|
-
let
|
53768
|
+
let policy3 = "";
|
53722
53769
|
for (const token of policyTokens) {
|
53723
53770
|
if (token && ReferrerPolicy.has(token)) {
|
53724
|
-
|
53771
|
+
policy3 = token;
|
53725
53772
|
}
|
53726
53773
|
}
|
53727
|
-
return
|
53774
|
+
return policy3;
|
53728
53775
|
}
|
53729
53776
|
var import_node_net, ReferrerPolicy, DEFAULT_REFERRER_POLICY;
|
53730
53777
|
var init_referrer = __esm({
|
@@ -69693,7 +69740,7 @@ var require_dist_cjs42 = __commonJS({
|
|
69693
69740
|
var import_util_buffer_from = require_dist_cjs23();
|
69694
69741
|
var import_util_utf8 = require_dist_cjs24();
|
69695
69742
|
var import_buffer2 = require("buffer");
|
69696
|
-
var
|
69743
|
+
var import_crypto10 = require("crypto");
|
69697
69744
|
var _Hash = class _Hash {
|
69698
69745
|
constructor(algorithmIdentifier, secret) {
|
69699
69746
|
this.algorithmIdentifier = algorithmIdentifier;
|
@@ -69707,7 +69754,7 @@ var require_dist_cjs42 = __commonJS({
|
|
69707
69754
|
return Promise.resolve(this.hash.digest());
|
69708
69755
|
}
|
69709
69756
|
reset() {
|
69710
|
-
this.hash = this.secret ? (0,
|
69757
|
+
this.hash = this.secret ? (0, import_crypto10.createHmac)(this.algorithmIdentifier, castSourceData(this.secret)) : (0, import_crypto10.createHash)(this.algorithmIdentifier);
|
69711
69758
|
}
|
69712
69759
|
};
|
69713
69760
|
__name(_Hash, "Hash");
|
@@ -74371,7 +74418,7 @@ var require_fromWebToken = __commonJS({
|
|
74371
74418
|
var fromWebToken2 = (init2) => async () => {
|
74372
74419
|
var _a;
|
74373
74420
|
(_a = init2.logger) == null ? void 0 : _a.debug("@aws-sdk/credential-provider-web-identity", "fromWebToken");
|
74374
|
-
const { roleArn, roleSessionName, webIdentityToken, providerId, policyArns, policy:
|
74421
|
+
const { roleArn, roleSessionName, webIdentityToken, providerId, policyArns, policy: policy3, durationSeconds } = init2;
|
74375
74422
|
let { roleAssumerWithWebIdentity } = init2;
|
74376
74423
|
if (!roleAssumerWithWebIdentity) {
|
74377
74424
|
const { getDefaultRoleAssumerWithWebIdentity } = await Promise.resolve().then(() => __importStar2(require_dist_cjs50()));
|
@@ -74387,7 +74434,7 @@ var require_fromWebToken = __commonJS({
|
|
74387
74434
|
WebIdentityToken: webIdentityToken,
|
74388
74435
|
ProviderId: providerId,
|
74389
74436
|
PolicyArns: policyArns,
|
74390
|
-
Policy:
|
74437
|
+
Policy: policy3,
|
74391
74438
|
DurationSeconds: durationSeconds
|
74392
74439
|
});
|
74393
74440
|
};
|
@@ -77515,7 +77562,7 @@ var init_pgPushUtils = __esm({
|
|
77515
77562
|
}
|
77516
77563
|
}
|
77517
77564
|
}
|
77518
|
-
const stmnt = fromJson([statement], "postgresql");
|
77565
|
+
const stmnt = fromJson([statement], "postgresql", "push");
|
77519
77566
|
if (typeof stmnt !== "undefined") {
|
77520
77567
|
statementsToExecute.push(...stmnt);
|
77521
77568
|
}
|
@@ -78669,7 +78716,7 @@ var init_pgIntrospect = __esm({
|
|
78669
78716
|
init_global();
|
78670
78717
|
init_pgSerializer();
|
78671
78718
|
init_views();
|
78672
|
-
pgPushIntrospect = async (db, filters, schemaFilters, entities) => {
|
78719
|
+
pgPushIntrospect = async (db, filters, schemaFilters, entities, tsSchema) => {
|
78673
78720
|
const matchers = filters.map((it) => {
|
78674
78721
|
return new Minimatch(it);
|
78675
78722
|
});
|
@@ -78698,7 +78745,7 @@ var init_pgIntrospect = __esm({
|
|
78698
78745
|
);
|
78699
78746
|
const res = await (0, import_hanji9.renderWithTask)(
|
78700
78747
|
progress,
|
78701
|
-
fromDatabase2(db, filter2, schemaFilters, entities)
|
78748
|
+
fromDatabase2(db, filter2, schemaFilters, entities, void 0, tsSchema)
|
78702
78749
|
);
|
78703
78750
|
const schema5 = { id: originUUID, prevId: "", ...res };
|
78704
78751
|
const { internal, ...schemaWithoutInternals } = schema5;
|
@@ -78915,8 +78962,8 @@ var init_introspect_sqlite = __esm({
|
|
78915
78962
|
if (defaultValue === "NULL") {
|
78916
78963
|
return `sql\`NULL\``;
|
78917
78964
|
}
|
78918
|
-
if (typeof defaultValue === "string"
|
78919
|
-
return defaultValue.substring(1, defaultValue.length - 1);
|
78965
|
+
if (typeof defaultValue === "string") {
|
78966
|
+
return defaultValue.substring(1, defaultValue.length - 1).replaceAll('"', '\\"').replaceAll("''", "'");
|
78920
78967
|
}
|
78921
78968
|
return defaultValue;
|
78922
78969
|
};
|
@@ -79174,12 +79221,14 @@ __export(push_exports, {
|
|
79174
79221
|
pgPush: () => pgPush,
|
79175
79222
|
sqlitePush: () => sqlitePush
|
79176
79223
|
});
|
79177
|
-
var import_hanji11, mysqlPush, pgPush, sqlitePush, libSQLPush;
|
79224
|
+
var import_crypto6, import_hanji11, mysqlPush, pgPush, sqlitePush, libSQLPush;
|
79178
79225
|
var init_push = __esm({
|
79179
79226
|
"src/cli/commands/push.ts"() {
|
79180
79227
|
"use strict";
|
79181
79228
|
init_source();
|
79229
|
+
import_crypto6 = require("crypto");
|
79182
79230
|
import_hanji11 = __toESM(require_hanji());
|
79231
|
+
init_serializer();
|
79183
79232
|
init_sqlgenerator();
|
79184
79233
|
init_selector_ui();
|
79185
79234
|
init_outputs();
|
@@ -79292,9 +79341,13 @@ var init_push = __esm({
|
|
79292
79341
|
const { preparePostgresDB: preparePostgresDB2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
|
79293
79342
|
const { pgPushIntrospect: pgPushIntrospect2 } = await Promise.resolve().then(() => (init_pgIntrospect(), pgIntrospect_exports));
|
79294
79343
|
const db = await preparePostgresDB2(credentials2);
|
79295
|
-
const
|
79344
|
+
const serialized = await serializePg(schemaPath, casing2, schemasFilter);
|
79345
|
+
const { schema: schema5 } = await pgPushIntrospect2(db, tablesFilter, schemasFilter, entities, serialized);
|
79296
79346
|
const { preparePgPush: preparePgPush2 } = await Promise.resolve().then(() => (init_migrate(), migrate_exports));
|
79297
|
-
const statements = await preparePgPush2(
|
79347
|
+
const statements = await preparePgPush2(
|
79348
|
+
{ id: (0, import_crypto6.randomUUID)(), prevId: schema5.id, ...serialized },
|
79349
|
+
schema5
|
79350
|
+
);
|
79298
79351
|
try {
|
79299
79352
|
if (statements.sqlStatements.length === 0) {
|
79300
79353
|
(0, import_hanji11.render)(`[${source_default.blue("i")}] No changes detected`);
|
@@ -79435,15 +79488,15 @@ var init_push = __esm({
|
|
79435
79488
|
[${source_default.blue("i")}] No changes detected`);
|
79436
79489
|
} else {
|
79437
79490
|
if (!("driver" in credentials2)) {
|
79438
|
-
await db.
|
79491
|
+
await db.run("begin");
|
79439
79492
|
try {
|
79440
79493
|
for (const dStmnt of statementsToExecute) {
|
79441
|
-
await db.
|
79494
|
+
await db.run(dStmnt);
|
79442
79495
|
}
|
79443
|
-
await db.
|
79496
|
+
await db.run("commit");
|
79444
79497
|
} catch (e2) {
|
79445
79498
|
console.error(e2);
|
79446
|
-
await db.
|
79499
|
+
await db.run("rollback");
|
79447
79500
|
process.exit(1);
|
79448
79501
|
}
|
79449
79502
|
}
|
@@ -79895,6 +79948,7 @@ var init_introspect_mysql = __esm({
|
|
79895
79948
|
init_utils3();
|
79896
79949
|
init_global();
|
79897
79950
|
init_mysqlSerializer();
|
79951
|
+
init_utils();
|
79898
79952
|
mysqlImportsList = /* @__PURE__ */ new Set([
|
79899
79953
|
"mysqlTable",
|
79900
79954
|
"mysqlEnum",
|
@@ -80022,6 +80076,12 @@ var init_introspect_mysql = __esm({
|
|
80022
80076
|
patched = patched.startsWith("varbinary(") ? "varbinary" : patched;
|
80023
80077
|
patched = patched.startsWith("int(") ? "int" : patched;
|
80024
80078
|
patched = patched.startsWith("double(") ? "double" : patched;
|
80079
|
+
patched = patched.startsWith("float(") ? "float" : patched;
|
80080
|
+
patched = patched.startsWith("int unsigned") ? "int" : patched;
|
80081
|
+
patched = patched.startsWith("tinyint unsigned") ? "tinyint" : patched;
|
80082
|
+
patched = patched.startsWith("smallint unsigned") ? "smallint" : patched;
|
80083
|
+
patched = patched.startsWith("mediumint unsigned") ? "mediumint" : patched;
|
80084
|
+
patched = patched.startsWith("bigint unsigned") ? "bigint" : patched;
|
80025
80085
|
return patched;
|
80026
80086
|
}).filter((type) => {
|
80027
80087
|
return mysqlImportsList.has(type);
|
@@ -80045,6 +80105,12 @@ var init_introspect_mysql = __esm({
|
|
80045
80105
|
patched = patched.startsWith("varbinary(") ? "varbinary" : patched;
|
80046
80106
|
patched = patched.startsWith("int(") ? "int" : patched;
|
80047
80107
|
patched = patched.startsWith("double(") ? "double" : patched;
|
80108
|
+
patched = patched.startsWith("float(") ? "float" : patched;
|
80109
|
+
patched = patched.startsWith("int unsigned") ? "int" : patched;
|
80110
|
+
patched = patched.startsWith("tinyint unsigned") ? "tinyint" : patched;
|
80111
|
+
patched = patched.startsWith("smallint unsigned") ? "smallint" : patched;
|
80112
|
+
patched = patched.startsWith("mediumint unsigned") ? "mediumint" : patched;
|
80113
|
+
patched = patched.startsWith("bigint unsigned") ? "bigint" : patched;
|
80048
80114
|
return patched;
|
80049
80115
|
}).filter((type) => {
|
80050
80116
|
return mysqlImportsList.has(type);
|
@@ -80191,28 +80257,32 @@ import { sql } from "drizzle-orm"
|
|
80191
80257
|
}
|
80192
80258
|
if (lowered.startsWith("int")) {
|
80193
80259
|
const isUnsigned = lowered.startsWith("int unsigned");
|
80194
|
-
|
80260
|
+
const columnName = dbColumnName2({ name, casing: rawCasing, withMode: isUnsigned });
|
80261
|
+
let out = `${casing2(name)}: int(${columnName}${isUnsigned ? `${columnName.length > 0 ? ", " : ""}{ unsigned: true }` : ""})`;
|
80195
80262
|
out += autoincrement ? `.autoincrement()` : "";
|
80196
80263
|
out += typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
|
80197
80264
|
return out;
|
80198
80265
|
}
|
80199
80266
|
if (lowered.startsWith("tinyint")) {
|
80200
80267
|
const isUnsigned = lowered.startsWith("tinyint unsigned");
|
80201
|
-
|
80268
|
+
const columnName = dbColumnName2({ name, casing: rawCasing, withMode: isUnsigned });
|
80269
|
+
let out = `${casing2(name)}: tinyint(${columnName}${isUnsigned ? `${columnName.length > 0 ? ", " : ""}{ unsigned: true }` : ""})`;
|
80202
80270
|
out += autoincrement ? `.autoincrement()` : "";
|
80203
80271
|
out += typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
|
80204
80272
|
return out;
|
80205
80273
|
}
|
80206
80274
|
if (lowered.startsWith("smallint")) {
|
80207
80275
|
const isUnsigned = lowered.startsWith("smallint unsigned");
|
80208
|
-
|
80276
|
+
const columnName = dbColumnName2({ name, casing: rawCasing, withMode: isUnsigned });
|
80277
|
+
let out = `${casing2(name)}: smallint(${columnName}${isUnsigned ? `${columnName.length > 0 ? ", " : ""}{ unsigned: true }` : ""})`;
|
80209
80278
|
out += autoincrement ? `.autoincrement()` : "";
|
80210
80279
|
out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
|
80211
80280
|
return out;
|
80212
80281
|
}
|
80213
80282
|
if (lowered.startsWith("mediumint")) {
|
80214
80283
|
const isUnsigned = lowered.startsWith("mediumint unsigned");
|
80215
|
-
|
80284
|
+
const columnName = dbColumnName2({ name, casing: rawCasing, withMode: isUnsigned });
|
80285
|
+
let out = `${casing2(name)}: mediumint(${columnName}${isUnsigned ? `${columnName.length > 0 ? ", " : ""}{ unsigned: true }` : ""})`;
|
80216
80286
|
out += autoincrement ? `.autoincrement()` : "";
|
80217
80287
|
out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
|
80218
80288
|
return out;
|
@@ -80231,17 +80301,28 @@ import { sql } from "drizzle-orm"
|
|
80231
80301
|
}
|
80232
80302
|
if (lowered.startsWith("double")) {
|
80233
80303
|
let params;
|
80234
|
-
if (lowered.length > 6) {
|
80235
|
-
const [precision, scale] = lowered.slice(7, lowered.length - 1).split(",");
|
80304
|
+
if (lowered.length > (lowered.includes("unsigned") ? 15 : 6)) {
|
80305
|
+
const [precision, scale] = lowered.slice(7, lowered.length - (1 + (lowered.includes("unsigned") ? 9 : 0))).split(",");
|
80236
80306
|
params = { precision, scale };
|
80237
80307
|
}
|
80308
|
+
if (lowered.includes("unsigned")) {
|
80309
|
+
params = { ...params ?? {}, unsigned: true };
|
80310
|
+
}
|
80238
80311
|
const timeConfigParams = params ? timeConfig(params) : void 0;
|
80239
80312
|
let out = params ? `${casing2(name)}: double(${dbColumnName2({ name, casing: rawCasing, withMode: timeConfigParams !== void 0 })}${timeConfig(params)})` : `${casing2(name)}: double(${dbColumnName2({ name, casing: rawCasing })})`;
|
80240
80313
|
out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
|
80241
80314
|
return out;
|
80242
80315
|
}
|
80243
|
-
if (lowered
|
80244
|
-
let
|
80316
|
+
if (lowered.startsWith("float")) {
|
80317
|
+
let params;
|
80318
|
+
if (lowered.length > (lowered.includes("unsigned") ? 14 : 5)) {
|
80319
|
+
const [precision, scale] = lowered.slice(6, lowered.length - (1 + (lowered.includes("unsigned") ? 9 : 0))).split(",");
|
80320
|
+
params = { precision, scale };
|
80321
|
+
}
|
80322
|
+
if (lowered.includes("unsigned")) {
|
80323
|
+
params = { ...params ?? {}, unsigned: true };
|
80324
|
+
}
|
80325
|
+
let out = `${casing2(name)}: float(${dbColumnName2({ name, casing: rawCasing })}${params ? timeConfig(params) : ""})`;
|
80245
80326
|
out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
|
80246
80327
|
return out;
|
80247
80328
|
}
|
@@ -80318,7 +80399,8 @@ import { sql } from "drizzle-orm"
|
|
80318
80399
|
"varchar".length + 1,
|
80319
80400
|
lowered.length - 1
|
80320
80401
|
)} })`;
|
80321
|
-
|
80402
|
+
const mappedDefaultValue = mapColumnDefault2(defaultValue, isExpression);
|
80403
|
+
out += defaultValue ? `.default(${isExpression ? mappedDefaultValue : unescapeSingleQuotes(mappedDefaultValue, true)})` : "";
|
80322
80404
|
return out;
|
80323
80405
|
}
|
80324
80406
|
if (lowered.startsWith("char")) {
|
@@ -80347,10 +80429,13 @@ import { sql } from "drizzle-orm"
|
|
80347
80429
|
}
|
80348
80430
|
if (lowered.startsWith("decimal")) {
|
80349
80431
|
let params;
|
80350
|
-
if (lowered.length > 7) {
|
80351
|
-
const [precision, scale] = lowered.slice(8, lowered.length - 1).split(",");
|
80432
|
+
if (lowered.length > (lowered.includes("unsigned") ? 16 : 7)) {
|
80433
|
+
const [precision, scale] = lowered.slice(8, lowered.length - (1 + (lowered.includes("unsigned") ? 9 : 0))).split(",");
|
80352
80434
|
params = { precision, scale };
|
80353
80435
|
}
|
80436
|
+
if (lowered.includes("unsigned")) {
|
80437
|
+
params = { ...params ?? {}, unsigned: true };
|
80438
|
+
}
|
80354
80439
|
const timeConfigParams = params ? timeConfig(params) : void 0;
|
80355
80440
|
let out = params ? `${casing2(name)}: decimal(${dbColumnName2({ name, casing: rawCasing, withMode: timeConfigParams !== void 0 })}${timeConfigParams})` : `${casing2(name)}: decimal(${dbColumnName2({ name, casing: rawCasing })})`;
|
80356
80441
|
defaultValue = typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
|
@@ -80368,9 +80453,10 @@ import { sql } from "drizzle-orm"
|
|
80368
80453
|
return out;
|
80369
80454
|
}
|
80370
80455
|
if (lowered.startsWith("enum")) {
|
80371
|
-
const values = lowered.substring("enum".length + 1, lowered.length - 1);
|
80456
|
+
const values = lowered.substring("enum".length + 1, lowered.length - 1).split(",").map((v) => unescapeSingleQuotes(v, true)).join(",");
|
80372
80457
|
let out = `${casing2(name)}: mysqlEnum(${dbColumnName2({ name, casing: rawCasing, withMode: true })}[${values}])`;
|
80373
|
-
|
80458
|
+
const mappedDefaultValue = mapColumnDefault2(defaultValue, isExpression);
|
80459
|
+
out += defaultValue ? `.default(${isExpression ? mappedDefaultValue : unescapeSingleQuotes(mappedDefaultValue, true)})` : "";
|
80374
80460
|
return out;
|
80375
80461
|
}
|
80376
80462
|
if (lowered.startsWith("varbinary")) {
|
@@ -80557,9 +80643,9 @@ var init_introspect_pg = __esm({
|
|
80557
80643
|
import_relations = require("drizzle-orm/relations");
|
80558
80644
|
init_utils3();
|
80559
80645
|
import_casing4 = require("drizzle-orm/casing");
|
80560
|
-
init_vector();
|
80561
80646
|
init_global();
|
80562
80647
|
init_pgSerializer();
|
80648
|
+
init_utils();
|
80563
80649
|
pgImportsList = /* @__PURE__ */ new Set([
|
80564
80650
|
"pgTable",
|
80565
80651
|
"pgEnum",
|
@@ -80799,7 +80885,7 @@ var init_introspect_pg = __esm({
|
|
80799
80885
|
const enumSchema3 = schemas[it.schema];
|
80800
80886
|
const paramName = paramNameFor(it.name, enumSchema3);
|
80801
80887
|
const func = enumSchema3 ? `${enumSchema3}.enum` : "pgEnum";
|
80802
|
-
const values = Object.values(it.values).map((it2) => `'${it2}'`).join(", ");
|
80888
|
+
const values = Object.values(it.values).map((it2) => `'${unescapeSingleQuotes(it2, false)}'`).join(", ");
|
80803
80889
|
return `export const ${withCasing2(paramName, casing2)} = ${func}("${it.name}", [${values}])
|
80804
80890
|
`;
|
80805
80891
|
}).join("").concat("\n");
|
@@ -80961,7 +81047,7 @@ import { sql } from "drizzle-orm"
|
|
80961
81047
|
return typeof defaultValue !== "undefined" ? `.default(${buildArrayDefault(defaultValue, lowered)})` : "";
|
80962
81048
|
}
|
80963
81049
|
if (enumTypes.has(`${typeSchema}.${type.replace("[]", "")}`)) {
|
80964
|
-
return typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault3(defaultValue, isExpression)})` : "";
|
81050
|
+
return typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault3(unescapeSingleQuotes(defaultValue, true), isExpression)})` : "";
|
80965
81051
|
}
|
80966
81052
|
if (lowered.startsWith("integer")) {
|
80967
81053
|
return typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault3(defaultValue, isExpression)})` : "";
|
@@ -80989,19 +81075,19 @@ import { sql } from "drizzle-orm"
|
|
80989
81075
|
return defaultValue ? `.default('${mapColumnDefault3(defaultValue, isExpression)}')` : "";
|
80990
81076
|
}
|
80991
81077
|
if (lowered.startsWith("timestamp")) {
|
80992
|
-
return defaultValue === "now()" ? ".defaultNow()" :
|
81078
|
+
return defaultValue === "now()" ? ".defaultNow()" : /^'\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}(\.\d+)?([+-]\d{2}(:\d{2})?)?'$/.test(defaultValue) ? `.default(${mapColumnDefault3(defaultValue, isExpression)})` : defaultValue ? `.default(sql\`${defaultValue}\`)` : "";
|
80993
81079
|
}
|
80994
81080
|
if (lowered.startsWith("time")) {
|
80995
|
-
return defaultValue === "now()" ? ".defaultNow()" : defaultValue ? `.default(${mapColumnDefault3(defaultValue, isExpression)})` : "";
|
81081
|
+
return defaultValue === "now()" ? ".defaultNow()" : /^'\d{2}:\d{2}(:\d{2})?(\.\d+)?'$/.test(defaultValue) ? `.default(${mapColumnDefault3(defaultValue, isExpression)})` : defaultValue ? `.default(sql\`${defaultValue}\`)` : "";
|
80996
81082
|
}
|
80997
81083
|
if (lowered.startsWith("interval")) {
|
80998
81084
|
return defaultValue ? `.default(${mapColumnDefault3(defaultValue, isExpression)})` : "";
|
80999
81085
|
}
|
81000
81086
|
if (lowered === "date") {
|
81001
|
-
return defaultValue === "now()" ? ".defaultNow()" : defaultValue
|
81087
|
+
return defaultValue === "now()" ? ".defaultNow()" : /^'\d{4}-\d{2}-\d{2}'$/.test(defaultValue) ? `.default(${defaultValue})` : defaultValue ? `.default(sql\`${defaultValue}\`)` : "";
|
81002
81088
|
}
|
81003
81089
|
if (lowered.startsWith("text")) {
|
81004
|
-
return typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault3(defaultValue, isExpression)})` : "";
|
81090
|
+
return typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault3(unescapeSingleQuotes(defaultValue, true), isExpression)})` : "";
|
81005
81091
|
}
|
81006
81092
|
if (lowered.startsWith("jsonb")) {
|
81007
81093
|
const def = typeof defaultValue !== "undefined" ? defaultValue.replace(/::(.*?)(?<![^\w"])(?=$)/, "").slice(1, -1) : null;
|
@@ -81024,7 +81110,7 @@ import { sql } from "drizzle-orm"
|
|
81024
81110
|
return typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault3(defaultValue, isExpression)})` : "";
|
81025
81111
|
}
|
81026
81112
|
if (lowered.startsWith("varchar")) {
|
81027
|
-
return typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault3(defaultValue, isExpression)})` : "";
|
81113
|
+
return typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault3(unescapeSingleQuotes(defaultValue, true), isExpression)})` : "";
|
81028
81114
|
}
|
81029
81115
|
if (lowered.startsWith("point")) {
|
81030
81116
|
return typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault3(defaultValue, isExpression)})` : "";
|
@@ -81039,7 +81125,7 @@ import { sql } from "drizzle-orm"
|
|
81039
81125
|
return typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault3(defaultValue, isExpression)})` : "";
|
81040
81126
|
}
|
81041
81127
|
if (lowered.startsWith("char")) {
|
81042
|
-
return typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault3(defaultValue, isExpression)})` : "";
|
81128
|
+
return typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault3(unescapeSingleQuotes(defaultValue, true), isExpression)})` : "";
|
81043
81129
|
}
|
81044
81130
|
return "";
|
81045
81131
|
};
|
@@ -81285,7 +81371,7 @@ import { sql } from "drizzle-orm"
|
|
81285
81371
|
if (it2.isExpression) {
|
81286
81372
|
return `sql\`${it2.expression}\``;
|
81287
81373
|
} else {
|
81288
|
-
return `table.${withCasing2(it2.expression, casing2)}${it2.asc ? ".asc()" : ".desc()"}${it2.nulls === "first" ? ".nullsFirst()" : ".nullsLast()"}${it2.opclass
|
81374
|
+
return `table.${withCasing2(it2.expression, casing2)}${it2.asc ? ".asc()" : ".desc()"}${it2.nulls === "first" ? ".nullsFirst()" : ".nullsLast()"}${it2.opclass ? `.op("${it2.opclass}")` : ""}`;
|
81289
81375
|
}
|
81290
81376
|
}).join(", ")})`;
|
81291
81377
|
statement += it.where ? `.where(sql\`${it.where}\`)` : "";
|
@@ -81921,13 +82007,13 @@ function getInternalBody(response) {
|
|
81921
82007
|
const state = response[stateKey];
|
81922
82008
|
return state && state.body || void 0;
|
81923
82009
|
}
|
81924
|
-
var import_http, import_http2, import_stream2,
|
82010
|
+
var import_http, import_http2, import_stream2, import_crypto7, RequestError, toRequestError, GlobalRequest, Request3, newRequestFromIncoming, getRequestCache, requestCache, incomingKey, urlKey, abortControllerKey, getAbortController, requestPrototype, newRequest, buildOutgoingHttpHeaders, responseCache, getResponseCache, cacheKey, GlobalResponse, Response22, stateKey, X_ALREADY_SENT, webFetch, regBuffer, regContentType, handleRequestError, handleFetchError, handleResponseError, responseViaCache, responseViaResponseObject, getRequestListener, createAdaptorServer, serve;
|
81925
82011
|
var init_dist2 = __esm({
|
81926
82012
|
"../node_modules/.pnpm/@hono+node-server@1.12.0/node_modules/@hono/node-server/dist/index.mjs"() {
|
81927
82013
|
import_http = require("http");
|
81928
82014
|
import_http2 = require("http2");
|
81929
82015
|
import_stream2 = require("stream");
|
81930
|
-
|
82016
|
+
import_crypto7 = __toESM(require("crypto"), 1);
|
81931
82017
|
RequestError = class extends Error {
|
81932
82018
|
static name = "RequestError";
|
81933
82019
|
constructor(message, options) {
|
@@ -82143,7 +82229,7 @@ var init_dist2 = __esm({
|
|
82143
82229
|
X_ALREADY_SENT = "x-hono-already-sent";
|
82144
82230
|
webFetch = global.fetch;
|
82145
82231
|
if (typeof global.crypto === "undefined") {
|
82146
|
-
global.crypto =
|
82232
|
+
global.crypto = import_crypto7.default;
|
82147
82233
|
}
|
82148
82234
|
global.fetch = (info2, init2) => {
|
82149
82235
|
init2 = {
|
@@ -85177,13 +85263,13 @@ __export(studio_exports, {
|
|
85177
85263
|
prepareSQLiteSchema: () => prepareSQLiteSchema,
|
85178
85264
|
prepareServer: () => prepareServer
|
85179
85265
|
});
|
85180
|
-
var
|
85266
|
+
var import_crypto9, import_drizzle_orm8, import_mysql_core3, import_pg_core3, import_sqlite_core3, import_fs12, import_node_https2, preparePgSchema, prepareMySqlSchema, prepareSQLiteSchema, getCustomDefaults, drizzleForPostgres, drizzleForMySQL, drizzleForSQLite, drizzleForLibSQL, extractRelations, init, proxySchema, defaultsSchema, schema4, jsonStringify, prepareServer;
|
85181
85267
|
var init_studio2 = __esm({
|
85182
85268
|
"src/serializer/studio.ts"() {
|
85183
85269
|
"use strict";
|
85184
85270
|
init_dist2();
|
85185
85271
|
init_esm();
|
85186
|
-
|
85272
|
+
import_crypto9 = require("crypto");
|
85187
85273
|
import_drizzle_orm8 = require("drizzle-orm");
|
85188
85274
|
import_mysql_core3 = require("drizzle-orm/mysql-core");
|
85189
85275
|
import_pg_core3 = require("drizzle-orm/pg-core");
|
@@ -85329,7 +85415,7 @@ var init_studio2 = __esm({
|
|
85329
85415
|
} else {
|
85330
85416
|
dbUrl = `postgresql://${credentials2.user}:${credentials2.password}@${credentials2.host}:${credentials2.port}/${credentials2.database}`;
|
85331
85417
|
}
|
85332
|
-
const dbHash = (0,
|
85418
|
+
const dbHash = (0, import_crypto9.createHash)("sha256").update(dbUrl).digest("hex");
|
85333
85419
|
return {
|
85334
85420
|
dbHash,
|
85335
85421
|
dialect: "postgresql",
|
@@ -85351,7 +85437,7 @@ var init_studio2 = __esm({
|
|
85351
85437
|
} else {
|
85352
85438
|
dbUrl = `mysql://${credentials2.user}:${credentials2.password}@${credentials2.host}:${credentials2.port}/${credentials2.database}`;
|
85353
85439
|
}
|
85354
|
-
const dbHash = (0,
|
85440
|
+
const dbHash = (0, import_crypto9.createHash)("sha256").update(dbUrl).digest("hex");
|
85355
85441
|
return {
|
85356
85442
|
dbHash,
|
85357
85443
|
dialect: "mysql",
|
@@ -85377,7 +85463,7 @@ var init_studio2 = __esm({
|
|
85377
85463
|
} else {
|
85378
85464
|
dbUrl = credentials2.url;
|
85379
85465
|
}
|
85380
|
-
const dbHash = (0,
|
85466
|
+
const dbHash = (0, import_crypto9.createHash)("sha256").update(dbUrl).digest("hex");
|
85381
85467
|
return {
|
85382
85468
|
dbHash,
|
85383
85469
|
dialect: "sqlite",
|
@@ -85394,7 +85480,7 @@ var init_studio2 = __esm({
|
|
85394
85480
|
const sqliteDB = await connectToLibSQL2(credentials2);
|
85395
85481
|
const customDefaults = getCustomDefaults(sqliteSchema2);
|
85396
85482
|
let dbUrl = `turso://${credentials2.url}/${credentials2.authToken}`;
|
85397
|
-
const dbHash = (0,
|
85483
|
+
const dbHash = (0, import_crypto9.createHash)("sha256").update(dbUrl).digest("hex");
|
85398
85484
|
return {
|
85399
85485
|
dbHash,
|
85400
85486
|
dialect: "sqlite",
|
@@ -88963,7 +89049,7 @@ init_utils2();
|
|
88963
89049
|
var version2 = async () => {
|
88964
89050
|
const { npmVersion } = await ormCoreVersions();
|
88965
89051
|
const ormVersion = npmVersion ? `drizzle-orm: v${npmVersion}` : "";
|
88966
|
-
const envVersion = "0.27.
|
89052
|
+
const envVersion = "0.27.2-96d338b";
|
88967
89053
|
const kitVersion = envVersion ? `v${envVersion}` : "--";
|
88968
89054
|
const versions = `drizzle-kit: ${kitVersion}
|
88969
89055
|
${ormVersion}`;
|