drizzle-kit 0.26.2-31c8041 → 0.26.2-4b200a2
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 +67 -7
- package/api.d.ts +67 -7
- package/api.js +998 -667
- package/api.mjs +998 -667
- package/bin.cjs +782 -332
- package/index.d.mts +2 -2
- package/index.d.ts +2 -2
- package/package.json +5 -5
- package/utils.js +11 -10
- package/utils.mjs +11 -9
package/bin.cjs
CHANGED
@@ -5832,7 +5832,7 @@ var init_vector = __esm({
|
|
5832
5832
|
});
|
5833
5833
|
|
5834
5834
|
// src/serializer/pgSchema.ts
|
5835
|
-
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, 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;
|
5835
|
+
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
5836
|
var init_pgSchema = __esm({
|
5837
5837
|
"src/serializer/pgSchema.ts"() {
|
5838
5838
|
"use strict";
|
@@ -6043,7 +6043,12 @@ var init_pgSchema = __esm({
|
|
6043
6043
|
for: enumType(["ALL", "SELECT", "INSERT", "UPDATE", "DELETE"]).optional(),
|
6044
6044
|
to: stringType().array().optional(),
|
6045
6045
|
using: stringType().optional(),
|
6046
|
-
withCheck: stringType().optional()
|
6046
|
+
withCheck: stringType().optional(),
|
6047
|
+
on: stringType().optional()
|
6048
|
+
}).strict();
|
6049
|
+
policySquashed = objectType({
|
6050
|
+
name: stringType(),
|
6051
|
+
values: stringType()
|
6047
6052
|
}).strict();
|
6048
6053
|
viewWithOption = objectType({
|
6049
6054
|
checkOption: enumType(["local", "cascaded"]).optional(),
|
@@ -6223,6 +6228,7 @@ var init_pgSchema = __esm({
|
|
6223
6228
|
views: recordType(stringType(), view2).default({}),
|
6224
6229
|
sequences: recordType(stringType(), sequenceSchema).default({}),
|
6225
6230
|
roles: recordType(stringType(), roleSchema).default({}),
|
6231
|
+
policies: recordType(stringType(), policy).default({}),
|
6226
6232
|
_meta: objectType({
|
6227
6233
|
schemas: recordType(stringType(), stringType()),
|
6228
6234
|
tables: recordType(stringType(), stringType()),
|
@@ -6271,7 +6277,8 @@ var init_pgSchema = __esm({
|
|
6271
6277
|
schemas: recordType(stringType(), stringType()),
|
6272
6278
|
views: recordType(stringType(), view2),
|
6273
6279
|
sequences: recordType(stringType(), sequenceSquashed),
|
6274
|
-
roles: recordType(stringType(), roleSchema).default({})
|
6280
|
+
roles: recordType(stringType(), roleSchema).default({}),
|
6281
|
+
policies: recordType(stringType(), policySquashed).default({})
|
6275
6282
|
}).strict();
|
6276
6283
|
pgSchemaV3 = pgSchemaInternalV3.merge(schemaHash2);
|
6277
6284
|
pgSchemaV4 = pgSchemaInternalV4.merge(schemaHash2);
|
@@ -6354,24 +6361,25 @@ var init_pgSchema = __esm({
|
|
6354
6361
|
squashFK: (fk4) => {
|
6355
6362
|
return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""};${fk4.schemaTo || "public"}`;
|
6356
6363
|
},
|
6357
|
-
squashPolicy: (
|
6364
|
+
squashPolicy: (policy4) => {
|
6358
6365
|
var _a;
|
6359
|
-
return `${
|
6366
|
+
return `${policy4.name}--${policy4.as}--${policy4.for}--${(_a = policy4.to) == null ? void 0 : _a.join(",")}--${policy4.using}--${policy4.withCheck}--${policy4.on}`;
|
6360
6367
|
},
|
6361
|
-
unsquashPolicy: (
|
6362
|
-
const splitted =
|
6368
|
+
unsquashPolicy: (policy4) => {
|
6369
|
+
const splitted = policy4.split("--");
|
6363
6370
|
return {
|
6364
6371
|
name: splitted[0],
|
6365
6372
|
as: splitted[1],
|
6366
6373
|
for: splitted[2],
|
6367
6374
|
to: splitted[3].split(","),
|
6368
6375
|
using: splitted[4] !== "undefined" ? splitted[4] : void 0,
|
6369
|
-
withCheck: splitted[5] !== "undefined" ? splitted[5] : void 0
|
6376
|
+
withCheck: splitted[5] !== "undefined" ? splitted[5] : void 0,
|
6377
|
+
on: splitted[6] !== "undefined" ? splitted[6] : void 0
|
6370
6378
|
};
|
6371
6379
|
},
|
6372
|
-
squashPolicyPush: (
|
6380
|
+
squashPolicyPush: (policy4) => {
|
6373
6381
|
var _a;
|
6374
|
-
return `${
|
6382
|
+
return `${policy4.name}--${policy4.as}--${policy4.for}--${(_a = policy4.to) == null ? void 0 : _a.join(",")}--${policy4.on}`;
|
6375
6383
|
},
|
6376
6384
|
squashPK: (pk) => {
|
6377
6385
|
return `${pk.columns.join(",")};${pk.name}`;
|
@@ -6485,8 +6493,8 @@ var init_pgSchema = __esm({
|
|
6485
6493
|
return PgSquasher.squashUnique(unq);
|
6486
6494
|
}
|
6487
6495
|
);
|
6488
|
-
const squashedPolicies = mapValues(it[1].policies, (
|
6489
|
-
return action === "push" ? PgSquasher.squashPolicyPush(
|
6496
|
+
const squashedPolicies = mapValues(it[1].policies, (policy4) => {
|
6497
|
+
return action === "push" ? PgSquasher.squashPolicyPush(policy4) : PgSquasher.squashPolicy(policy4);
|
6490
6498
|
});
|
6491
6499
|
const squashedChecksContraints = mapValues(
|
6492
6500
|
it[1].checkConstraints,
|
@@ -6523,6 +6531,17 @@ var init_pgSchema = __esm({
|
|
6523
6531
|
];
|
6524
6532
|
})
|
6525
6533
|
);
|
6534
|
+
const mappedPolicies = Object.fromEntries(
|
6535
|
+
Object.entries(json.policies).map((it) => {
|
6536
|
+
return [
|
6537
|
+
it[0],
|
6538
|
+
{
|
6539
|
+
name: it[1].name,
|
6540
|
+
values: action === "push" ? PgSquasher.squashPolicyPush(it[1]) : PgSquasher.squashPolicy(it[1])
|
6541
|
+
}
|
6542
|
+
];
|
6543
|
+
})
|
6544
|
+
);
|
6526
6545
|
return {
|
6527
6546
|
version: "7",
|
6528
6547
|
dialect: json.dialect,
|
@@ -6530,6 +6549,7 @@ var init_pgSchema = __esm({
|
|
6530
6549
|
enums: json.enums,
|
6531
6550
|
schemas: json.schemas,
|
6532
6551
|
views: json.views,
|
6552
|
+
policies: mappedPolicies,
|
6533
6553
|
sequences: mappedSequences,
|
6534
6554
|
roles: json.roles
|
6535
6555
|
};
|
@@ -6542,6 +6562,8 @@ var init_pgSchema = __esm({
|
|
6542
6562
|
tables: {},
|
6543
6563
|
enums: {},
|
6544
6564
|
schemas: {},
|
6565
|
+
policies: {},
|
6566
|
+
roles: {},
|
6545
6567
|
sequences: {},
|
6546
6568
|
_meta: {
|
6547
6569
|
schemas: {},
|
@@ -6860,17 +6882,11 @@ function findAddedAndRemoved(columnNames1, columnNames2) {
|
|
6860
6882
|
const removedColumns = columnNames1.filter((it) => !set2.has(it));
|
6861
6883
|
return { addedColumns, removedColumns };
|
6862
6884
|
}
|
6863
|
-
|
6864
|
-
if (!column7.name)
|
6865
|
-
return "";
|
6866
|
-
return !column7.keyAsName || casing2 === void 0 ? column7.name : casing2 === "camelCase" ? (0, import_casing.toCamelCase)(column7.name) : (0, import_casing.toSnakeCase)(column7.name);
|
6867
|
-
}
|
6868
|
-
var import_casing, import_fs, import_path, import_url, copy, objectValues, assertV1OutFolder, dryJournal, prepareOutFolder, validatorForDialect, validateWithReport, prepareMigrationFolder, prepareMigrationMeta, schemaRenameKey, tableRenameKey, columnRenameKey, normaliseSQLiteUrl, normalisePGliteUrl;
|
6885
|
+
var import_fs, import_path, import_url, copy, objectValues, assertV1OutFolder, dryJournal, prepareOutFolder, validatorForDialect, validateWithReport, prepareMigrationFolder, prepareMigrationMeta, schemaRenameKey, tableRenameKey, columnRenameKey, normaliseSQLiteUrl, normalisePGliteUrl;
|
6869
6886
|
var init_utils = __esm({
|
6870
6887
|
"src/utils.ts"() {
|
6871
6888
|
"use strict";
|
6872
6889
|
init_source();
|
6873
|
-
import_casing = require("drizzle-orm/casing");
|
6874
6890
|
import_fs = require("fs");
|
6875
6891
|
import_path = require("path");
|
6876
6892
|
import_url = require("url");
|
@@ -8940,7 +8956,7 @@ var init_utils2 = __esm({
|
|
8940
8956
|
process.exit(1);
|
8941
8957
|
}
|
8942
8958
|
};
|
8943
|
-
requiredApiVersion =
|
8959
|
+
requiredApiVersion = 10;
|
8944
8960
|
assertOrmCoreVersion = async () => {
|
8945
8961
|
try {
|
8946
8962
|
const { compatibilityVersion } = await import("drizzle-orm/version");
|
@@ -11482,10 +11498,10 @@ var init_outputs = __esm({
|
|
11482
11498
|
)
|
11483
11499
|
},
|
11484
11500
|
common: {
|
11485
|
-
ambiguousParams: (
|
11486
|
-
`You can't use both --config and other cli options for ${
|
11501
|
+
ambiguousParams: (command) => withStyle.error(
|
11502
|
+
`You can't use both --config and other cli options for ${command} command`
|
11487
11503
|
),
|
11488
|
-
schema: (
|
11504
|
+
schema: (command) => withStyle.error(`"--schema" is a required field for ${command} command`)
|
11489
11505
|
},
|
11490
11506
|
postgres: {
|
11491
11507
|
connection: {
|
@@ -11536,7 +11552,7 @@ var init_common = __esm({
|
|
11536
11552
|
init_lib();
|
11537
11553
|
init_schemaValidator();
|
11538
11554
|
init_outputs();
|
11539
|
-
assertCollisions = (
|
11555
|
+
assertCollisions = (command, options, whitelist, remainingKeys) => {
|
11540
11556
|
const { config, ...rest } = options;
|
11541
11557
|
let atLeastOneParam = false;
|
11542
11558
|
for (const key of Object.keys(rest)) {
|
@@ -11550,7 +11566,7 @@ var init_common = __esm({
|
|
11550
11566
|
if (!atLeastOneParam) {
|
11551
11567
|
return "config";
|
11552
11568
|
}
|
11553
|
-
console.log(outputs.common.ambiguousParams(
|
11569
|
+
console.log(outputs.common.ambiguousParams(command));
|
11554
11570
|
process.exit(1);
|
11555
11571
|
};
|
11556
11572
|
sqliteDriversLiterals = [
|
@@ -11681,7 +11697,14 @@ var init_cli = __esm({
|
|
11681
11697
|
schemaFilter: unionType([stringType(), stringType().array()]).optional().default(["public"]),
|
11682
11698
|
extensionsFilters: literalType("postgis").array().optional(),
|
11683
11699
|
verbose: booleanType().optional(),
|
11684
|
-
strict: booleanType().optional()
|
11700
|
+
strict: booleanType().optional(),
|
11701
|
+
entities: objectType({
|
11702
|
+
roles: booleanType().or(objectType({
|
11703
|
+
provider: stringType().optional(),
|
11704
|
+
include: stringType().array().optional(),
|
11705
|
+
exclude: stringType().array().optional()
|
11706
|
+
})).optional().default(false)
|
11707
|
+
}).optional()
|
11685
11708
|
}).passthrough();
|
11686
11709
|
pullParams = objectType({
|
11687
11710
|
config: stringType().optional(),
|
@@ -11728,7 +11751,7 @@ var init_libsql = __esm({
|
|
11728
11751
|
url: stringType().min(1),
|
11729
11752
|
authToken: stringType().min(1).optional()
|
11730
11753
|
});
|
11731
|
-
printConfigConnectionIssues = (options,
|
11754
|
+
printConfigConnectionIssues = (options, command) => {
|
11732
11755
|
let text = `Please provide required params for 'turso' dialect:
|
11733
11756
|
`;
|
11734
11757
|
console.log(error(text));
|
@@ -11909,25 +11932,25 @@ var init_sqlite = __esm({
|
|
11909
11932
|
return o;
|
11910
11933
|
})
|
11911
11934
|
]);
|
11912
|
-
printConfigConnectionIssues4 = (options,
|
11935
|
+
printConfigConnectionIssues4 = (options, command) => {
|
11913
11936
|
const parsedDriver = sqliteDriver.safeParse(options.driver);
|
11914
11937
|
const driver2 = parsedDriver.success ? parsedDriver.data : "";
|
11915
11938
|
if (driver2 === "expo") {
|
11916
|
-
if (
|
11939
|
+
if (command === "migrate") {
|
11917
11940
|
console.log(
|
11918
11941
|
error(
|
11919
11942
|
`You can't use 'migrate' command with Expo SQLite, please follow migration instructions in our docs - https://orm.drizzle.team/docs/get-started-sqlite#expo-sqlite`
|
11920
11943
|
)
|
11921
11944
|
);
|
11922
|
-
} else if (
|
11945
|
+
} else if (command === "studio") {
|
11923
11946
|
console.log(
|
11924
11947
|
error(
|
11925
11948
|
`You can't use 'studio' command with Expo SQLite, please use Expo Plugin https://www.npmjs.com/package/expo-drizzle-studio-plugin`
|
11926
11949
|
)
|
11927
11950
|
);
|
11928
|
-
} else if (
|
11951
|
+
} else if (command === "pull") {
|
11929
11952
|
console.log(error("You can't use 'pull' command with Expo SQLite"));
|
11930
|
-
} else if (
|
11953
|
+
} else if (command === "push") {
|
11931
11954
|
console.log(error("You can't use 'push' command with Expo SQLite"));
|
11932
11955
|
} else {
|
11933
11956
|
console.log(error("Unexpected error with expo driver \u{1F914}"));
|
@@ -17791,7 +17814,8 @@ var init_utils4 = __esm({
|
|
17791
17814
|
credentials: parsed2.data,
|
17792
17815
|
casing: config.casing,
|
17793
17816
|
tablesFilter,
|
17794
|
-
schemasFilter
|
17817
|
+
schemasFilter,
|
17818
|
+
entities: config.entities
|
17795
17819
|
};
|
17796
17820
|
}
|
17797
17821
|
if (config.dialect === "mysql") {
|
@@ -17942,7 +17966,8 @@ var init_utils4 = __esm({
|
|
17942
17966
|
credentials: parsed2.data,
|
17943
17967
|
tablesFilter,
|
17944
17968
|
schemasFilter,
|
17945
|
-
prefix: ((_d = config.migrations) == null ? void 0 : _d.prefix) || "index"
|
17969
|
+
prefix: ((_d = config.migrations) == null ? void 0 : _d.prefix) || "index",
|
17970
|
+
entities: config.entities
|
17946
17971
|
};
|
17947
17972
|
}
|
17948
17973
|
assertUnreachable(dialect4);
|
@@ -18186,6 +18211,34 @@ var init_mysqlImports = __esm({
|
|
18186
18211
|
}
|
18187
18212
|
});
|
18188
18213
|
|
18214
|
+
// src/serializer/utils.ts
|
18215
|
+
function getColumnCasing(column7, casing2) {
|
18216
|
+
if (!column7.name)
|
18217
|
+
return "";
|
18218
|
+
return !column7.keyAsName || casing2 === void 0 ? column7.name : casing2 === "camelCase" ? (0, import_casing.toCamelCase)(column7.name) : (0, import_casing.toSnakeCase)(column7.name);
|
18219
|
+
}
|
18220
|
+
var import_casing, sqlToStr;
|
18221
|
+
var init_utils5 = __esm({
|
18222
|
+
"src/serializer/utils.ts"() {
|
18223
|
+
"use strict";
|
18224
|
+
import_casing = require("drizzle-orm/casing");
|
18225
|
+
sqlToStr = (sql, casing2) => {
|
18226
|
+
return sql.toQuery({
|
18227
|
+
escapeName: () => {
|
18228
|
+
throw new Error("we don't support params for `sql` default values");
|
18229
|
+
},
|
18230
|
+
escapeParam: () => {
|
18231
|
+
throw new Error("we don't support params for `sql` default values");
|
18232
|
+
},
|
18233
|
+
escapeString: () => {
|
18234
|
+
throw new Error("we don't support params for `sql` default values");
|
18235
|
+
},
|
18236
|
+
casing: new import_casing.CasingCache(casing2)
|
18237
|
+
}).sql;
|
18238
|
+
};
|
18239
|
+
}
|
18240
|
+
});
|
18241
|
+
|
18189
18242
|
// src/serializer/mysqlSerializer.ts
|
18190
18243
|
var mysqlSerializer_exports = {};
|
18191
18244
|
__export(mysqlSerializer_exports, {
|
@@ -18210,24 +18263,20 @@ function clearDefaults(defaultValue, collate) {
|
|
18210
18263
|
return `(${resultDefault})`;
|
18211
18264
|
}
|
18212
18265
|
}
|
18213
|
-
var import_drizzle_orm2,
|
18266
|
+
var import_drizzle_orm2, import_mysql_core2, indexName, generateMySqlSnapshot, fromDatabase;
|
18214
18267
|
var init_mysqlSerializer = __esm({
|
18215
18268
|
"src/serializer/mysqlSerializer.ts"() {
|
18216
18269
|
"use strict";
|
18217
18270
|
init_source();
|
18218
18271
|
import_drizzle_orm2 = require("drizzle-orm");
|
18219
|
-
import_drizzle_orm3 = require("drizzle-orm");
|
18220
18272
|
import_mysql_core2 = require("drizzle-orm/mysql-core");
|
18221
|
-
import_mysql_core3 = require("drizzle-orm/mysql-core");
|
18222
|
-
import_mysql_core4 = require("drizzle-orm/mysql-core");
|
18223
18273
|
init_outputs();
|
18224
|
-
|
18225
|
-
init_serializer();
|
18274
|
+
init_utils5();
|
18226
18275
|
indexName = (tableName, columns) => {
|
18227
18276
|
return `${tableName}_${columns.join("_")}_index`;
|
18228
18277
|
};
|
18229
18278
|
generateMySqlSnapshot = (tables, views, casing2) => {
|
18230
|
-
const dialect4 = new
|
18279
|
+
const dialect4 = new import_mysql_core2.MySqlDialect({ casing: casing2 });
|
18231
18280
|
const result = {};
|
18232
18281
|
const resultViews = {};
|
18233
18282
|
const internal = { tables: {}, indexes: {} };
|
@@ -18241,7 +18290,7 @@ var init_mysqlSerializer = __esm({
|
|
18241
18290
|
checks,
|
18242
18291
|
primaryKeys,
|
18243
18292
|
uniqueConstraints
|
18244
|
-
} = (0,
|
18293
|
+
} = (0, import_mysql_core2.getTableConfig)(table4);
|
18245
18294
|
const columnsObject = {};
|
18246
18295
|
const indexesObject = {};
|
18247
18296
|
const foreignKeysObject = {};
|
@@ -18265,7 +18314,7 @@ var init_mysqlSerializer = __esm({
|
|
18265
18314
|
autoincrement: autoIncrement,
|
18266
18315
|
onUpdate: column7.hasOnUpdateNow,
|
18267
18316
|
generated: generated ? {
|
18268
|
-
as: (0, import_drizzle_orm2.is)(generated.as,
|
18317
|
+
as: (0, import_drizzle_orm2.is)(generated.as, import_drizzle_orm2.SQL) ? dialect4.sqlToQuery(generated.as).sql : typeof generated.as === "function" ? dialect4.sqlToQuery(generated.as()).sql : generated.as,
|
18269
18318
|
type: generated.mode ?? "stored"
|
18270
18319
|
} : void 0
|
18271
18320
|
};
|
@@ -18300,7 +18349,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
|
|
18300
18349
|
};
|
18301
18350
|
}
|
18302
18351
|
if (column7.default !== void 0) {
|
18303
|
-
if ((0, import_drizzle_orm2.is)(column7.default,
|
18352
|
+
if ((0, import_drizzle_orm2.is)(column7.default, import_drizzle_orm2.SQL)) {
|
18304
18353
|
columnToSet.default = sqlToStr(column7.default, casing2);
|
18305
18354
|
} else {
|
18306
18355
|
if (typeof column7.default === "string") {
|
@@ -18344,7 +18393,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
|
|
18344
18393
|
});
|
18345
18394
|
uniqueConstraints == null ? void 0 : uniqueConstraints.map((unq) => {
|
18346
18395
|
const columnNames = unq.columns.map((c) => getColumnCasing(c, casing2));
|
18347
|
-
const name = unq.name ?? (0,
|
18396
|
+
const name = unq.name ?? (0, import_mysql_core2.uniqueKeyName)(table4, columnNames);
|
18348
18397
|
const existingUnique = uniqueConstraintObject[name];
|
18349
18398
|
if (typeof existingUnique !== "undefined") {
|
18350
18399
|
console.log(
|
@@ -18408,7 +18457,7 @@ The unique constraint ${source_default.underline.blue(
|
|
18408
18457
|
const name = value.config.name;
|
18409
18458
|
let indexColumns = columns2.map((it) => {
|
18410
18459
|
var _a;
|
18411
|
-
if ((0, import_drizzle_orm2.is)(it,
|
18460
|
+
if ((0, import_drizzle_orm2.is)(it, import_drizzle_orm2.SQL)) {
|
18412
18461
|
const sql = dialect4.sqlToQuery(it, "indexes").sql;
|
18413
18462
|
if (typeof internal.indexes[name] === "undefined") {
|
18414
18463
|
internal.indexes[name] = {
|
@@ -18559,12 +18608,12 @@ ${withStyle.errorWarning(
|
|
18559
18608
|
autoincrement: autoIncrement,
|
18560
18609
|
onUpdate: column7.hasOnUpdateNow,
|
18561
18610
|
generated: generated ? {
|
18562
|
-
as: (0, import_drizzle_orm2.is)(generated.as,
|
18611
|
+
as: (0, import_drizzle_orm2.is)(generated.as, import_drizzle_orm2.SQL) ? dialect4.sqlToQuery(generated.as).sql : typeof generated.as === "function" ? dialect4.sqlToQuery(generated.as()).sql : generated.as,
|
18563
18612
|
type: generated.mode ?? "stored"
|
18564
18613
|
} : void 0
|
18565
18614
|
};
|
18566
18615
|
if (column7.default !== void 0) {
|
18567
|
-
if ((0, import_drizzle_orm2.is)(column7.default,
|
18616
|
+
if ((0, import_drizzle_orm2.is)(column7.default, import_drizzle_orm2.SQL)) {
|
18568
18617
|
columnToSet.default = sqlToStr(column7.default, casing2);
|
18569
18618
|
} else {
|
18570
18619
|
if (typeof column7.default === "string") {
|
@@ -18957,11 +19006,11 @@ __export(pgImports_exports, {
|
|
18957
19006
|
prepareFromExports: () => prepareFromExports2,
|
18958
19007
|
prepareFromPgImports: () => prepareFromPgImports
|
18959
19008
|
});
|
18960
|
-
var
|
19009
|
+
var import_drizzle_orm3, import_pg_core, prepareFromExports2, prepareFromPgImports;
|
18961
19010
|
var init_pgImports = __esm({
|
18962
19011
|
"src/serializer/pgImports.ts"() {
|
18963
19012
|
"use strict";
|
18964
|
-
|
19013
|
+
import_drizzle_orm3 = require("drizzle-orm");
|
18965
19014
|
import_pg_core = require("drizzle-orm/pg-core");
|
18966
19015
|
init_utils4();
|
18967
19016
|
prepareFromExports2 = (exports2) => {
|
@@ -18970,6 +19019,7 @@ var init_pgImports = __esm({
|
|
18970
19019
|
const schemas = [];
|
18971
19020
|
const sequences = [];
|
18972
19021
|
const roles = [];
|
19022
|
+
const policies = [];
|
18973
19023
|
const views = [];
|
18974
19024
|
const matViews = [];
|
18975
19025
|
const i0values = Object.values(exports2);
|
@@ -18978,10 +19028,10 @@ var init_pgImports = __esm({
|
|
18978
19028
|
enums.push(t2);
|
18979
19029
|
return;
|
18980
19030
|
}
|
18981
|
-
if ((0,
|
19031
|
+
if ((0, import_drizzle_orm3.is)(t2, import_pg_core.PgTable)) {
|
18982
19032
|
tables.push(t2);
|
18983
19033
|
}
|
18984
|
-
if ((0,
|
19034
|
+
if ((0, import_drizzle_orm3.is)(t2, import_pg_core.PgSchema)) {
|
18985
19035
|
schemas.push(t2);
|
18986
19036
|
}
|
18987
19037
|
if ((0, import_pg_core.isPgView)(t2)) {
|
@@ -18993,11 +19043,14 @@ var init_pgImports = __esm({
|
|
18993
19043
|
if ((0, import_pg_core.isPgSequence)(t2)) {
|
18994
19044
|
sequences.push(t2);
|
18995
19045
|
}
|
18996
|
-
if ((0,
|
19046
|
+
if ((0, import_drizzle_orm3.is)(t2, import_pg_core.PgRole)) {
|
18997
19047
|
roles.push(t2);
|
18998
19048
|
}
|
19049
|
+
if ((0, import_drizzle_orm3.is)(t2, import_pg_core.PgPolicy)) {
|
19050
|
+
policies.push(t2);
|
19051
|
+
}
|
18999
19052
|
});
|
19000
|
-
return { tables, enums, schemas, sequences, views, matViews, roles };
|
19053
|
+
return { tables, enums, schemas, sequences, views, matViews, roles, policies };
|
19001
19054
|
};
|
19002
19055
|
prepareFromPgImports = async (imports) => {
|
19003
19056
|
const tables = [];
|
@@ -19005,7 +19058,8 @@ var init_pgImports = __esm({
|
|
19005
19058
|
const schemas = [];
|
19006
19059
|
const sequences = [];
|
19007
19060
|
const views = [];
|
19008
|
-
|
19061
|
+
const roles = [];
|
19062
|
+
const policies = [];
|
19009
19063
|
const matViews = [];
|
19010
19064
|
const { unregister } = await safeRegister();
|
19011
19065
|
for (let i2 = 0; i2 < imports.length; i2++) {
|
@@ -19019,9 +19073,10 @@ var init_pgImports = __esm({
|
|
19019
19073
|
views.push(...prepared.views);
|
19020
19074
|
matViews.push(...prepared.matViews);
|
19021
19075
|
roles.push(...prepared.roles);
|
19076
|
+
policies.push(...prepared.policies);
|
19022
19077
|
}
|
19023
19078
|
unregister();
|
19024
|
-
return { tables: Array.from(new Set(tables)), enums, schemas, sequences, views, matViews, roles };
|
19079
|
+
return { tables: Array.from(new Set(tables)), enums, schemas, sequences, views, matViews, roles, policies };
|
19025
19080
|
};
|
19026
19081
|
}
|
19027
19082
|
});
|
@@ -19104,28 +19159,28 @@ function prepareRoles(entities) {
|
|
19104
19159
|
}
|
19105
19160
|
return { useRoles, includeRoles, excludeRoles };
|
19106
19161
|
}
|
19107
|
-
var
|
19162
|
+
var import_drizzle_orm4, import_pg_core2, indexName2, generatePgSnapshot, trimChar, fromDatabase2, defaultForColumn, getColumnsInfoQuery;
|
19108
19163
|
var init_pgSerializer = __esm({
|
19109
19164
|
"src/serializer/pgSerializer.ts"() {
|
19110
19165
|
"use strict";
|
19111
19166
|
init_source();
|
19112
|
-
|
19167
|
+
import_drizzle_orm4 = require("drizzle-orm");
|
19113
19168
|
import_pg_core2 = require("drizzle-orm/pg-core");
|
19114
|
-
import_pg_core3 = require("drizzle-orm/pg-core");
|
19115
19169
|
init_vector();
|
19116
19170
|
init_outputs();
|
19117
19171
|
init_utils();
|
19118
|
-
|
19172
|
+
init_utils5();
|
19119
19173
|
indexName2 = (tableName, columns) => {
|
19120
19174
|
return `${tableName}_${columns.join("_")}_index`;
|
19121
19175
|
};
|
19122
|
-
generatePgSnapshot = (tables, enums, schemas, sequences, roles, views, matViews, casing2, schemaFilter) => {
|
19123
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
19176
|
+
generatePgSnapshot = (tables, enums, schemas, sequences, roles, policies, views, matViews, casing2, schemaFilter) => {
|
19177
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
19124
19178
|
const dialect4 = new import_pg_core2.PgDialect({ casing: casing2 });
|
19125
19179
|
const result = {};
|
19126
19180
|
const resultViews = {};
|
19127
19181
|
const sequencesToReturn = {};
|
19128
19182
|
const rolesToReturn = {};
|
19183
|
+
const policiesToReturn = {};
|
19129
19184
|
const indexesInSchema = {};
|
19130
19185
|
for (const table4 of tables) {
|
19131
19186
|
const checksInTable = {};
|
@@ -19138,9 +19193,9 @@ var init_pgSerializer = __esm({
|
|
19138
19193
|
schema: schema5,
|
19139
19194
|
primaryKeys,
|
19140
19195
|
uniqueConstraints,
|
19141
|
-
policies,
|
19196
|
+
policies: policies2,
|
19142
19197
|
enableRLS
|
19143
|
-
} = (0,
|
19198
|
+
} = (0, import_pg_core2.getTableConfig)(table4);
|
19144
19199
|
if (schemaFilter && !schemaFilter.includes(schema5 ?? "public")) {
|
19145
19200
|
continue;
|
19146
19201
|
}
|
@@ -19157,7 +19212,7 @@ var init_pgSerializer = __esm({
|
|
19157
19212
|
const notNull = column7.notNull;
|
19158
19213
|
const primaryKey = column7.primary;
|
19159
19214
|
const sqlTypeLowered = column7.getSQLType().toLowerCase();
|
19160
|
-
const typeSchema = (0,
|
19215
|
+
const typeSchema = (0, import_drizzle_orm4.is)(column7, import_pg_core2.PgEnumColumn) ? column7.enum.schema || "public" : void 0;
|
19161
19216
|
const generated = column7.generated;
|
19162
19217
|
const identity = column7.generatedIdentity;
|
19163
19218
|
const increment = stringFromIdentityProperty((_a2 = identity == null ? void 0 : identity.sequenceOptions) == null ? void 0 : _a2.increment) ?? "1";
|
@@ -19172,7 +19227,7 @@ var init_pgSerializer = __esm({
|
|
19172
19227
|
primaryKey,
|
19173
19228
|
notNull,
|
19174
19229
|
generated: generated ? {
|
19175
|
-
as: (0,
|
19230
|
+
as: (0, import_drizzle_orm4.is)(generated.as, import_drizzle_orm4.SQL) ? dialect4.sqlToQuery(generated.as).sql : typeof generated.as === "function" ? dialect4.sqlToQuery(generated.as()).sql : generated.as,
|
19176
19231
|
type: "stored"
|
19177
19232
|
} : void 0,
|
19178
19233
|
identity: identity ? {
|
@@ -19213,7 +19268,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
|
|
19213
19268
|
};
|
19214
19269
|
}
|
19215
19270
|
if (column7.default !== void 0) {
|
19216
|
-
if ((0,
|
19271
|
+
if ((0, import_drizzle_orm4.is)(column7.default, import_drizzle_orm4.SQL)) {
|
19217
19272
|
columnToSet.default = sqlToStr(column7.default, casing2);
|
19218
19273
|
} else {
|
19219
19274
|
if (typeof column7.default === "string") {
|
@@ -19281,8 +19336,8 @@ ${withStyle.errorWarning(
|
|
19281
19336
|
const onDelete = fk4.onDelete;
|
19282
19337
|
const onUpdate = fk4.onUpdate;
|
19283
19338
|
const reference = fk4.reference();
|
19284
|
-
const tableTo = (0,
|
19285
|
-
const schemaTo = (0,
|
19339
|
+
const tableTo = (0, import_drizzle_orm4.getTableName)(reference.foreignTable);
|
19340
|
+
const schemaTo = (0, import_pg_core2.getTableConfig)(reference.foreignTable).schema;
|
19286
19341
|
const originalColumnsFrom = reference.columns.map((it) => it.name);
|
19287
19342
|
const columnsFrom = reference.columns.map((it) => getColumnCasing(it, casing2));
|
19288
19343
|
const originalColumnsTo = reference.foreignColumns.map((it) => it.name);
|
@@ -19314,12 +19369,12 @@ ${withStyle.errorWarning(
|
|
19314
19369
|
const columns2 = value.config.columns;
|
19315
19370
|
let indexColumnNames = [];
|
19316
19371
|
columns2.forEach((it) => {
|
19317
|
-
if ((0,
|
19372
|
+
if ((0, import_drizzle_orm4.is)(it, import_drizzle_orm4.SQL)) {
|
19318
19373
|
if (typeof value.config.name === "undefined") {
|
19319
19374
|
console.log(
|
19320
19375
|
`
|
19321
19376
|
${withStyle.errorWarning(
|
19322
|
-
`Please specify an index name in ${(0,
|
19377
|
+
`Please specify an index name in ${(0, import_drizzle_orm4.getTableName)(value.config.table)} table that has "${dialect4.sqlToQuery(it).sql}" expression. We can generate index names for indexes on columns only; for expressions in indexes, you need to specify the name yourself.`
|
19323
19378
|
)}`
|
19324
19379
|
);
|
19325
19380
|
process.exit(1);
|
@@ -19327,7 +19382,7 @@ ${withStyle.errorWarning(
|
|
19327
19382
|
}
|
19328
19383
|
it = it;
|
19329
19384
|
const name2 = getColumnCasing(it, casing2);
|
19330
|
-
if (!(0,
|
19385
|
+
if (!(0, import_drizzle_orm4.is)(it, import_drizzle_orm4.SQL) && it.type === "PgVector" && typeof it.indexConfig.opClass === "undefined") {
|
19331
19386
|
console.log(
|
19332
19387
|
`
|
19333
19388
|
${withStyle.errorWarning(
|
@@ -19355,7 +19410,7 @@ You can check the "pg_vector" docs for more info: https://github.com/pgvector/pg
|
|
19355
19410
|
let indexColumns = columns2.map(
|
19356
19411
|
(it) => {
|
19357
19412
|
var _a2, _b2, _c2, _d2, _e2;
|
19358
|
-
if ((0,
|
19413
|
+
if ((0, import_drizzle_orm4.is)(it, import_drizzle_orm4.SQL)) {
|
19359
19414
|
return {
|
19360
19415
|
expression: dialect4.sqlToQuery(it, "indexes").sql,
|
19361
19416
|
asc: true,
|
@@ -19400,33 +19455,44 @@ ${withStyle.errorWarning(
|
|
19400
19455
|
with: value.config.with ?? {}
|
19401
19456
|
};
|
19402
19457
|
});
|
19403
|
-
|
19458
|
+
policies2.forEach((policy4) => {
|
19404
19459
|
var _a2, _b2;
|
19405
19460
|
const mappedTo = [];
|
19406
|
-
if (!
|
19461
|
+
if (!policy4.to) {
|
19407
19462
|
mappedTo.push("public");
|
19408
19463
|
} else {
|
19409
|
-
if (
|
19410
|
-
mappedTo.push(
|
19411
|
-
} else if (
|
19412
|
-
mappedTo.push(
|
19413
|
-
} else if (
|
19414
|
-
|
19464
|
+
if (policy4.to && typeof policy4.to === "string") {
|
19465
|
+
mappedTo.push(policy4.to);
|
19466
|
+
} else if (policy4.to && (0, import_drizzle_orm4.is)(policy4.to, import_pg_core2.PgRole)) {
|
19467
|
+
mappedTo.push(policy4.to.name);
|
19468
|
+
} else if (policy4.to && Array.isArray(policy4.to)) {
|
19469
|
+
policy4.to.forEach((it) => {
|
19415
19470
|
if (typeof it === "string") {
|
19416
19471
|
mappedTo.push(it);
|
19417
|
-
} else if ((0,
|
19472
|
+
} else if ((0, import_drizzle_orm4.is)(it, import_pg_core2.PgRole)) {
|
19418
19473
|
mappedTo.push(it.name);
|
19419
19474
|
}
|
19420
19475
|
});
|
19421
19476
|
}
|
19422
19477
|
}
|
19423
|
-
policiesObject[
|
19424
|
-
|
19425
|
-
|
19426
|
-
|
19478
|
+
if (policiesObject[policy4.name] !== void 0) {
|
19479
|
+
console.log(
|
19480
|
+
`
|
19481
|
+
${withStyle.errorWarning(
|
19482
|
+
`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
|
+
policy4.name
|
19484
|
+
)} name`
|
19485
|
+
)}`
|
19486
|
+
);
|
19487
|
+
process.exit(1);
|
19488
|
+
}
|
19489
|
+
policiesObject[policy4.name] = {
|
19490
|
+
name: policy4.name,
|
19491
|
+
as: ((_a2 = policy4.as) == null ? void 0 : _a2.toUpperCase()) ?? "PERMISSIVE",
|
19492
|
+
for: ((_b2 = policy4.for) == null ? void 0 : _b2.toUpperCase()) ?? "ALL",
|
19427
19493
|
to: mappedTo.sort(),
|
19428
|
-
using: (0,
|
19429
|
-
withCheck: (0,
|
19494
|
+
using: (0, import_drizzle_orm4.is)(policy4.using, import_drizzle_orm4.SQL) ? dialect4.sqlToQuery(policy4.using).sql : void 0,
|
19495
|
+
withCheck: (0, import_drizzle_orm4.is)(policy4.withCheck, import_drizzle_orm4.SQL) ? dialect4.sqlToQuery(policy4.withCheck).sql : void 0
|
19430
19496
|
};
|
19431
19497
|
});
|
19432
19498
|
checks.forEach((check2) => {
|
@@ -19470,14 +19536,72 @@ ${withStyle.errorWarning(
|
|
19470
19536
|
isRLSEnabled: enableRLS
|
19471
19537
|
};
|
19472
19538
|
}
|
19539
|
+
for (const policy4 of policies) {
|
19540
|
+
if (!policy4._linkedTable) {
|
19541
|
+
console.log(
|
19542
|
+
`
|
19543
|
+
${withStyle.errorWarning(
|
19544
|
+
`"Policy ${policy4.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
|
+
)}`
|
19546
|
+
);
|
19547
|
+
continue;
|
19548
|
+
}
|
19549
|
+
const tableConfig = (0, import_pg_core2.getTableConfig)(policy4._linkedTable);
|
19550
|
+
const tableKey2 = `${tableConfig.schema ?? "public"}.${tableConfig.name}`;
|
19551
|
+
const mappedTo = [];
|
19552
|
+
if (!policy4.to) {
|
19553
|
+
mappedTo.push("public");
|
19554
|
+
} else {
|
19555
|
+
if (policy4.to && typeof policy4.to === "string") {
|
19556
|
+
mappedTo.push(policy4.to);
|
19557
|
+
} else if (policy4.to && (0, import_drizzle_orm4.is)(policy4.to, import_pg_core2.PgRole)) {
|
19558
|
+
mappedTo.push(policy4.to.name);
|
19559
|
+
} else if (policy4.to && Array.isArray(policy4.to)) {
|
19560
|
+
policy4.to.forEach((it) => {
|
19561
|
+
if (typeof it === "string") {
|
19562
|
+
mappedTo.push(it);
|
19563
|
+
} else if ((0, import_drizzle_orm4.is)(it, import_pg_core2.PgRole)) {
|
19564
|
+
mappedTo.push(it.name);
|
19565
|
+
}
|
19566
|
+
});
|
19567
|
+
}
|
19568
|
+
}
|
19569
|
+
if (((_a = result[tableKey2]) == null ? void 0 : _a.policies[policy4.name]) !== void 0 || policiesToReturn[policy4.name] !== void 0) {
|
19570
|
+
console.log(
|
19571
|
+
`
|
19572
|
+
${withStyle.errorWarning(
|
19573
|
+
`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
|
+
policy4.name
|
19575
|
+
)} name`
|
19576
|
+
)}`
|
19577
|
+
);
|
19578
|
+
process.exit(1);
|
19579
|
+
}
|
19580
|
+
const mappedPolicy = {
|
19581
|
+
name: policy4.name,
|
19582
|
+
as: ((_b = policy4.as) == null ? void 0 : _b.toUpperCase()) ?? "PERMISSIVE",
|
19583
|
+
for: ((_c = policy4.for) == null ? void 0 : _c.toUpperCase()) ?? "ALL",
|
19584
|
+
to: mappedTo.sort(),
|
19585
|
+
using: (0, import_drizzle_orm4.is)(policy4.using, import_drizzle_orm4.SQL) ? dialect4.sqlToQuery(policy4.using).sql : void 0,
|
19586
|
+
withCheck: (0, import_drizzle_orm4.is)(policy4.withCheck, import_drizzle_orm4.SQL) ? dialect4.sqlToQuery(policy4.withCheck).sql : void 0
|
19587
|
+
};
|
19588
|
+
if (result[tableKey2]) {
|
19589
|
+
result[tableKey2].policies[policy4.name] = mappedPolicy;
|
19590
|
+
} else {
|
19591
|
+
policiesToReturn[policy4.name] = {
|
19592
|
+
...mappedPolicy,
|
19593
|
+
on: `"${tableConfig.schema ?? "public"}"."${tableConfig.name}"`
|
19594
|
+
};
|
19595
|
+
}
|
19596
|
+
}
|
19473
19597
|
for (const sequence of sequences) {
|
19474
19598
|
const name = sequence.seqName;
|
19475
19599
|
if (typeof sequencesToReturn[`${sequence.schema ?? "public"}.${name}`] === "undefined") {
|
19476
|
-
const increment = stringFromIdentityProperty((
|
19477
|
-
const minValue = stringFromIdentityProperty((
|
19478
|
-
const maxValue = stringFromIdentityProperty((
|
19479
|
-
const startWith = stringFromIdentityProperty((
|
19480
|
-
const cache = stringFromIdentityProperty((
|
19600
|
+
const increment = stringFromIdentityProperty((_d = sequence == null ? void 0 : sequence.seqOptions) == null ? void 0 : _d.increment) ?? "1";
|
19601
|
+
const minValue = stringFromIdentityProperty((_e = sequence == null ? void 0 : sequence.seqOptions) == null ? void 0 : _e.minValue) ?? (parseFloat(increment) < 0 ? "-9223372036854775808" : "1");
|
19602
|
+
const maxValue = stringFromIdentityProperty((_f = sequence == null ? void 0 : sequence.seqOptions) == null ? void 0 : _f.maxValue) ?? (parseFloat(increment) < 0 ? "-1" : "9223372036854775807");
|
19603
|
+
const startWith = stringFromIdentityProperty((_g = sequence == null ? void 0 : sequence.seqOptions) == null ? void 0 : _g.startWith) ?? (parseFloat(increment) < 0 ? maxValue : minValue);
|
19604
|
+
const cache = stringFromIdentityProperty((_h = sequence == null ? void 0 : sequence.seqOptions) == null ? void 0 : _h.cache) ?? "1";
|
19481
19605
|
sequencesToReturn[`${sequence.schema ?? "public"}.${name}`] = {
|
19482
19606
|
name,
|
19483
19607
|
schema: sequence.schema ?? "public",
|
@@ -19486,7 +19610,7 @@ ${withStyle.errorWarning(
|
|
19486
19610
|
minValue,
|
19487
19611
|
maxValue,
|
19488
19612
|
cache,
|
19489
|
-
cycle: ((
|
19613
|
+
cycle: ((_i = sequence.seqOptions) == null ? void 0 : _i.cycle) ?? false
|
19490
19614
|
};
|
19491
19615
|
} else {
|
19492
19616
|
}
|
@@ -19513,7 +19637,7 @@ ${withStyle.errorWarning(
|
|
19513
19637
|
let using;
|
19514
19638
|
let withNoData;
|
19515
19639
|
let materialized = false;
|
19516
|
-
if ((0,
|
19640
|
+
if ((0, import_drizzle_orm4.is)(view4, import_pg_core2.PgView)) {
|
19517
19641
|
({ name: viewName, schema: schema5, query, selectedFields, isExisting, with: withOption } = (0, import_pg_core2.getViewConfig)(view4));
|
19518
19642
|
} else {
|
19519
19643
|
({ name: viewName, schema: schema5, query, selectedFields, isExisting, with: withOption, tablespace, using, withNoData } = (0, import_pg_core2.getMaterializedViewConfig)(view4));
|
@@ -19534,19 +19658,19 @@ ${withStyle.errorWarning(
|
|
19534
19658
|
process.exit(1);
|
19535
19659
|
}
|
19536
19660
|
for (const key in selectedFields) {
|
19537
|
-
if ((0,
|
19661
|
+
if ((0, import_drizzle_orm4.is)(selectedFields[key], import_pg_core2.PgColumn)) {
|
19538
19662
|
const column7 = selectedFields[key];
|
19539
19663
|
const notNull = column7.notNull;
|
19540
19664
|
const primaryKey = column7.primary;
|
19541
19665
|
const sqlTypeLowered = column7.getSQLType().toLowerCase();
|
19542
|
-
const typeSchema = (0,
|
19666
|
+
const typeSchema = (0, import_drizzle_orm4.is)(column7, import_pg_core2.PgEnumColumn) ? column7.enum.schema || "public" : void 0;
|
19543
19667
|
const generated = column7.generated;
|
19544
19668
|
const identity = column7.generatedIdentity;
|
19545
|
-
const increment = stringFromIdentityProperty((
|
19546
|
-
const minValue = stringFromIdentityProperty((
|
19547
|
-
const maxValue = stringFromIdentityProperty((
|
19548
|
-
const startWith = stringFromIdentityProperty((
|
19549
|
-
const cache = stringFromIdentityProperty((
|
19669
|
+
const increment = stringFromIdentityProperty((_j = identity == null ? void 0 : identity.sequenceOptions) == null ? void 0 : _j.increment) ?? "1";
|
19670
|
+
const minValue = stringFromIdentityProperty((_k = identity == null ? void 0 : identity.sequenceOptions) == null ? void 0 : _k.minValue) ?? (parseFloat(increment) < 0 ? minRangeForIdentityBasedOn(column7.columnType) : "1");
|
19671
|
+
const maxValue = stringFromIdentityProperty((_l = identity == null ? void 0 : identity.sequenceOptions) == null ? void 0 : _l.maxValue) ?? (parseFloat(increment) < 0 ? "-1" : maxRangeForIdentityBasedOn(column7.getSQLType()));
|
19672
|
+
const startWith = stringFromIdentityProperty((_m = identity == null ? void 0 : identity.sequenceOptions) == null ? void 0 : _m.startWith) ?? (parseFloat(increment) < 0 ? maxValue : minValue);
|
19673
|
+
const cache = stringFromIdentityProperty((_n = identity == null ? void 0 : identity.sequenceOptions) == null ? void 0 : _n.cache) ?? "1";
|
19550
19674
|
const columnToSet = {
|
19551
19675
|
name: column7.name,
|
19552
19676
|
type: column7.getSQLType(),
|
@@ -19554,7 +19678,7 @@ ${withStyle.errorWarning(
|
|
19554
19678
|
primaryKey,
|
19555
19679
|
notNull,
|
19556
19680
|
generated: generated ? {
|
19557
|
-
as: (0,
|
19681
|
+
as: (0, import_drizzle_orm4.is)(generated.as, import_drizzle_orm4.SQL) ? dialect4.sqlToQuery(generated.as).sql : typeof generated.as === "function" ? dialect4.sqlToQuery(generated.as()).sql : generated.as,
|
19558
19682
|
type: "stored"
|
19559
19683
|
} : void 0,
|
19560
19684
|
identity: identity ? {
|
@@ -19566,7 +19690,7 @@ ${withStyle.errorWarning(
|
|
19566
19690
|
minValue,
|
19567
19691
|
maxValue,
|
19568
19692
|
cache,
|
19569
|
-
cycle: ((
|
19693
|
+
cycle: ((_o = identity == null ? void 0 : identity.sequenceOptions) == null ? void 0 : _o.cycle) ?? false
|
19570
19694
|
} : void 0
|
19571
19695
|
};
|
19572
19696
|
if (column7.isUnique) {
|
@@ -19591,7 +19715,7 @@ ${withStyle.errorWarning(
|
|
19591
19715
|
};
|
19592
19716
|
}
|
19593
19717
|
if (column7.default !== void 0) {
|
19594
|
-
if ((0,
|
19718
|
+
if ((0, import_drizzle_orm4.is)(column7.default, import_drizzle_orm4.SQL)) {
|
19595
19719
|
columnToSet.default = sqlToStr(column7.default, casing2);
|
19596
19720
|
} else {
|
19597
19721
|
if (typeof column7.default === "string") {
|
@@ -19658,6 +19782,7 @@ ${withStyle.errorWarning(
|
|
19658
19782
|
schemas: schemasObject,
|
19659
19783
|
sequences: sequencesToReturn,
|
19660
19784
|
roles: rolesToReturn,
|
19785
|
+
policies: policiesToReturn,
|
19661
19786
|
views: resultViews,
|
19662
19787
|
_meta: {
|
19663
19788
|
schemas: {},
|
@@ -19813,7 +19938,7 @@ WHERE
|
|
19813
19938
|
for (const dbPolicy of allPolicies) {
|
19814
19939
|
const { tablename, schemaname, to, withCheck, using, ...rest } = dbPolicy;
|
19815
19940
|
const tableForPolicy = policiesByTable[`${schemaname}.${tablename}`];
|
19816
|
-
const parsedTo = to;
|
19941
|
+
const parsedTo = typeof to === "string" ? to.slice(1, -1).split(",") : to;
|
19817
19942
|
const parsedWithCheck = withCheck === null ? void 0 : withCheck;
|
19818
19943
|
const parsedUsing = using === null ? void 0 : using;
|
19819
19944
|
if (tableForPolicy) {
|
@@ -20420,6 +20545,7 @@ WHERE
|
|
20420
20545
|
schemas: schemasObject,
|
20421
20546
|
sequences: sequencesToReturn,
|
20422
20547
|
roles: rolesToReturn,
|
20548
|
+
policies: {},
|
20423
20549
|
views,
|
20424
20550
|
_meta: {
|
20425
20551
|
schemas: {},
|
@@ -20577,11 +20703,11 @@ __export(sqliteImports_exports, {
|
|
20577
20703
|
prepareFromExports: () => prepareFromExports3,
|
20578
20704
|
prepareFromSqliteImports: () => prepareFromSqliteImports
|
20579
20705
|
});
|
20580
|
-
var
|
20706
|
+
var import_drizzle_orm5, import_sqlite_core, prepareFromExports3, prepareFromSqliteImports;
|
20581
20707
|
var init_sqliteImports = __esm({
|
20582
20708
|
"src/serializer/sqliteImports.ts"() {
|
20583
20709
|
"use strict";
|
20584
|
-
|
20710
|
+
import_drizzle_orm5 = require("drizzle-orm");
|
20585
20711
|
import_sqlite_core = require("drizzle-orm/sqlite-core");
|
20586
20712
|
init_utils4();
|
20587
20713
|
prepareFromExports3 = (exports2) => {
|
@@ -20589,10 +20715,10 @@ var init_sqliteImports = __esm({
|
|
20589
20715
|
const views = [];
|
20590
20716
|
const i0values = Object.values(exports2);
|
20591
20717
|
i0values.forEach((t2) => {
|
20592
|
-
if ((0,
|
20718
|
+
if ((0, import_drizzle_orm5.is)(t2, import_sqlite_core.SQLiteTable)) {
|
20593
20719
|
tables.push(t2);
|
20594
20720
|
}
|
20595
|
-
if ((0,
|
20721
|
+
if ((0, import_drizzle_orm5.is)(t2, import_sqlite_core.SQLiteView)) {
|
20596
20722
|
views.push(t2);
|
20597
20723
|
}
|
20598
20724
|
});
|
@@ -20682,16 +20808,15 @@ function extractGeneratedColumns(input) {
|
|
20682
20808
|
}
|
20683
20809
|
return columns;
|
20684
20810
|
}
|
20685
|
-
var
|
20811
|
+
var import_drizzle_orm6, import_sqlite_core2, generateSqliteSnapshot, fromDatabase3;
|
20686
20812
|
var init_sqliteSerializer = __esm({
|
20687
20813
|
"src/serializer/sqliteSerializer.ts"() {
|
20688
20814
|
"use strict";
|
20689
20815
|
init_source();
|
20690
|
-
|
20816
|
+
import_drizzle_orm6 = require("drizzle-orm");
|
20691
20817
|
import_sqlite_core2 = require("drizzle-orm/sqlite-core");
|
20692
20818
|
init_outputs();
|
20693
|
-
|
20694
|
-
init_serializer();
|
20819
|
+
init_utils5();
|
20695
20820
|
generateSqliteSnapshot = (tables, views, casing2) => {
|
20696
20821
|
const dialect4 = new import_sqlite_core2.SQLiteSyncDialect({ casing: casing2 });
|
20697
20822
|
const result = {};
|
@@ -20724,14 +20849,14 @@ var init_sqliteSerializer = __esm({
|
|
20724
20849
|
type: column7.getSQLType(),
|
20725
20850
|
primaryKey,
|
20726
20851
|
notNull,
|
20727
|
-
autoincrement: (0,
|
20852
|
+
autoincrement: (0, import_drizzle_orm6.is)(column7, import_sqlite_core2.SQLiteBaseInteger) ? column7.autoIncrement : false,
|
20728
20853
|
generated: generated ? {
|
20729
|
-
as: (0,
|
20854
|
+
as: (0, import_drizzle_orm6.is)(generated.as, import_drizzle_orm6.SQL) ? `(${dialect4.sqlToQuery(generated.as, "indexes").sql})` : typeof generated.as === "function" ? `(${dialect4.sqlToQuery(generated.as(), "indexes").sql})` : `(${generated.as})`,
|
20730
20855
|
type: generated.mode ?? "virtual"
|
20731
20856
|
} : void 0
|
20732
20857
|
};
|
20733
20858
|
if (column7.default !== void 0) {
|
20734
|
-
if ((0,
|
20859
|
+
if ((0, import_drizzle_orm6.is)(column7.default, import_drizzle_orm6.SQL)) {
|
20735
20860
|
columnToSet.default = sqlToStr(column7.default, casing2);
|
20736
20861
|
} else {
|
20737
20862
|
columnToSet.default = typeof column7.default === "string" ? `'${column7.default}'` : typeof column7.default === "object" || Array.isArray(column7.default) ? `'${JSON.stringify(column7.default)}'` : column7.default;
|
@@ -20770,7 +20895,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
|
|
20770
20895
|
const onUpdate = fk4.onUpdate ?? "no action";
|
20771
20896
|
const reference = fk4.reference();
|
20772
20897
|
const referenceFT = reference.foreignTable;
|
20773
|
-
const tableTo = (0,
|
20898
|
+
const tableTo = (0, import_drizzle_orm6.getTableName)(referenceFT);
|
20774
20899
|
const originalColumnsFrom = reference.columns.map((it) => it.name);
|
20775
20900
|
const columnsFrom = reference.columns.map((it) => getColumnCasing(it, casing2));
|
20776
20901
|
const originalColumnsTo = reference.foreignColumns.map((it) => it.name);
|
@@ -20802,7 +20927,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
|
|
20802
20927
|
const name = value.config.name;
|
20803
20928
|
let indexColumns = columns2.map((it) => {
|
20804
20929
|
var _a;
|
20805
|
-
if ((0,
|
20930
|
+
if ((0, import_drizzle_orm6.is)(it, import_drizzle_orm6.SQL)) {
|
20806
20931
|
const sql = dialect4.sqlToQuery(it, "indexes").sql;
|
20807
20932
|
if (typeof internal.indexes[name] === "undefined") {
|
20808
20933
|
internal.indexes[name] = {
|
@@ -20828,7 +20953,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
|
|
20828
20953
|
});
|
20829
20954
|
let where = void 0;
|
20830
20955
|
if (value.config.where !== void 0) {
|
20831
|
-
if ((0,
|
20956
|
+
if ((0, import_drizzle_orm6.is)(value.config.where, import_drizzle_orm6.SQL)) {
|
20832
20957
|
where = dialect4.sqlToQuery(value.config.where).sql;
|
20833
20958
|
}
|
20834
20959
|
}
|
@@ -20937,7 +21062,7 @@ ${withStyle.errorWarning(
|
|
20937
21062
|
process.exit(1);
|
20938
21063
|
}
|
20939
21064
|
for (const key in selectedFields) {
|
20940
|
-
if ((0,
|
21065
|
+
if ((0, import_drizzle_orm6.is)(selectedFields[key], import_sqlite_core2.SQLiteColumn)) {
|
20941
21066
|
const column7 = selectedFields[key];
|
20942
21067
|
const notNull = column7.notNull;
|
20943
21068
|
const primaryKey = column7.primary;
|
@@ -20947,14 +21072,14 @@ ${withStyle.errorWarning(
|
|
20947
21072
|
type: column7.getSQLType(),
|
20948
21073
|
primaryKey,
|
20949
21074
|
notNull,
|
20950
|
-
autoincrement: (0,
|
21075
|
+
autoincrement: (0, import_drizzle_orm6.is)(column7, import_sqlite_core2.SQLiteBaseInteger) ? column7.autoIncrement : false,
|
20951
21076
|
generated: generated ? {
|
20952
|
-
as: (0,
|
21077
|
+
as: (0, import_drizzle_orm6.is)(generated.as, import_drizzle_orm6.SQL) ? `(${dialect4.sqlToQuery(generated.as, "indexes").sql})` : typeof generated.as === "function" ? `(${dialect4.sqlToQuery(generated.as(), "indexes").sql})` : `(${generated.as})`,
|
20953
21078
|
type: generated.mode ?? "virtual"
|
20954
21079
|
} : void 0
|
20955
21080
|
};
|
20956
21081
|
if (column7.default !== void 0) {
|
20957
|
-
if ((0,
|
21082
|
+
if ((0, import_drizzle_orm6.is)(column7.default, import_drizzle_orm6.SQL)) {
|
20958
21083
|
columnToSet.default = sqlToStr(column7.default, casing2);
|
20959
21084
|
} else {
|
20960
21085
|
columnToSet.default = typeof column7.default === "string" ? `'${column7.default}'` : typeof column7.default === "object" || Array.isArray(column7.default) ? `'${JSON.stringify(column7.default)}'` : column7.default;
|
@@ -21291,30 +21416,15 @@ WHERE
|
|
21291
21416
|
});
|
21292
21417
|
|
21293
21418
|
// src/serializer/index.ts
|
21294
|
-
var
|
21419
|
+
var import_fs3, glob, import_path3, serializeMySql, serializePg, serializeSQLite, prepareFilenames;
|
21295
21420
|
var init_serializer = __esm({
|
21296
21421
|
"src/serializer/index.ts"() {
|
21297
21422
|
"use strict";
|
21298
21423
|
init_source();
|
21299
|
-
import_casing2 = require("drizzle-orm/casing");
|
21300
21424
|
import_fs3 = __toESM(require("fs"));
|
21301
21425
|
glob = __toESM(require_glob());
|
21302
21426
|
import_path3 = __toESM(require("path"));
|
21303
21427
|
init_views();
|
21304
|
-
sqlToStr = (sql, casing2) => {
|
21305
|
-
return sql.toQuery({
|
21306
|
-
escapeName: () => {
|
21307
|
-
throw new Error("we don't support params for `sql` default values");
|
21308
|
-
},
|
21309
|
-
escapeParam: () => {
|
21310
|
-
throw new Error("we don't support params for `sql` default values");
|
21311
|
-
},
|
21312
|
-
escapeString: () => {
|
21313
|
-
throw new Error("we don't support params for `sql` default values");
|
21314
|
-
},
|
21315
|
-
casing: new import_casing2.CasingCache(casing2)
|
21316
|
-
}).sql;
|
21317
|
-
};
|
21318
21428
|
serializeMySql = async (path5, casing2) => {
|
21319
21429
|
const filenames = prepareFilenames(path5);
|
21320
21430
|
console.log(source_default.gray(`Reading schema files:
|
@@ -21329,10 +21439,10 @@ ${filenames.join("\n")}
|
|
21329
21439
|
const filenames = prepareFilenames(path5);
|
21330
21440
|
const { prepareFromPgImports: prepareFromPgImports2 } = await Promise.resolve().then(() => (init_pgImports(), pgImports_exports));
|
21331
21441
|
const { generatePgSnapshot: generatePgSnapshot2 } = await Promise.resolve().then(() => (init_pgSerializer(), pgSerializer_exports));
|
21332
|
-
const { tables, enums, schemas, sequences, views, matViews, roles } = await prepareFromPgImports2(
|
21442
|
+
const { tables, enums, schemas, sequences, views, matViews, roles, policies } = await prepareFromPgImports2(
|
21333
21443
|
filenames
|
21334
21444
|
);
|
21335
|
-
return generatePgSnapshot2(tables, enums, schemas, sequences, roles, views, matViews, casing2, schemaFilter);
|
21445
|
+
return generatePgSnapshot2(tables, enums, schemas, sequences, roles, policies, views, matViews, casing2, schemaFilter);
|
21336
21446
|
};
|
21337
21447
|
serializeSQLite = async (path5, casing2) => {
|
21338
21448
|
const filenames = prepareFilenames(path5);
|
@@ -23808,6 +23918,14 @@ function diffSchemasOrTables(left, right) {
|
|
23808
23918
|
const deleted = result.filter((it) => it[0].endsWith("__deleted")).map((it) => it[1]);
|
23809
23919
|
return { added, deleted };
|
23810
23920
|
}
|
23921
|
+
function diffIndPolicies(left, right) {
|
23922
|
+
left = JSON.parse(JSON.stringify(left));
|
23923
|
+
right = JSON.parse(JSON.stringify(right));
|
23924
|
+
const result = Object.entries((0, import_json_diff.diff)(left, right) ?? {});
|
23925
|
+
const added = result.filter((it) => it[0].endsWith("__added")).map((it) => it[1]);
|
23926
|
+
const deleted = result.filter((it) => it[0].endsWith("__deleted")).map((it) => it[1]);
|
23927
|
+
return { added, deleted };
|
23928
|
+
}
|
23811
23929
|
function diffColumns(left, right) {
|
23812
23930
|
left = JSON.parse(JSON.stringify(left));
|
23813
23931
|
right = JSON.parse(JSON.stringify(right));
|
@@ -23880,6 +23998,7 @@ function applyJsonDiff(json1, json2) {
|
|
23880
23998
|
difference.enums = difference.enums || {};
|
23881
23999
|
difference.sequences = difference.sequences || {};
|
23882
24000
|
difference.roles = difference.roles || {};
|
24001
|
+
difference.policies = difference.policies || {};
|
23883
24002
|
difference.views = difference.views || {};
|
23884
24003
|
const schemaKeys = Object.keys(difference.schemas);
|
23885
24004
|
for (let key of schemaKeys) {
|
@@ -23940,6 +24059,10 @@ function applyJsonDiff(json1, json2) {
|
|
23940
24059
|
const alteredRoles = rolesEntries.filter((it) => !(it[0].includes("__added") || it[0].includes("__deleted"))).map((it) => {
|
23941
24060
|
return json2.roles[it[0]];
|
23942
24061
|
});
|
24062
|
+
const policiesEntries = Object.entries(difference.policies);
|
24063
|
+
const alteredPolicies = policiesEntries.filter((it) => !(it[0].includes("__added") || it[0].includes("__deleted"))).map((it) => {
|
24064
|
+
return json2.policies[it[0]];
|
24065
|
+
});
|
23943
24066
|
const viewsEntries = Object.entries(difference.views);
|
23944
24067
|
const alteredViews = viewsEntries.filter((it) => !(it[0].includes("__added") || it[0].includes("__deleted"))).map(
|
23945
24068
|
([nameWithSchema, view4]) => {
|
@@ -24020,7 +24143,8 @@ function applyJsonDiff(json1, json2) {
|
|
24020
24143
|
alteredEnums,
|
24021
24144
|
alteredSequences,
|
24022
24145
|
alteredRoles,
|
24023
|
-
alteredViews
|
24146
|
+
alteredViews,
|
24147
|
+
alteredPolicies
|
24024
24148
|
};
|
24025
24149
|
}
|
24026
24150
|
var import_json_diff, mapArraysDiff, findAlternationsInTable, alternationsInColumn;
|
@@ -24477,7 +24601,7 @@ function fromJson(statements, dialect4, action, json2) {
|
|
24477
24601
|
}).filter((it) => it !== "");
|
24478
24602
|
return result;
|
24479
24603
|
}
|
24480
|
-
var pgNativeTypes, isPgNativeType, Convertor, PgCreateRoleConvertor, PgDropRoleConvertor, PgRenameRoleConvertor, PgAlterRoleConvertor, PgCreatePolicyConvertor, PgDropPolicyConvertor, PgRenamePolicyConvertor, PgAlterPolicyConvertor, 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;
|
24604
|
+
var pgNativeTypes, isPgNativeType, 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;
|
24481
24605
|
var init_sqlgenerator = __esm({
|
24482
24606
|
"src/sqlgenerator.ts"() {
|
24483
24607
|
"use strict";
|
@@ -24572,14 +24696,14 @@ var init_sqlgenerator = __esm({
|
|
24572
24696
|
}
|
24573
24697
|
convert(statement) {
|
24574
24698
|
var _a, _b, _c;
|
24575
|
-
const
|
24699
|
+
const policy4 = statement.data;
|
24576
24700
|
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
24577
|
-
const usingPart =
|
24578
|
-
const withCheckPart =
|
24579
|
-
const policyToPart = (_a =
|
24701
|
+
const usingPart = policy4.using ? ` USING (${policy4.using})` : "";
|
24702
|
+
const withCheckPart = policy4.withCheck ? ` WITH CHECK (${policy4.withCheck})` : "";
|
24703
|
+
const policyToPart = (_a = policy4.to) == null ? void 0 : _a.map(
|
24580
24704
|
(v) => ["current_user", "current_role", "session_user", "public"].includes(v) ? v : `"${v}"`
|
24581
24705
|
).join(", ");
|
24582
|
-
return `CREATE POLICY "${
|
24706
|
+
return `CREATE POLICY "${policy4.name}" ON ${tableNameWithSchema} AS ${(_b = policy4.as) == null ? void 0 : _b.toUpperCase()} FOR ${(_c = policy4.for) == null ? void 0 : _c.toUpperCase()} TO ${policyToPart}${usingPart}${withCheckPart};`;
|
24583
24707
|
}
|
24584
24708
|
};
|
24585
24709
|
PgDropPolicyConvertor = class extends Convertor {
|
@@ -24587,9 +24711,9 @@ var init_sqlgenerator = __esm({
|
|
24587
24711
|
return statement.type === "drop_policy" && dialect4 === "postgresql";
|
24588
24712
|
}
|
24589
24713
|
convert(statement) {
|
24590
|
-
const
|
24714
|
+
const policy4 = statement.data;
|
24591
24715
|
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
24592
|
-
return `DROP POLICY "${
|
24716
|
+
return `DROP POLICY "${policy4.name}" ON ${tableNameWithSchema} CASCADE;`;
|
24593
24717
|
}
|
24594
24718
|
};
|
24595
24719
|
PgRenamePolicyConvertor = class extends Convertor {
|
@@ -24614,6 +24738,50 @@ var init_sqlgenerator = __esm({
|
|
24614
24738
|
return `ALTER POLICY "${oldPolicy.name}" ON ${tableNameWithSchema} TO ${newPolicy.to}${usingPart}${withCheckPart};`;
|
24615
24739
|
}
|
24616
24740
|
};
|
24741
|
+
PgCreateIndPolicyConvertor = class extends Convertor {
|
24742
|
+
can(statement, dialect4) {
|
24743
|
+
return statement.type === "create_ind_policy" && dialect4 === "postgresql";
|
24744
|
+
}
|
24745
|
+
convert(statement) {
|
24746
|
+
var _a, _b, _c;
|
24747
|
+
const policy4 = statement.data;
|
24748
|
+
const usingPart = policy4.using ? ` USING (${policy4.using})` : "";
|
24749
|
+
const withCheckPart = policy4.withCheck ? ` WITH CHECK (${policy4.withCheck})` : "";
|
24750
|
+
const policyToPart = (_a = policy4.to) == null ? void 0 : _a.map(
|
24751
|
+
(v) => ["current_user", "current_role", "session_user", "public"].includes(v) ? v : `"${v}"`
|
24752
|
+
).join(", ");
|
24753
|
+
return `CREATE POLICY "${policy4.name}" ON ${policy4.on} AS ${(_b = policy4.as) == null ? void 0 : _b.toUpperCase()} FOR ${(_c = policy4.for) == null ? void 0 : _c.toUpperCase()} TO ${policyToPart}${usingPart}${withCheckPart};`;
|
24754
|
+
}
|
24755
|
+
};
|
24756
|
+
PgDropIndPolicyConvertor = class extends Convertor {
|
24757
|
+
can(statement, dialect4) {
|
24758
|
+
return statement.type === "drop_ind_policy" && dialect4 === "postgresql";
|
24759
|
+
}
|
24760
|
+
convert(statement) {
|
24761
|
+
const policy4 = statement.data;
|
24762
|
+
return `DROP POLICY "${policy4.name}" ON ${policy4.on} CASCADE;`;
|
24763
|
+
}
|
24764
|
+
};
|
24765
|
+
PgRenameIndPolicyConvertor = class extends Convertor {
|
24766
|
+
can(statement, dialect4) {
|
24767
|
+
return statement.type === "rename_ind_policy" && dialect4 === "postgresql";
|
24768
|
+
}
|
24769
|
+
convert(statement) {
|
24770
|
+
return `ALTER POLICY "${statement.oldName}" ON ${statement.tableKey} RENAME TO "${statement.newName}";`;
|
24771
|
+
}
|
24772
|
+
};
|
24773
|
+
PgAlterIndPolicyConvertor = class extends Convertor {
|
24774
|
+
can(statement, dialect4) {
|
24775
|
+
return statement.type === "alter_ind_policy" && dialect4 === "postgresql";
|
24776
|
+
}
|
24777
|
+
convert(statement) {
|
24778
|
+
const newPolicy = statement.newData;
|
24779
|
+
const oldPolicy = statement.oldData;
|
24780
|
+
const usingPart = newPolicy.using ? ` USING (${newPolicy.using})` : oldPolicy.using ? ` USING (${oldPolicy.using})` : "";
|
24781
|
+
const withCheckPart = newPolicy.withCheck ? ` WITH CHECK (${newPolicy.withCheck})` : oldPolicy.withCheck ? ` WITH CHECK (${oldPolicy.withCheck})` : "";
|
24782
|
+
return `ALTER POLICY "${oldPolicy.name}" ON ${oldPolicy.on} TO ${newPolicy.to}${usingPart}${withCheckPart};`;
|
24783
|
+
}
|
24784
|
+
};
|
24617
24785
|
PgEnableRlsConvertor = class extends Convertor {
|
24618
24786
|
can(statement, dialect4) {
|
24619
24787
|
return statement.type === "enable_rls" && dialect4 === "postgresql";
|
@@ -26514,6 +26682,10 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
26514
26682
|
convertors.push(new PgCreatePolicyConvertor());
|
26515
26683
|
convertors.push(new PgDropPolicyConvertor());
|
26516
26684
|
convertors.push(new PgRenamePolicyConvertor());
|
26685
|
+
convertors.push(new PgAlterIndPolicyConvertor());
|
26686
|
+
convertors.push(new PgCreateIndPolicyConvertor());
|
26687
|
+
convertors.push(new PgDropIndPolicyConvertor());
|
26688
|
+
convertors.push(new PgRenameIndPolicyConvertor());
|
26517
26689
|
convertors.push(new PgEnableRlsConvertor());
|
26518
26690
|
convertors.push(new PgDisableRlsConvertor());
|
26519
26691
|
convertors.push(new PgDropRoleConvertor());
|
@@ -26820,7 +26992,7 @@ var init_sqlitePushUtils = __esm({
|
|
26820
26992
|
});
|
26821
26993
|
|
26822
26994
|
// src/jsonStatements.ts
|
26823
|
-
var preparePgCreateTableJson, prepareMySqlCreateTableJson, prepareSQLiteCreateTable, prepareDropTableJson, prepareRenameTableJson, prepareCreateEnumJson, prepareAddValuesToEnumJson, prepareDropEnumValues, prepareDropEnumJson, prepareMoveEnumJson, prepareRenameEnumJson, prepareCreateSequenceJson, prepareAlterSequenceJson, prepareDropSequenceJson, prepareMoveSequenceJson, prepareRenameSequenceJson, prepareCreateRoleJson, prepareAlterRoleJson, prepareDropRoleJson, prepareRenameRoleJson, prepareCreateSchemasJson, prepareRenameSchemasJson, prepareDeleteSchemasJson, prepareRenameColumns, _prepareDropColumns, _prepareAddColumns, _prepareSqliteAddColumns, prepareAlterColumnsMysql, preparePgAlterColumns, prepareSqliteAlterColumns, prepareRenamePolicyJsons, prepareCreatePolicyJsons, prepareDropPolicyJsons, prepareAlterPolicyJson, preparePgCreateIndexesJson, prepareCreateIndexesJson, prepareCreateReferencesJson, prepareLibSQLCreateReferencesJson, prepareDropReferencesJson, prepareLibSQLDropReferencesJson, prepareAlterReferencesJson, prepareDropIndexesJson, prepareAddCompositePrimaryKeySqlite, prepareDeleteCompositePrimaryKeySqlite, prepareAlterCompositePrimaryKeySqlite, prepareAddCompositePrimaryKeyPg, prepareDeleteCompositePrimaryKeyPg, prepareAlterCompositePrimaryKeyPg, prepareAddUniqueConstraintPg, prepareDeleteUniqueConstraintPg, prepareAddCheckConstraint, prepareDeleteCheckConstraint, prepareAddCompositePrimaryKeyMySql, prepareDeleteCompositePrimaryKeyMySql, prepareAlterCompositePrimaryKeyMySql, preparePgCreateViewJson, prepareMySqlCreateViewJson, prepareSqliteCreateViewJson, prepareDropViewJson, prepareRenameViewJson, preparePgAlterViewAlterSchemaJson, preparePgAlterViewAddWithOptionJson, preparePgAlterViewDropWithOptionJson, preparePgAlterViewAlterTablespaceJson, preparePgAlterViewAlterUsingJson, prepareMySqlAlterView;
|
26995
|
+
var preparePgCreateTableJson, prepareMySqlCreateTableJson, prepareSQLiteCreateTable, prepareDropTableJson, prepareRenameTableJson, prepareCreateEnumJson, prepareAddValuesToEnumJson, prepareDropEnumValues, prepareDropEnumJson, prepareMoveEnumJson, prepareRenameEnumJson, prepareCreateSequenceJson, prepareAlterSequenceJson, prepareDropSequenceJson, prepareMoveSequenceJson, prepareRenameSequenceJson, prepareCreateRoleJson, prepareAlterRoleJson, prepareDropRoleJson, prepareRenameRoleJson, prepareCreateSchemasJson, prepareRenameSchemasJson, prepareDeleteSchemasJson, prepareRenameColumns, _prepareDropColumns, _prepareAddColumns, _prepareSqliteAddColumns, prepareAlterColumnsMysql, preparePgAlterColumns, prepareSqliteAlterColumns, prepareRenamePolicyJsons, prepareRenameIndPolicyJsons, prepareCreatePolicyJsons, prepareCreateIndPolicyJsons, prepareDropPolicyJsons, prepareDropIndPolicyJsons, prepareAlterPolicyJson, prepareAlterIndPolicyJson, preparePgCreateIndexesJson, prepareCreateIndexesJson, prepareCreateReferencesJson, prepareLibSQLCreateReferencesJson, prepareDropReferencesJson, prepareLibSQLDropReferencesJson, prepareAlterReferencesJson, prepareDropIndexesJson, prepareAddCompositePrimaryKeySqlite, prepareDeleteCompositePrimaryKeySqlite, prepareAlterCompositePrimaryKeySqlite, prepareAddCompositePrimaryKeyPg, prepareDeleteCompositePrimaryKeyPg, prepareAlterCompositePrimaryKeyPg, prepareAddUniqueConstraintPg, prepareDeleteUniqueConstraintPg, prepareAddCheckConstraint, prepareDeleteCheckConstraint, prepareAddCompositePrimaryKeyMySql, prepareDeleteCompositePrimaryKeyMySql, prepareAlterCompositePrimaryKeyMySql, preparePgCreateViewJson, prepareMySqlCreateViewJson, prepareSqliteCreateViewJson, prepareDropViewJson, prepareRenameViewJson, preparePgAlterViewAlterSchemaJson, preparePgAlterViewAddWithOptionJson, preparePgAlterViewDropWithOptionJson, preparePgAlterViewAlterTablespaceJson, preparePgAlterViewAlterUsingJson, prepareMySqlAlterView;
|
26824
26996
|
var init_jsonStatements = __esm({
|
26825
26997
|
"src/jsonStatements.ts"() {
|
26826
26998
|
"use strict";
|
@@ -27950,6 +28122,16 @@ var init_jsonStatements = __esm({
|
|
27950
28122
|
};
|
27951
28123
|
});
|
27952
28124
|
};
|
28125
|
+
prepareRenameIndPolicyJsons = (renames) => {
|
28126
|
+
return renames.map((it) => {
|
28127
|
+
return {
|
28128
|
+
type: "rename_ind_policy",
|
28129
|
+
tableKey: it.from.on,
|
28130
|
+
oldName: it.from.name,
|
28131
|
+
newName: it.to.name
|
28132
|
+
};
|
28133
|
+
});
|
28134
|
+
};
|
27953
28135
|
prepareCreatePolicyJsons = (tableName, schema5, policies) => {
|
27954
28136
|
return policies.map((it) => {
|
27955
28137
|
return {
|
@@ -27960,6 +28142,15 @@ var init_jsonStatements = __esm({
|
|
27960
28142
|
};
|
27961
28143
|
});
|
27962
28144
|
};
|
28145
|
+
prepareCreateIndPolicyJsons = (policies) => {
|
28146
|
+
return policies.map((it) => {
|
28147
|
+
return {
|
28148
|
+
type: "create_ind_policy",
|
28149
|
+
tableName: it.on,
|
28150
|
+
data: it
|
28151
|
+
};
|
28152
|
+
});
|
28153
|
+
};
|
27963
28154
|
prepareDropPolicyJsons = (tableName, schema5, policies) => {
|
27964
28155
|
return policies.map((it) => {
|
27965
28156
|
return {
|
@@ -27970,6 +28161,15 @@ var init_jsonStatements = __esm({
|
|
27970
28161
|
};
|
27971
28162
|
});
|
27972
28163
|
};
|
28164
|
+
prepareDropIndPolicyJsons = (policies) => {
|
28165
|
+
return policies.map((it) => {
|
28166
|
+
return {
|
28167
|
+
type: "drop_ind_policy",
|
28168
|
+
tableName: it.on,
|
28169
|
+
data: it
|
28170
|
+
};
|
28171
|
+
});
|
28172
|
+
};
|
27973
28173
|
prepareAlterPolicyJson = (tableName, schema5, oldPolicy, newPolicy) => {
|
27974
28174
|
return {
|
27975
28175
|
type: "alter_policy",
|
@@ -27979,6 +28179,13 @@ var init_jsonStatements = __esm({
|
|
27979
28179
|
schema: schema5
|
27980
28180
|
};
|
27981
28181
|
};
|
28182
|
+
prepareAlterIndPolicyJson = (oldPolicy, newPolicy) => {
|
28183
|
+
return {
|
28184
|
+
type: "alter_ind_policy",
|
28185
|
+
oldData: oldPolicy,
|
28186
|
+
newData: newPolicy
|
28187
|
+
};
|
28188
|
+
};
|
27982
28189
|
preparePgCreateIndexesJson = (tableName, schema5, indexes, fullSchema, action) => {
|
27983
28190
|
if (action === "push") {
|
27984
28191
|
return Object.values(indexes).map((indexData) => {
|
@@ -28892,6 +29099,7 @@ var init_snapshotsDiffer = __esm({
|
|
28892
29099
|
alteredEnums: changedEnumSchema.array(),
|
28893
29100
|
alteredSequences: sequenceSquashed.array(),
|
28894
29101
|
alteredRoles: roleSchema.array(),
|
29102
|
+
alteredPolicies: policySquashed.array(),
|
28895
29103
|
alteredViews: alteredPgViewSchema.array()
|
28896
29104
|
}).strict();
|
28897
29105
|
diffResultSchemeMysql = objectType({
|
@@ -28949,7 +29157,7 @@ var init_snapshotsDiffer = __esm({
|
|
28949
29157
|
}
|
28950
29158
|
return column7;
|
28951
29159
|
};
|
28952
|
-
applyPgSnapshotsDiff = async (json1, json2, schemasResolver2, enumsResolver2, sequencesResolver2, policyResolver2, roleResolver2, tablesResolver2, columnsResolver2, viewsResolver2, prevFull, curFull, action) => {
|
29160
|
+
applyPgSnapshotsDiff = async (json1, json2, schemasResolver2, enumsResolver2, sequencesResolver2, policyResolver2, indPolicyResolver2, roleResolver2, tablesResolver2, columnsResolver2, viewsResolver2, prevFull, curFull, action) => {
|
28953
29161
|
const schemasDiff = diffSchemasOrTables(json1.schemas, json2.schemas);
|
28954
29162
|
const {
|
28955
29163
|
created: createdSchemas,
|
@@ -29166,24 +29374,24 @@ var init_snapshotsDiffer = __esm({
|
|
29166
29374
|
const columnCreates = [];
|
29167
29375
|
const columnDeletes = [];
|
29168
29376
|
for (let entry of Object.values(res)) {
|
29169
|
-
const { renamed, created, deleted } = await columnsResolver2({
|
29377
|
+
const { renamed, created: created2, deleted: deleted2 } = await columnsResolver2({
|
29170
29378
|
tableName: entry.name,
|
29171
29379
|
schema: entry.schema,
|
29172
29380
|
deleted: entry.columns.deleted,
|
29173
29381
|
created: entry.columns.added
|
29174
29382
|
});
|
29175
|
-
if (
|
29383
|
+
if (created2.length > 0) {
|
29176
29384
|
columnCreates.push({
|
29177
29385
|
table: entry.name,
|
29178
29386
|
schema: entry.schema,
|
29179
|
-
columns:
|
29387
|
+
columns: created2
|
29180
29388
|
});
|
29181
29389
|
}
|
29182
|
-
if (
|
29390
|
+
if (deleted2.length > 0) {
|
29183
29391
|
columnDeletes.push({
|
29184
29392
|
table: entry.name,
|
29185
29393
|
schema: entry.schema,
|
29186
|
-
columns:
|
29394
|
+
columns: deleted2
|
29187
29395
|
});
|
29188
29396
|
}
|
29189
29397
|
if (renamed.length > 0) {
|
@@ -29223,24 +29431,24 @@ var init_snapshotsDiffer = __esm({
|
|
29223
29431
|
const policyCreates = [];
|
29224
29432
|
const policyDeletes = [];
|
29225
29433
|
for (let entry of Object.values(policyRes)) {
|
29226
|
-
const { renamed, created, deleted } = await policyResolver2({
|
29434
|
+
const { renamed, created: created2, deleted: deleted2 } = await policyResolver2({
|
29227
29435
|
tableName: entry.name,
|
29228
29436
|
schema: entry.schema,
|
29229
29437
|
deleted: entry.policies.deleted.map(PgSquasher.unsquashPolicy),
|
29230
29438
|
created: entry.policies.added.map(PgSquasher.unsquashPolicy)
|
29231
29439
|
});
|
29232
|
-
if (
|
29440
|
+
if (created2.length > 0) {
|
29233
29441
|
policyCreates.push({
|
29234
29442
|
table: entry.name,
|
29235
29443
|
schema: entry.schema,
|
29236
|
-
columns:
|
29444
|
+
columns: created2
|
29237
29445
|
});
|
29238
29446
|
}
|
29239
|
-
if (
|
29447
|
+
if (deleted2.length > 0) {
|
29240
29448
|
policyDeletes.push({
|
29241
29449
|
table: entry.name,
|
29242
29450
|
schema: entry.schema,
|
29243
|
-
columns:
|
29451
|
+
columns: deleted2
|
29244
29452
|
});
|
29245
29453
|
}
|
29246
29454
|
if (renamed.length > 0) {
|
@@ -29264,12 +29472,12 @@ var init_snapshotsDiffer = __esm({
|
|
29264
29472
|
(tableKey2, tableValue) => {
|
29265
29473
|
const patchedPolicies = mapKeys(
|
29266
29474
|
tableValue.policies,
|
29267
|
-
(policyKey,
|
29475
|
+
(policyKey, policy4) => {
|
29268
29476
|
const rens = policyRenamesDict[`${tableValue.schema || "public"}.${tableValue.name}`] || [];
|
29269
29477
|
const newName = columnChangeFor(policyKey, rens);
|
29270
|
-
const unsquashedPolicy = PgSquasher.unsquashPolicy(
|
29478
|
+
const unsquashedPolicy = PgSquasher.unsquashPolicy(policy4);
|
29271
29479
|
unsquashedPolicy.name = newName;
|
29272
|
-
|
29480
|
+
policy4 = PgSquasher.squashPolicy(unsquashedPolicy);
|
29273
29481
|
return newName;
|
29274
29482
|
}
|
29275
29483
|
);
|
@@ -29277,7 +29485,46 @@ var init_snapshotsDiffer = __esm({
|
|
29277
29485
|
return [tableKey2, tableValue];
|
29278
29486
|
}
|
29279
29487
|
);
|
29280
|
-
const
|
29488
|
+
const indPolicyRes = diffIndPolicies(policyPatchedSnap1.policies, json2.policies);
|
29489
|
+
const indPolicyCreates = [];
|
29490
|
+
const indPolicyDeletes = [];
|
29491
|
+
const { renamed: indPolicyRenames, created, deleted } = await indPolicyResolver2({
|
29492
|
+
deleted: indPolicyRes.deleted.map((t2) => PgSquasher.unsquashPolicy(t2.values)),
|
29493
|
+
created: indPolicyRes.added.map((t2) => PgSquasher.unsquashPolicy(t2.values))
|
29494
|
+
});
|
29495
|
+
if (created.length > 0) {
|
29496
|
+
indPolicyCreates.push({
|
29497
|
+
policies: created
|
29498
|
+
});
|
29499
|
+
}
|
29500
|
+
if (deleted.length > 0) {
|
29501
|
+
indPolicyDeletes.push({
|
29502
|
+
policies: deleted
|
29503
|
+
});
|
29504
|
+
}
|
29505
|
+
const indPolicyRenamesDict = indPolicyRenames.reduce(
|
29506
|
+
(acc, it) => {
|
29507
|
+
acc[it.from.name] = {
|
29508
|
+
nameFrom: it.from.name,
|
29509
|
+
nameTo: it.to.name
|
29510
|
+
};
|
29511
|
+
return acc;
|
29512
|
+
},
|
29513
|
+
{}
|
29514
|
+
);
|
29515
|
+
const indPolicyPatchedSnap1 = copy(policyPatchedSnap1);
|
29516
|
+
indPolicyPatchedSnap1.policies = mapEntries(
|
29517
|
+
indPolicyPatchedSnap1.policies,
|
29518
|
+
(policyKey, policyValue) => {
|
29519
|
+
const key = policyKey;
|
29520
|
+
const change = indPolicyRenamesDict[key];
|
29521
|
+
if (change) {
|
29522
|
+
policyValue.name = change.nameTo;
|
29523
|
+
}
|
29524
|
+
return [policyKey, policyValue];
|
29525
|
+
}
|
29526
|
+
);
|
29527
|
+
const viewsDiff = diffSchemasOrTables(indPolicyPatchedSnap1.views, json2.views);
|
29281
29528
|
const {
|
29282
29529
|
created: createdViews,
|
29283
29530
|
deleted: deletedViews,
|
@@ -29419,16 +29666,16 @@ var init_snapshotsDiffer = __esm({
|
|
29419
29666
|
);
|
29420
29667
|
if (it.alteredUniqueConstraints) {
|
29421
29668
|
const added = {};
|
29422
|
-
const
|
29669
|
+
const deleted2 = {};
|
29423
29670
|
for (const k of Object.keys(it.alteredUniqueConstraints)) {
|
29424
29671
|
added[k] = it.alteredUniqueConstraints[k].__new;
|
29425
|
-
|
29672
|
+
deleted2[k] = it.alteredUniqueConstraints[k].__old;
|
29426
29673
|
}
|
29427
29674
|
addedUniqueConstraints.push(
|
29428
29675
|
...prepareAddUniqueConstraintPg(it.name, it.schema, added)
|
29429
29676
|
);
|
29430
29677
|
deletedUniqueConstraints.push(
|
29431
|
-
...prepareDeleteUniqueConstraintPg(it.name, it.schema,
|
29678
|
+
...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted2)
|
29432
29679
|
);
|
29433
29680
|
}
|
29434
29681
|
createCheckConstraints = prepareAddCheckConstraint(it.name, it.schema, it.addedCheckConstraints);
|
@@ -29439,13 +29686,13 @@ var init_snapshotsDiffer = __esm({
|
|
29439
29686
|
);
|
29440
29687
|
if (it.alteredCheckConstraints && action !== "push") {
|
29441
29688
|
const added = {};
|
29442
|
-
const
|
29689
|
+
const deleted2 = {};
|
29443
29690
|
for (const k of Object.keys(it.alteredCheckConstraints)) {
|
29444
29691
|
added[k] = it.alteredCheckConstraints[k].__new;
|
29445
|
-
|
29692
|
+
deleted2[k] = it.alteredCheckConstraints[k].__old;
|
29446
29693
|
}
|
29447
29694
|
createCheckConstraints.push(...prepareAddCheckConstraint(it.name, it.schema, added));
|
29448
|
-
deleteCheckConstraints.push(...prepareDeleteCheckConstraint(it.name, it.schema,
|
29695
|
+
deleteCheckConstraints.push(...prepareDeleteCheckConstraint(it.name, it.schema, deleted2));
|
29449
29696
|
}
|
29450
29697
|
jsonCreatedCheckConstraints.push(...createCheckConstraints);
|
29451
29698
|
jsonDeletedCheckConstraints.push(...deleteCheckConstraints);
|
@@ -29493,8 +29740,68 @@ var init_snapshotsDiffer = __esm({
|
|
29493
29740
|
const jsonDropPoliciesStatements = [];
|
29494
29741
|
const jsonAlterPoliciesStatements = [];
|
29495
29742
|
const jsonRenamePoliciesStatements = [];
|
29743
|
+
const jsonRenameIndPoliciesStatements = [];
|
29744
|
+
const jsonCreateIndPoliciesStatements = [];
|
29745
|
+
const jsonDropIndPoliciesStatements = [];
|
29746
|
+
const jsonAlterIndPoliciesStatements = [];
|
29496
29747
|
const jsonEnableRLSStatements = [];
|
29497
29748
|
const jsonDisableRLSStatements = [];
|
29749
|
+
for (let it of indPolicyRenames) {
|
29750
|
+
jsonRenameIndPoliciesStatements.push(
|
29751
|
+
...prepareRenameIndPolicyJsons([it])
|
29752
|
+
);
|
29753
|
+
}
|
29754
|
+
for (const it of indPolicyCreates) {
|
29755
|
+
jsonCreateIndPoliciesStatements.push(
|
29756
|
+
...prepareCreateIndPolicyJsons(
|
29757
|
+
it.policies
|
29758
|
+
)
|
29759
|
+
);
|
29760
|
+
}
|
29761
|
+
for (const it of indPolicyDeletes) {
|
29762
|
+
jsonDropIndPoliciesStatements.push(
|
29763
|
+
...prepareDropIndPolicyJsons(
|
29764
|
+
it.policies
|
29765
|
+
)
|
29766
|
+
);
|
29767
|
+
}
|
29768
|
+
typedResult.alteredPolicies.forEach(({ values }) => {
|
29769
|
+
const policy4 = PgSquasher.unsquashPolicy(values);
|
29770
|
+
const newPolicy = PgSquasher.unsquashPolicy(json2.policies[policy4.name].values);
|
29771
|
+
const oldPolicy = PgSquasher.unsquashPolicy(json1.policies[policy4.name].values);
|
29772
|
+
if (newPolicy.as !== oldPolicy.as) {
|
29773
|
+
jsonDropIndPoliciesStatements.push(
|
29774
|
+
...prepareDropIndPolicyJsons(
|
29775
|
+
[oldPolicy]
|
29776
|
+
)
|
29777
|
+
);
|
29778
|
+
jsonCreateIndPoliciesStatements.push(
|
29779
|
+
...prepareCreateIndPolicyJsons(
|
29780
|
+
[newPolicy]
|
29781
|
+
)
|
29782
|
+
);
|
29783
|
+
return;
|
29784
|
+
}
|
29785
|
+
if (newPolicy.for !== oldPolicy.for) {
|
29786
|
+
jsonDropIndPoliciesStatements.push(
|
29787
|
+
...prepareDropIndPolicyJsons(
|
29788
|
+
[oldPolicy]
|
29789
|
+
)
|
29790
|
+
);
|
29791
|
+
jsonCreateIndPoliciesStatements.push(
|
29792
|
+
...prepareCreateIndPolicyJsons(
|
29793
|
+
[newPolicy]
|
29794
|
+
)
|
29795
|
+
);
|
29796
|
+
return;
|
29797
|
+
}
|
29798
|
+
jsonAlterIndPoliciesStatements.push(
|
29799
|
+
prepareAlterIndPolicyJson(
|
29800
|
+
oldPolicy,
|
29801
|
+
newPolicy
|
29802
|
+
)
|
29803
|
+
);
|
29804
|
+
});
|
29498
29805
|
for (let it of policyRenames) {
|
29499
29806
|
jsonRenamePoliciesStatements.push(
|
29500
29807
|
...prepareRenamePolicyJsons(it.table, it.schema, it.renames)
|
@@ -29882,6 +30189,10 @@ var init_snapshotsDiffer = __esm({
|
|
29882
30189
|
jsonStatements.push(...jsonDropPoliciesStatements);
|
29883
30190
|
jsonStatements.push(...jsonCreatePoliciesStatements);
|
29884
30191
|
jsonStatements.push(...jsonAlterPoliciesStatements);
|
30192
|
+
jsonStatements.push(...jsonRenameIndPoliciesStatements);
|
30193
|
+
jsonStatements.push(...jsonDropIndPoliciesStatements);
|
30194
|
+
jsonStatements.push(...jsonCreateIndPoliciesStatements);
|
30195
|
+
jsonStatements.push(...jsonAlterIndPoliciesStatements);
|
29885
30196
|
jsonStatements.push(...createViews);
|
29886
30197
|
jsonStatements.push(...dropEnums);
|
29887
30198
|
jsonStatements.push(...dropSequences);
|
@@ -32466,6 +32777,7 @@ __export(migrate_exports, {
|
|
32466
32777
|
columnsResolver: () => columnsResolver,
|
32467
32778
|
embeddedMigrations: () => embeddedMigrations,
|
32468
32779
|
enumsResolver: () => enumsResolver,
|
32780
|
+
indPolicyResolver: () => indPolicyResolver,
|
32469
32781
|
mySqlViewsResolver: () => mySqlViewsResolver,
|
32470
32782
|
policyResolver: () => policyResolver,
|
32471
32783
|
prepareAndMigrateLibSQL: () => prepareAndMigrateLibSQL,
|
@@ -32489,7 +32801,7 @@ __export(migrate_exports, {
|
|
32489
32801
|
viewsResolver: () => viewsResolver,
|
32490
32802
|
writeResult: () => writeResult
|
32491
32803
|
});
|
32492
|
-
var import_fs5, import_hanji3, import_path4, schemasResolver, tablesResolver, viewsResolver, mySqlViewsResolver, sqliteViewsResolver, sequencesResolver, roleResolver, policyResolver, enumsResolver, columnsResolver, prepareAndMigratePg, preparePgPush, prepareMySQLPush, prepareAndMigrateMysql, prepareAndMigrateSqlite, prepareAndMigrateLibSQL, prepareSQLitePush, prepareLibSQLPush, promptColumnsConflicts, promptNamedConflict, promptNamedWithSchemasConflict, promptSchemasConflict, BREAKPOINT, writeResult, embeddedMigrations, prepareSnapshotFolderName, two;
|
32804
|
+
var import_fs5, import_hanji3, import_path4, schemasResolver, tablesResolver, viewsResolver, mySqlViewsResolver, sqliteViewsResolver, sequencesResolver, roleResolver, policyResolver, indPolicyResolver, enumsResolver, columnsResolver, prepareAndMigratePg, preparePgPush, prepareMySQLPush, prepareAndMigrateMysql, prepareAndMigrateSqlite, prepareAndMigrateLibSQL, prepareSQLitePush, prepareLibSQLPush, promptColumnsConflicts, promptNamedConflict, promptNamedWithSchemasConflict, promptSchemasConflict, BREAKPOINT, writeResult, embeddedMigrations, prepareSnapshotFolderName, two;
|
32493
32805
|
var init_migrate = __esm({
|
32494
32806
|
"src/cli/commands/migrate.ts"() {
|
32495
32807
|
"use strict";
|
@@ -32634,6 +32946,18 @@ var init_migrate = __esm({
|
|
32634
32946
|
renamed: result.renamed
|
32635
32947
|
};
|
32636
32948
|
};
|
32949
|
+
indPolicyResolver = async (input) => {
|
32950
|
+
const result = await promptNamedConflict(
|
32951
|
+
input.created,
|
32952
|
+
input.deleted,
|
32953
|
+
"policy"
|
32954
|
+
);
|
32955
|
+
return {
|
32956
|
+
created: result.created,
|
32957
|
+
deleted: result.deleted,
|
32958
|
+
renamed: result.renamed
|
32959
|
+
};
|
32960
|
+
};
|
32637
32961
|
enumsResolver = async (input) => {
|
32638
32962
|
try {
|
32639
32963
|
const { created, deleted, moved, renamed } = await promptNamedWithSchemasConflict(
|
@@ -32705,6 +33029,7 @@ var init_migrate = __esm({
|
|
32705
33029
|
enumsResolver,
|
32706
33030
|
sequencesResolver,
|
32707
33031
|
policyResolver,
|
33032
|
+
indPolicyResolver,
|
32708
33033
|
roleResolver,
|
32709
33034
|
tablesResolver,
|
32710
33035
|
columnsResolver,
|
@@ -32743,6 +33068,7 @@ var init_migrate = __esm({
|
|
32743
33068
|
enumsResolver,
|
32744
33069
|
sequencesResolver,
|
32745
33070
|
policyResolver,
|
33071
|
+
indPolicyResolver,
|
32746
33072
|
roleResolver,
|
32747
33073
|
tablesResolver,
|
32748
33074
|
columnsResolver,
|
@@ -36003,6 +36329,28 @@ var init_dist2 = __esm({
|
|
36003
36329
|
}
|
36004
36330
|
});
|
36005
36331
|
|
36332
|
+
// ../node_modules/.pnpm/hono@4.5.0/node_modules/hono/dist/middleware/compress/index.js
|
36333
|
+
var ENCODING_TYPES, compress;
|
36334
|
+
var init_compress = __esm({
|
36335
|
+
"../node_modules/.pnpm/hono@4.5.0/node_modules/hono/dist/middleware/compress/index.js"() {
|
36336
|
+
ENCODING_TYPES = ["gzip", "deflate"];
|
36337
|
+
compress = (options) => {
|
36338
|
+
return async function compress2(ctx, next) {
|
36339
|
+
await next();
|
36340
|
+
const accepted = ctx.req.header("Accept-Encoding");
|
36341
|
+
const encoding = (options == null ? void 0 : options.encoding) ?? ENCODING_TYPES.find((encoding2) => accepted == null ? void 0 : accepted.includes(encoding2));
|
36342
|
+
if (!encoding || !ctx.res.body) {
|
36343
|
+
return;
|
36344
|
+
}
|
36345
|
+
const stream = new CompressionStream(encoding);
|
36346
|
+
ctx.res = new Response(ctx.res.body.pipeThrough(stream), ctx.res);
|
36347
|
+
ctx.res.headers.delete("Content-Length");
|
36348
|
+
ctx.res.headers.set("Content-Encoding", encoding);
|
36349
|
+
};
|
36350
|
+
};
|
36351
|
+
}
|
36352
|
+
});
|
36353
|
+
|
36006
36354
|
// ../node_modules/.pnpm/hono@4.5.0/node_modules/hono/dist/middleware/cors/index.js
|
36007
36355
|
var cors;
|
36008
36356
|
var init_cors = __esm({
|
@@ -42316,7 +42664,7 @@ function determineRequestsReferrer(request, { referrerURLCallback, referrerOrigi
|
|
42316
42664
|
if (request.referrer === "no-referrer" || request.referrerPolicy === "") {
|
42317
42665
|
return null;
|
42318
42666
|
}
|
42319
|
-
const
|
42667
|
+
const policy4 = request.referrerPolicy;
|
42320
42668
|
if (request.referrer === "about:client") {
|
42321
42669
|
return "no-referrer";
|
42322
42670
|
}
|
@@ -42333,7 +42681,7 @@ function determineRequestsReferrer(request, { referrerURLCallback, referrerOrigi
|
|
42333
42681
|
referrerOrigin = referrerOriginCallback(referrerOrigin);
|
42334
42682
|
}
|
42335
42683
|
const currentURL = new URL(request.url);
|
42336
|
-
switch (
|
42684
|
+
switch (policy4) {
|
42337
42685
|
case "no-referrer":
|
42338
42686
|
return "no-referrer";
|
42339
42687
|
case "origin":
|
@@ -42369,18 +42717,18 @@ function determineRequestsReferrer(request, { referrerURLCallback, referrerOrigi
|
|
42369
42717
|
}
|
42370
42718
|
return referrerURL;
|
42371
42719
|
default:
|
42372
|
-
throw new TypeError(`Invalid referrerPolicy: ${
|
42720
|
+
throw new TypeError(`Invalid referrerPolicy: ${policy4}`);
|
42373
42721
|
}
|
42374
42722
|
}
|
42375
42723
|
function parseReferrerPolicyFromHeader(headers) {
|
42376
42724
|
const policyTokens = (headers.get("referrer-policy") || "").split(/[,\s]+/);
|
42377
|
-
let
|
42725
|
+
let policy4 = "";
|
42378
42726
|
for (const token of policyTokens) {
|
42379
42727
|
if (token && ReferrerPolicy.has(token)) {
|
42380
|
-
|
42728
|
+
policy4 = token;
|
42381
42729
|
}
|
42382
42730
|
}
|
42383
|
-
return
|
42731
|
+
return policy4;
|
42384
42732
|
}
|
42385
42733
|
var import_node_net, ReferrerPolicy, DEFAULT_REFERRER_POLICY;
|
42386
42734
|
var init_referrer = __esm({
|
@@ -44958,8 +45306,8 @@ var require_sender = __commonJS({
|
|
44958
45306
|
* @param {Function} [cb] Callback
|
44959
45307
|
* @private
|
44960
45308
|
*/
|
44961
|
-
dispatch(data,
|
44962
|
-
if (!
|
45309
|
+
dispatch(data, compress2, options, cb) {
|
45310
|
+
if (!compress2) {
|
44963
45311
|
this.sendFrame(_Sender.frame(data, options), cb);
|
44964
45312
|
return;
|
44965
45313
|
}
|
@@ -52061,12 +52409,12 @@ var require_dist_cjs32 = __commonJS({
|
|
52061
52409
|
this.middlewareStack = (0, import_middleware_stack.constructStack)();
|
52062
52410
|
this.config = config;
|
52063
52411
|
}
|
52064
|
-
send(
|
52412
|
+
send(command, optionsOrCb, cb) {
|
52065
52413
|
const options = typeof optionsOrCb !== "function" ? optionsOrCb : void 0;
|
52066
52414
|
const callback = typeof optionsOrCb === "function" ? optionsOrCb : cb;
|
52067
|
-
const handler =
|
52415
|
+
const handler = command.resolveMiddleware(this.middlewareStack, this.config, options);
|
52068
52416
|
if (callback) {
|
52069
|
-
handler(
|
52417
|
+
handler(command).then(
|
52070
52418
|
(result) => callback(null, result.output),
|
52071
52419
|
(err2) => callback(err2)
|
52072
52420
|
).catch(
|
@@ -52076,7 +52424,7 @@ var require_dist_cjs32 = __commonJS({
|
|
52076
52424
|
}
|
52077
52425
|
);
|
52078
52426
|
} else {
|
52079
|
-
return handler(
|
52427
|
+
return handler(command).then((result) => result.output);
|
52080
52428
|
}
|
52081
52429
|
}
|
52082
52430
|
destroy() {
|
@@ -52276,8 +52624,8 @@ var require_dist_cjs32 = __commonJS({
|
|
52276
52624
|
var ClassBuilder = _ClassBuilder;
|
52277
52625
|
var SENSITIVE_STRING = "***SensitiveInformation***";
|
52278
52626
|
var createAggregatedClient = /* @__PURE__ */ __name((commands, Client2) => {
|
52279
|
-
for (const
|
52280
|
-
const CommandCtor = commands[
|
52627
|
+
for (const command of Object.keys(commands)) {
|
52628
|
+
const CommandCtor = commands[command];
|
52281
52629
|
const methodImpl = /* @__PURE__ */ __name(async function(args, optionsOrCb, cb) {
|
52282
52630
|
const command22 = new CommandCtor(args);
|
52283
52631
|
if (typeof optionsOrCb === "function") {
|
@@ -52290,7 +52638,7 @@ var require_dist_cjs32 = __commonJS({
|
|
52290
52638
|
return this.send(command22, optionsOrCb);
|
52291
52639
|
}
|
52292
52640
|
}, "methodImpl");
|
52293
|
-
const methodName = (
|
52641
|
+
const methodName = (command[0].toLowerCase() + command.slice(1)).replace(/Command$/, "");
|
52294
52642
|
Client2.prototype[methodName] = methodImpl;
|
52295
52643
|
}
|
52296
52644
|
}, "createAggregatedClient");
|
@@ -56503,9 +56851,9 @@ var require_node2json = __commonJS({
|
|
56503
56851
|
"../node_modules/.pnpm/fast-xml-parser@4.2.5/node_modules/fast-xml-parser/src/xmlparser/node2json.js"(exports2) {
|
56504
56852
|
"use strict";
|
56505
56853
|
function prettify(node, options) {
|
56506
|
-
return
|
56854
|
+
return compress2(node, options);
|
56507
56855
|
}
|
56508
|
-
function
|
56856
|
+
function compress2(arr, options, jPath) {
|
56509
56857
|
let text;
|
56510
56858
|
const compressedObj = {};
|
56511
56859
|
for (let i2 = 0; i2 < arr.length; i2++) {
|
@@ -56524,7 +56872,7 @@ var require_node2json = __commonJS({
|
|
56524
56872
|
} else if (property === void 0) {
|
56525
56873
|
continue;
|
56526
56874
|
} else if (tagObj[property]) {
|
56527
|
-
let val2 =
|
56875
|
+
let val2 = compress2(tagObj[property], options, newJpath);
|
56528
56876
|
const isLeaf = isLeafTag(val2, options);
|
56529
56877
|
if (tagObj[":@"]) {
|
56530
56878
|
assignAttributes(val2, tagObj[":@"], newJpath, options);
|
@@ -63027,7 +63375,7 @@ var require_fromWebToken = __commonJS({
|
|
63027
63375
|
var fromWebToken2 = (init2) => async () => {
|
63028
63376
|
var _a;
|
63029
63377
|
(_a = init2.logger) == null ? void 0 : _a.debug("@aws-sdk/credential-provider-web-identity", "fromWebToken");
|
63030
|
-
const { roleArn, roleSessionName, webIdentityToken, providerId, policyArns, policy:
|
63378
|
+
const { roleArn, roleSessionName, webIdentityToken, providerId, policyArns, policy: policy4, durationSeconds } = init2;
|
63031
63379
|
let { roleAssumerWithWebIdentity } = init2;
|
63032
63380
|
if (!roleAssumerWithWebIdentity) {
|
63033
63381
|
const { getDefaultRoleAssumerWithWebIdentity } = await Promise.resolve().then(() => __importStar2(require_dist_cjs50()));
|
@@ -63043,7 +63391,7 @@ var require_fromWebToken = __commonJS({
|
|
63043
63391
|
WebIdentityToken: webIdentityToken,
|
63044
63392
|
ProviderId: providerId,
|
63045
63393
|
PolicyArns: policyArns,
|
63046
|
-
Policy:
|
63394
|
+
Policy: policy4,
|
63047
63395
|
DurationSeconds: durationSeconds
|
63048
63396
|
});
|
63049
63397
|
};
|
@@ -64927,7 +65275,7 @@ var init_connections = __esm({
|
|
64927
65275
|
}
|
64928
65276
|
if (driver2 === "pglite") {
|
64929
65277
|
assertPackages("@electric-sql/pglite");
|
64930
|
-
const { PGlite } = await import("@electric-sql/pglite");
|
65278
|
+
const { PGlite, types: types3 } = await import("@electric-sql/pglite");
|
64931
65279
|
const { drizzle } = await import("drizzle-orm/pglite");
|
64932
65280
|
const { migrate: migrate2 } = await import("drizzle-orm/pglite/migrator");
|
64933
65281
|
const pglite = new PGlite(normalisePGliteUrl(credentials2.url));
|
@@ -64936,19 +65284,24 @@ var init_connections = __esm({
|
|
64936
65284
|
const migrateFn = async (config) => {
|
64937
65285
|
return migrate2(drzl, config);
|
64938
65286
|
};
|
65287
|
+
const parsers = {
|
65288
|
+
[types3.TIMESTAMP]: (value) => value,
|
65289
|
+
[types3.TIMESTAMPTZ]: (value) => value,
|
65290
|
+
[types3.INTERVAL]: (value) => value,
|
65291
|
+
[types3.DATE]: (value) => value
|
65292
|
+
};
|
64939
65293
|
const query = async (sql, params = []) => {
|
64940
|
-
const result = await pglite.query(sql, params
|
65294
|
+
const result = await pglite.query(sql, params, {
|
65295
|
+
parsers
|
65296
|
+
});
|
64941
65297
|
return result.rows;
|
64942
65298
|
};
|
64943
65299
|
const proxy = async (params) => {
|
64944
65300
|
const preparedParams = preparePGliteParams(params.params);
|
64945
|
-
|
64946
|
-
|
64947
|
-
|
64948
|
-
|
64949
|
-
return result2.rows;
|
64950
|
-
}
|
64951
|
-
const result = await pglite.query(params.sql, preparedParams);
|
65301
|
+
const result = await pglite.query(params.sql, preparedParams, {
|
65302
|
+
rowMode: params.mode,
|
65303
|
+
parsers
|
65304
|
+
});
|
64952
65305
|
return result.rows;
|
64953
65306
|
};
|
64954
65307
|
return { query, proxy, migrate: migrateFn };
|
@@ -64957,24 +65310,47 @@ var init_connections = __esm({
|
|
64957
65310
|
}
|
64958
65311
|
if (await checkPackage("pg")) {
|
64959
65312
|
console.log(withStyle.info(`Using 'pg' driver for database querying`));
|
64960
|
-
const pg = await import("pg");
|
65313
|
+
const { default: pg } = await import("pg");
|
64961
65314
|
const { drizzle } = await import("drizzle-orm/node-postgres");
|
64962
65315
|
const { migrate: migrate2 } = await import("drizzle-orm/node-postgres/migrator");
|
64963
65316
|
const ssl = "ssl" in credentials2 ? credentials2.ssl === "prefer" || credentials2.ssl === "require" || credentials2.ssl === "allow" ? { rejectUnauthorized: false } : credentials2.ssl === "verify-full" ? {} : credentials2.ssl : {};
|
64964
|
-
const
|
65317
|
+
const types3 = {
|
65318
|
+
// @ts-ignore
|
65319
|
+
getTypeParser: (typeId, format) => {
|
65320
|
+
if (typeId === pg.types.builtins.TIMESTAMPTZ) {
|
65321
|
+
return (val2) => val2;
|
65322
|
+
}
|
65323
|
+
if (typeId === pg.types.builtins.TIMESTAMP) {
|
65324
|
+
return (val2) => val2;
|
65325
|
+
}
|
65326
|
+
if (typeId === pg.types.builtins.DATE) {
|
65327
|
+
return (val2) => val2;
|
65328
|
+
}
|
65329
|
+
if (typeId === pg.types.builtins.INTERVAL) {
|
65330
|
+
return (val2) => val2;
|
65331
|
+
}
|
65332
|
+
return pg.types.getTypeParser(typeId, format);
|
65333
|
+
}
|
65334
|
+
};
|
65335
|
+
const client = "url" in credentials2 ? new pg.Pool({ connectionString: credentials2.url, max: 1 }) : new pg.Pool({ ...credentials2, ssl, max: 1 });
|
64965
65336
|
const db = drizzle(client);
|
64966
65337
|
const migrateFn = async (config) => {
|
64967
65338
|
return migrate2(db, config);
|
64968
65339
|
};
|
64969
65340
|
const query = async (sql, params) => {
|
64970
|
-
const result = await client.query(
|
65341
|
+
const result = await client.query({
|
65342
|
+
text: sql,
|
65343
|
+
values: params ?? [],
|
65344
|
+
types: types3
|
65345
|
+
});
|
64971
65346
|
return result.rows;
|
64972
65347
|
};
|
64973
65348
|
const proxy = async (params) => {
|
64974
65349
|
const result = await client.query({
|
64975
65350
|
text: params.sql,
|
64976
65351
|
values: params.params,
|
64977
|
-
...params.mode === "array" && { rowMode: "array" }
|
65352
|
+
...params.mode === "array" && { rowMode: "array" },
|
65353
|
+
types: types3
|
64978
65354
|
});
|
64979
65355
|
return result.rows;
|
64980
65356
|
};
|
@@ -64988,6 +65364,13 @@ var init_connections = __esm({
|
|
64988
65364
|
const { drizzle } = await import("drizzle-orm/postgres-js");
|
64989
65365
|
const { migrate: migrate2 } = await import("drizzle-orm/postgres-js/migrator");
|
64990
65366
|
const client = "url" in credentials2 ? postgres.default(credentials2.url, { max: 1 }) : postgres.default({ ...credentials2, max: 1 });
|
65367
|
+
const transparentParser = (val2) => val2;
|
65368
|
+
for (const type of ["1184", "1082", "1083", "1114"]) {
|
65369
|
+
client.options.parsers[type] = transparentParser;
|
65370
|
+
client.options.serializers[type] = transparentParser;
|
65371
|
+
}
|
65372
|
+
client.options.serializers["114"] = transparentParser;
|
65373
|
+
client.options.serializers["3802"] = transparentParser;
|
64991
65374
|
const db = drizzle(client);
|
64992
65375
|
const migrateFn = async (config) => {
|
64993
65376
|
return migrate2(db, config);
|
@@ -65013,10 +65396,28 @@ var init_connections = __esm({
|
|
65013
65396
|
"'@vercel/postgres' can only connect to remote Neon/Vercel Postgres/Supabase instances through a websocket"
|
65014
65397
|
)
|
65015
65398
|
);
|
65016
|
-
const { VercelPool } = await import("@vercel/postgres");
|
65399
|
+
const { VercelPool, types: pgTypes } = await import("@vercel/postgres");
|
65017
65400
|
const { drizzle } = await import("drizzle-orm/vercel-postgres");
|
65018
65401
|
const { migrate: migrate2 } = await import("drizzle-orm/vercel-postgres/migrator");
|
65019
65402
|
const ssl = "ssl" in credentials2 ? credentials2.ssl === "prefer" || credentials2.ssl === "require" || credentials2.ssl === "allow" ? { rejectUnauthorized: false } : credentials2.ssl === "verify-full" ? {} : credentials2.ssl : {};
|
65403
|
+
const types3 = {
|
65404
|
+
// @ts-ignore
|
65405
|
+
getTypeParser: (typeId, format) => {
|
65406
|
+
if (typeId === pgTypes.builtins.TIMESTAMPTZ) {
|
65407
|
+
return (val2) => val2;
|
65408
|
+
}
|
65409
|
+
if (typeId === pgTypes.builtins.TIMESTAMP) {
|
65410
|
+
return (val2) => val2;
|
65411
|
+
}
|
65412
|
+
if (typeId === pgTypes.builtins.DATE) {
|
65413
|
+
return (val2) => val2;
|
65414
|
+
}
|
65415
|
+
if (typeId === pgTypes.builtins.INTERVAL) {
|
65416
|
+
return (val2) => val2;
|
65417
|
+
}
|
65418
|
+
return pgTypes.getTypeParser(typeId, format);
|
65419
|
+
}
|
65420
|
+
};
|
65020
65421
|
const client = "url" in credentials2 ? new VercelPool({ connectionString: credentials2.url }) : new VercelPool({ ...credentials2, ssl });
|
65021
65422
|
await client.connect();
|
65022
65423
|
const db = drizzle(client);
|
@@ -65024,14 +65425,19 @@ var init_connections = __esm({
|
|
65024
65425
|
return migrate2(db, config);
|
65025
65426
|
};
|
65026
65427
|
const query = async (sql, params) => {
|
65027
|
-
const result = await client.query(
|
65428
|
+
const result = await client.query({
|
65429
|
+
text: sql,
|
65430
|
+
values: params ?? [],
|
65431
|
+
types: types3
|
65432
|
+
});
|
65028
65433
|
return result.rows;
|
65029
65434
|
};
|
65030
65435
|
const proxy = async (params) => {
|
65031
65436
|
const result = await client.query({
|
65032
65437
|
text: params.sql,
|
65033
65438
|
values: params.params,
|
65034
|
-
...params.mode === "array" && { rowMode: "array" }
|
65439
|
+
...params.mode === "array" && { rowMode: "array" },
|
65440
|
+
types: types3
|
65035
65441
|
});
|
65036
65442
|
return result.rows;
|
65037
65443
|
};
|
@@ -65048,10 +65454,28 @@ var init_connections = __esm({
|
|
65048
65454
|
"'@neondatabase/serverless' can only connect to remote Neon/Vercel Postgres/Supabase instances through a websocket"
|
65049
65455
|
)
|
65050
65456
|
);
|
65051
|
-
const { Pool, neonConfig } = await import("@neondatabase/serverless");
|
65457
|
+
const { Pool, neonConfig, types: pgTypes } = await import("@neondatabase/serverless");
|
65052
65458
|
const { drizzle } = await import("drizzle-orm/neon-serverless");
|
65053
65459
|
const { migrate: migrate2 } = await import("drizzle-orm/neon-serverless/migrator");
|
65054
65460
|
const ssl = "ssl" in credentials2 ? credentials2.ssl === "prefer" || credentials2.ssl === "require" || credentials2.ssl === "allow" ? { rejectUnauthorized: false } : credentials2.ssl === "verify-full" ? {} : credentials2.ssl : {};
|
65461
|
+
const types3 = {
|
65462
|
+
// @ts-ignore
|
65463
|
+
getTypeParser: (typeId, format) => {
|
65464
|
+
if (typeId === pgTypes.builtins.TIMESTAMPTZ) {
|
65465
|
+
return (val2) => val2;
|
65466
|
+
}
|
65467
|
+
if (typeId === pgTypes.builtins.TIMESTAMP) {
|
65468
|
+
return (val2) => val2;
|
65469
|
+
}
|
65470
|
+
if (typeId === pgTypes.builtins.DATE) {
|
65471
|
+
return (val2) => val2;
|
65472
|
+
}
|
65473
|
+
if (typeId === pgTypes.builtins.INTERVAL) {
|
65474
|
+
return (val2) => val2;
|
65475
|
+
}
|
65476
|
+
return pgTypes.getTypeParser(typeId, format);
|
65477
|
+
}
|
65478
|
+
};
|
65055
65479
|
const client = "url" in credentials2 ? new Pool({ connectionString: credentials2.url, max: 1 }) : new Pool({ ...credentials2, max: 1, ssl });
|
65056
65480
|
neonConfig.webSocketConstructor = wrapper_default;
|
65057
65481
|
const db = drizzle(client);
|
@@ -65059,14 +65483,19 @@ var init_connections = __esm({
|
|
65059
65483
|
return migrate2(db, config);
|
65060
65484
|
};
|
65061
65485
|
const query = async (sql, params) => {
|
65062
|
-
const result = await client.query(
|
65486
|
+
const result = await client.query({
|
65487
|
+
text: sql,
|
65488
|
+
values: params ?? [],
|
65489
|
+
types: types3
|
65490
|
+
});
|
65063
65491
|
return result.rows;
|
65064
65492
|
};
|
65065
65493
|
const proxy = async (params) => {
|
65066
65494
|
const result = await client.query({
|
65067
65495
|
text: params.sql,
|
65068
65496
|
values: params.params,
|
65069
|
-
...params.mode === "array" && { rowMode: "array" }
|
65497
|
+
...params.mode === "array" && { rowMode: "array" },
|
65498
|
+
types: types3
|
65070
65499
|
});
|
65071
65500
|
return result.rows;
|
65072
65501
|
};
|
@@ -65108,16 +65537,27 @@ var init_connections = __esm({
|
|
65108
65537
|
const migrateFn = async (config) => {
|
65109
65538
|
return migrate2(db, config);
|
65110
65539
|
};
|
65540
|
+
const typeCast = (field, next) => {
|
65541
|
+
if (field.type === "TIMESTAMP" || field.type === "DATETIME" || field.type === "DATE") {
|
65542
|
+
return field.string();
|
65543
|
+
}
|
65544
|
+
return next();
|
65545
|
+
};
|
65111
65546
|
await connection.connect();
|
65112
65547
|
const query = async (sql, params) => {
|
65113
|
-
const res = await connection.execute(
|
65548
|
+
const res = await connection.execute({
|
65549
|
+
sql,
|
65550
|
+
values: params,
|
65551
|
+
typeCast
|
65552
|
+
});
|
65114
65553
|
return res[0];
|
65115
65554
|
};
|
65116
65555
|
const proxy = async (params) => {
|
65117
65556
|
const result2 = await connection.query({
|
65118
65557
|
sql: params.sql,
|
65119
65558
|
values: params.params,
|
65120
|
-
rowsAsArray: params.mode === "array"
|
65559
|
+
rowsAsArray: params.mode === "array",
|
65560
|
+
typeCast
|
65121
65561
|
});
|
65122
65562
|
return result2[0];
|
65123
65563
|
};
|
@@ -65129,10 +65569,10 @@ var init_connections = __esm({
|
|
65129
65569
|
};
|
65130
65570
|
}
|
65131
65571
|
if (await checkPackage("@planetscale/database")) {
|
65132
|
-
const {
|
65572
|
+
const { Client } = await import("@planetscale/database");
|
65133
65573
|
const { drizzle } = await import("drizzle-orm/planetscale-serverless");
|
65134
65574
|
const { migrate: migrate2 } = await import("drizzle-orm/planetscale-serverless/migrator");
|
65135
|
-
const connection =
|
65575
|
+
const connection = new Client(result);
|
65136
65576
|
const db = drizzle(connection);
|
65137
65577
|
const migrateFn = async (config) => {
|
65138
65578
|
return migrate2(db, config);
|
@@ -65380,19 +65820,20 @@ __export(studio_exports, {
|
|
65380
65820
|
prepareSQLiteSchema: () => prepareSQLiteSchema,
|
65381
65821
|
prepareServer: () => prepareServer
|
65382
65822
|
});
|
65383
|
-
var import_crypto8,
|
65823
|
+
var import_crypto8, import_drizzle_orm7, import_mysql_core3, import_pg_core3, import_sqlite_core3, import_fs10, import_node_https2, preparePgSchema, prepareMySqlSchema, prepareSQLiteSchema, getCustomDefaults, drizzleForPostgres, drizzleForMySQL, drizzleForSQLite, drizzleForLibSQL, extractRelations, init, proxySchema, defaultsSchema, schema4, jsonStringify, prepareServer;
|
65384
65824
|
var init_studio2 = __esm({
|
65385
65825
|
"src/serializer/studio.ts"() {
|
65386
65826
|
"use strict";
|
65387
65827
|
init_dist();
|
65388
65828
|
init_esm();
|
65389
65829
|
import_crypto8 = require("crypto");
|
65390
|
-
|
65391
|
-
|
65392
|
-
|
65830
|
+
import_drizzle_orm7 = require("drizzle-orm");
|
65831
|
+
import_mysql_core3 = require("drizzle-orm/mysql-core");
|
65832
|
+
import_pg_core3 = require("drizzle-orm/pg-core");
|
65393
65833
|
import_sqlite_core3 = require("drizzle-orm/sqlite-core");
|
65394
65834
|
import_fs10 = __toESM(require("fs"));
|
65395
65835
|
init_dist2();
|
65836
|
+
init_compress();
|
65396
65837
|
init_cors();
|
65397
65838
|
import_node_https2 = require("node:https");
|
65398
65839
|
init_global();
|
@@ -65415,12 +65856,12 @@ var init_studio2 = __esm({
|
|
65415
65856
|
const i0 = require(`${it}`);
|
65416
65857
|
const i0values = Object.entries(i0);
|
65417
65858
|
i0values.forEach(([k, t2]) => {
|
65418
|
-
if ((0,
|
65419
|
-
const schema5 = (0,
|
65859
|
+
if ((0, import_drizzle_orm7.is)(t2, import_pg_core3.PgTable)) {
|
65860
|
+
const schema5 = (0, import_pg_core3.getTableConfig)(t2).schema || "public";
|
65420
65861
|
pgSchema2[schema5] = pgSchema2[schema5] || {};
|
65421
65862
|
pgSchema2[schema5][k] = t2;
|
65422
65863
|
}
|
65423
|
-
if ((0,
|
65864
|
+
if ((0, import_drizzle_orm7.is)(t2, import_drizzle_orm7.Relations)) {
|
65424
65865
|
relations4[k] = t2;
|
65425
65866
|
}
|
65426
65867
|
});
|
@@ -65445,11 +65886,11 @@ var init_studio2 = __esm({
|
|
65445
65886
|
const i0 = require(`${it}`);
|
65446
65887
|
const i0values = Object.entries(i0);
|
65447
65888
|
i0values.forEach(([k, t2]) => {
|
65448
|
-
if ((0,
|
65449
|
-
const schema5 = (0,
|
65889
|
+
if ((0, import_drizzle_orm7.is)(t2, import_mysql_core3.MySqlTable)) {
|
65890
|
+
const schema5 = (0, import_mysql_core3.getTableConfig)(t2).schema || "public";
|
65450
65891
|
mysqlSchema3[schema5][k] = t2;
|
65451
65892
|
}
|
65452
|
-
if ((0,
|
65893
|
+
if ((0, import_drizzle_orm7.is)(t2, import_drizzle_orm7.Relations)) {
|
65453
65894
|
relations4[k] = t2;
|
65454
65895
|
}
|
65455
65896
|
});
|
@@ -65474,11 +65915,11 @@ var init_studio2 = __esm({
|
|
65474
65915
|
const i0 = require(`${it}`);
|
65475
65916
|
const i0values = Object.entries(i0);
|
65476
65917
|
i0values.forEach(([k, t2]) => {
|
65477
|
-
if ((0,
|
65918
|
+
if ((0, import_drizzle_orm7.is)(t2, import_sqlite_core3.SQLiteTable)) {
|
65478
65919
|
const schema5 = "public";
|
65479
65920
|
sqliteSchema2[schema5][k] = t2;
|
65480
65921
|
}
|
65481
|
-
if ((0,
|
65922
|
+
if ((0, import_drizzle_orm7.is)(t2, import_drizzle_orm7.Relations)) {
|
65482
65923
|
relations4[k] = t2;
|
65483
65924
|
}
|
65484
65925
|
});
|
@@ -65491,10 +65932,10 @@ var init_studio2 = __esm({
|
|
65491
65932
|
Object.entries(schema5).map(([schema6, tables]) => {
|
65492
65933
|
Object.entries(tables).map(([, table4]) => {
|
65493
65934
|
let tableConfig;
|
65494
|
-
if ((0,
|
65495
|
-
tableConfig = (0,
|
65496
|
-
} else if ((0,
|
65497
|
-
tableConfig = (0,
|
65935
|
+
if ((0, import_drizzle_orm7.is)(table4, import_pg_core3.PgTable)) {
|
65936
|
+
tableConfig = (0, import_pg_core3.getTableConfig)(table4);
|
65937
|
+
} else if ((0, import_drizzle_orm7.is)(table4, import_mysql_core3.MySqlTable)) {
|
65938
|
+
tableConfig = (0, import_mysql_core3.getTableConfig)(table4);
|
65498
65939
|
} else {
|
65499
65940
|
tableConfig = (0, import_sqlite_core3.getTableConfig)(table4);
|
65500
65941
|
}
|
@@ -65611,7 +66052,7 @@ var init_studio2 = __esm({
|
|
65611
66052
|
extractRelations = (tablesConfig) => {
|
65612
66053
|
const relations4 = Object.values(tablesConfig.tables).map(
|
65613
66054
|
(it) => Object.entries(it.relations).map(([name, relation]) => {
|
65614
|
-
const normalized = (0,
|
66055
|
+
const normalized = (0, import_drizzle_orm7.normalizeRelation)(
|
65615
66056
|
tablesConfig.tables,
|
65616
66057
|
tablesConfig.tableNamesMap,
|
65617
66058
|
relation
|
@@ -65622,19 +66063,19 @@ var init_studio2 = __esm({
|
|
65622
66063
|
const fields = normalized.fields.map((it2) => it2.name).flat();
|
65623
66064
|
const refColumns = normalized.references.map((it2) => it2.name).flat();
|
65624
66065
|
let refSchema;
|
65625
|
-
if ((0,
|
65626
|
-
refSchema = (0,
|
65627
|
-
} else if ((0,
|
65628
|
-
refSchema = (0,
|
65629
|
-
} else if ((0,
|
66066
|
+
if ((0, import_drizzle_orm7.is)(refTable, import_pg_core3.PgTable)) {
|
66067
|
+
refSchema = (0, import_pg_core3.getTableConfig)(refTable).schema;
|
66068
|
+
} else if ((0, import_drizzle_orm7.is)(refTable, import_mysql_core3.MySqlTable)) {
|
66069
|
+
refSchema = (0, import_mysql_core3.getTableConfig)(refTable).schema;
|
66070
|
+
} else if ((0, import_drizzle_orm7.is)(refTable, import_sqlite_core3.SQLiteTable)) {
|
65630
66071
|
refSchema = void 0;
|
65631
66072
|
} else {
|
65632
66073
|
throw new Error("unsupported dialect");
|
65633
66074
|
}
|
65634
66075
|
let type;
|
65635
|
-
if ((0,
|
66076
|
+
if ((0, import_drizzle_orm7.is)(rel, import_drizzle_orm7.One)) {
|
65636
66077
|
type = "one";
|
65637
|
-
} else if ((0,
|
66078
|
+
} else if ((0, import_drizzle_orm7.is)(rel, import_drizzle_orm7.Many)) {
|
65638
66079
|
type = "many";
|
65639
66080
|
} else {
|
65640
66081
|
throw new Error("unsupported relation type");
|
@@ -65713,11 +66154,12 @@ var init_studio2 = __esm({
|
|
65713
66154
|
schemaFiles
|
65714
66155
|
}, app) => {
|
65715
66156
|
app = app !== void 0 ? app : new Hono2();
|
65716
|
-
app.use(
|
66157
|
+
app.use(compress());
|
65717
66158
|
app.use(async (ctx, next) => {
|
65718
66159
|
await next();
|
65719
66160
|
ctx.header("Access-Control-Allow-Private-Network", "true");
|
65720
66161
|
});
|
66162
|
+
app.use(cors());
|
65721
66163
|
app.onError((err2, ctx) => {
|
65722
66164
|
console.error(err2);
|
65723
66165
|
return ctx.json({
|
@@ -65738,9 +66180,9 @@ var init_studio2 = __esm({
|
|
65738
66180
|
),
|
65739
66181
|
...relations4
|
65740
66182
|
};
|
65741
|
-
const relationsConfig = (0,
|
66183
|
+
const relationsConfig = (0, import_drizzle_orm7.extractTablesRelationalConfig)(
|
65742
66184
|
relationalSchema,
|
65743
|
-
|
66185
|
+
import_drizzle_orm7.createTableRelationsHelpers
|
65744
66186
|
);
|
65745
66187
|
app.post("/", zValidator("json", schema4), async (c) => {
|
65746
66188
|
const body = c.req.valid("json");
|
@@ -81965,7 +82407,7 @@ var init_pgIntrospect = __esm({
|
|
81965
82407
|
init_global();
|
81966
82408
|
init_pgSerializer();
|
81967
82409
|
init_views();
|
81968
|
-
pgPushIntrospect = async (db, filters, schemaFilters, entities
|
82410
|
+
pgPushIntrospect = async (db, filters, schemaFilters, entities) => {
|
81969
82411
|
const matchers = filters.map((it) => {
|
81970
82412
|
return new Minimatch(it);
|
81971
82413
|
});
|
@@ -82004,11 +82446,11 @@ var init_pgIntrospect = __esm({
|
|
82004
82446
|
});
|
82005
82447
|
|
82006
82448
|
// src/introspect-sqlite.ts
|
82007
|
-
var
|
82449
|
+
var import_casing2, sqliteImportsList, indexName3, objToStatement2, relations, escapeColumnKey, withCasing, dbColumnName, schemaToTypeScript, isCyclic, isSelf, mapColumnDefault, column4, createTableColumns, createTableIndexes, createTableUniques, createTableChecks, createTablePKs, createTableFKs;
|
82008
82450
|
var init_introspect_sqlite = __esm({
|
82009
82451
|
"src/introspect-sqlite.ts"() {
|
82010
82452
|
"use strict";
|
82011
|
-
|
82453
|
+
import_casing2 = require("drizzle-orm/casing");
|
82012
82454
|
init_utils3();
|
82013
82455
|
init_global();
|
82014
82456
|
sqliteImportsList = /* @__PURE__ */ new Set([
|
@@ -82053,7 +82495,7 @@ var init_introspect_sqlite = __esm({
|
|
82053
82495
|
return "";
|
82054
82496
|
}
|
82055
82497
|
if (casing2 === "camel") {
|
82056
|
-
return (0,
|
82498
|
+
return (0, import_casing2.toCamelCase)(name) === name ? "" : withMode ? `"${name}", ` : `"${name}"`;
|
82057
82499
|
}
|
82058
82500
|
assertUnreachable(casing2);
|
82059
82501
|
};
|
@@ -83183,11 +83625,11 @@ var require_pluralize = __commonJS({
|
|
83183
83625
|
});
|
83184
83626
|
|
83185
83627
|
// src/introspect-mysql.ts
|
83186
|
-
var
|
83628
|
+
var import_casing3, mysqlImportsList, objToStatement22, timeConfig, binaryConfig, importsPatch, relations2, escapeColumnKey2, prepareCasing, dbColumnName2, schemaToTypeScript2, isCyclic2, isSelf2, mapColumnDefault2, mapColumnDefaultForJson, column5, createTableColumns2, createTableIndexes2, createTableUniques2, createTableChecks2, createTablePKs2, createTableFKs2;
|
83187
83629
|
var init_introspect_mysql = __esm({
|
83188
83630
|
"src/introspect-mysql.ts"() {
|
83189
83631
|
"use strict";
|
83190
|
-
|
83632
|
+
import_casing3 = require("drizzle-orm/casing");
|
83191
83633
|
init_utils3();
|
83192
83634
|
init_global();
|
83193
83635
|
init_mysqlSerializer();
|
@@ -83276,7 +83718,7 @@ var init_introspect_mysql = __esm({
|
|
83276
83718
|
return "";
|
83277
83719
|
}
|
83278
83720
|
if (casing2 === "camel") {
|
83279
|
-
return (0,
|
83721
|
+
return (0, import_casing3.toCamelCase)(name) === name ? "" : withMode ? `"${name}", ` : `"${name}"`;
|
83280
83722
|
}
|
83281
83723
|
assertUnreachable(casing2);
|
83282
83724
|
};
|
@@ -83845,14 +84287,14 @@ function generateIdentityParams(identity) {
|
|
83845
84287
|
}
|
83846
84288
|
return `.generatedByDefaultAsIdentity(${paramsObj})`;
|
83847
84289
|
}
|
83848
|
-
var
|
84290
|
+
var import_drizzle_orm8, import_relations, import_casing4, pgImportsList, timeConfig2, possibleIntervals, intervalStrToObj, intervalConfig, mapColumnDefault3, importsPatch2, relations3, escapeColumnKey3, withCasing2, dbColumnName3, paramNameFor, schemaToTypeScript3, isCyclic3, isSelf3, buildArrayDefault, mapDefault, column6, dimensionsInArray, createTableColumns3, createTableIndexes3, createTablePKs3, createTablePolicies, createTableUniques3, createTableChecks3, createTableFKs3;
|
83849
84291
|
var init_introspect_pg = __esm({
|
83850
84292
|
"src/introspect-pg.ts"() {
|
83851
84293
|
"use strict";
|
83852
|
-
|
84294
|
+
import_drizzle_orm8 = require("drizzle-orm");
|
83853
84295
|
import_relations = require("drizzle-orm/relations");
|
83854
84296
|
init_utils3();
|
83855
|
-
|
84297
|
+
import_casing4 = require("drizzle-orm/casing");
|
83856
84298
|
init_vector();
|
83857
84299
|
init_global();
|
83858
84300
|
init_pgSerializer();
|
@@ -83983,7 +84425,7 @@ var init_introspect_pg = __esm({
|
|
83983
84425
|
return "";
|
83984
84426
|
}
|
83985
84427
|
if (casing2 === "camel") {
|
83986
|
-
return (0,
|
84428
|
+
return (0, import_casing4.toCamelCase)(name) === name ? "" : withMode ? `"${name}", ` : `"${name}"`;
|
83987
84429
|
}
|
83988
84430
|
assertUnreachable(casing2);
|
83989
84431
|
};
|
@@ -84775,6 +85217,8 @@ var init_introspect = __esm({
|
|
84775
85217
|
enumsResolver,
|
84776
85218
|
sequencesResolver,
|
84777
85219
|
policyResolver,
|
85220
|
+
indPolicyResolver,
|
85221
|
+
roleResolver,
|
84778
85222
|
tablesResolver,
|
84779
85223
|
columnsResolver,
|
84780
85224
|
viewsResolver,
|
@@ -85165,7 +85609,7 @@ ${fields.join("\n")}
|
|
85165
85609
|
}
|
85166
85610
|
});
|
85167
85611
|
|
85168
|
-
// ../node_modules/.pnpm/@drizzle-team+brocli@0.10.
|
85612
|
+
// ../node_modules/.pnpm/@drizzle-team+brocli@0.10.2/node_modules/@drizzle-team/brocli/index.js
|
85169
85613
|
var __create2 = Object.create;
|
85170
85614
|
var __defProp2 = Object.defineProperty;
|
85171
85615
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
@@ -85669,32 +86113,32 @@ var defaultEventHandler = async (event) => {
|
|
85669
86113
|
var _a;
|
85670
86114
|
switch (event.type) {
|
85671
86115
|
case "command_help": {
|
85672
|
-
const
|
85673
|
-
const commandName = getCommandNameWithParents(
|
86116
|
+
const command3 = event.command;
|
86117
|
+
const commandName = getCommandNameWithParents(command3);
|
85674
86118
|
const cliName = event.name;
|
85675
|
-
const desc =
|
85676
|
-
const subs = (_a =
|
86119
|
+
const desc = command3.desc ?? command3.shortDesc;
|
86120
|
+
const subs = (_a = command3.subcommands) == null ? void 0 : _a.filter((s2) => !s2.hidden);
|
85677
86121
|
const subcommands = subs && subs.length ? subs : void 0;
|
85678
86122
|
if (desc !== void 0) {
|
85679
86123
|
console.log(`
|
85680
86124
|
${desc}`);
|
85681
86125
|
}
|
85682
|
-
const opts = Object.values(
|
86126
|
+
const opts = Object.values(command3.options ?? {}).filter(
|
85683
86127
|
(opt) => !opt.config.isHidden
|
85684
86128
|
);
|
85685
86129
|
const positionals = opts.filter((opt) => opt.config.type === "positional");
|
85686
86130
|
const options = opts.filter((opt) => opt.config.type !== "positional");
|
85687
86131
|
console.log("\nUsage:");
|
85688
|
-
if (
|
86132
|
+
if (command3.handler) {
|
85689
86133
|
console.log(
|
85690
86134
|
` ${cliName ? cliName + " " : ""}${commandName}${positionals.length ? " " + positionals.map(({ config: p2 }) => getOptionTypeText(p2)).join(" ") : ""} [flags]`
|
85691
86135
|
);
|
85692
86136
|
} else
|
85693
86137
|
console.log(` ${cliName ? cliName + " " : ""}${commandName} [command]`);
|
85694
|
-
if (
|
86138
|
+
if (command3.aliases) {
|
85695
86139
|
console.log(`
|
85696
86140
|
Aliases:`);
|
85697
|
-
console.log(` ${[
|
86141
|
+
console.log(` ${[command3.name, ...command3.aliases].join(", ")}`);
|
85698
86142
|
}
|
85699
86143
|
if (subcommands) {
|
85700
86144
|
console.log("\nAvailable Commands:");
|
@@ -85774,8 +86218,8 @@ Use "${cliName ? cliName + " " : ""}${commandName} [command] --help" for more in
|
|
85774
86218
|
const maxLength = commands.reduce((p2, e2) => e2.name.length > p2 ? e2.name.length : p2, 0);
|
85775
86219
|
const paddedLength = maxLength + padding;
|
85776
86220
|
const data = commands.map(
|
85777
|
-
(
|
85778
|
-
const desc2 =
|
86221
|
+
(c) => ` ${c.name.padEnd(paddedLength)}${(() => {
|
86222
|
+
const desc2 = c.shortDesc ?? c.desc;
|
85779
86223
|
if (!(desc2 == null ? void 0 : desc2.length))
|
85780
86224
|
return "";
|
85781
86225
|
const split = desc2.split("\n");
|
@@ -85867,8 +86311,8 @@ Type '${cName} --help' to get the help on command.`;
|
|
85867
86311
|
return true;
|
85868
86312
|
}
|
85869
86313
|
case "missing_args_error": {
|
85870
|
-
const missingOpts = event
|
85871
|
-
msg = `Command '${
|
86314
|
+
const { missing: missingOpts, command: command3 } = event;
|
86315
|
+
msg = `Command '${command3.name}' is missing following required options: ${missingOpts.map((opt) => {
|
85872
86316
|
const name = opt.shift();
|
85873
86317
|
const aliases = opt;
|
85874
86318
|
if (aliases.length)
|
@@ -85878,8 +86322,8 @@ Type '${cName} --help' to get the help on command.`;
|
|
85878
86322
|
break;
|
85879
86323
|
}
|
85880
86324
|
case "unrecognized_args_error": {
|
85881
|
-
const { command:
|
85882
|
-
msg = `Unrecognized options for command '${
|
86325
|
+
const { command: command3, unrecognized } = event;
|
86326
|
+
msg = `Unrecognized options for command '${command3.name}': ${unrecognized.join(", ")}`;
|
85883
86327
|
break;
|
85884
86328
|
}
|
85885
86329
|
case "unknown_error": {
|
@@ -85976,21 +86420,21 @@ var assignParent = (parent, subcommands) => subcommands.forEach((e2) => {
|
|
85976
86420
|
if (e2.subcommands)
|
85977
86421
|
assignParent(e2, e2.subcommands);
|
85978
86422
|
});
|
85979
|
-
var
|
86423
|
+
var command2 = (command3) => {
|
85980
86424
|
var _a, _b, _c;
|
85981
|
-
const allNames =
|
85982
|
-
const cmd = (0, import_clone.default)(
|
85983
|
-
if (
|
86425
|
+
const allNames = command3.aliases ? [command3.name, ...command3.aliases] : [command3.name];
|
86426
|
+
const cmd = (0, import_clone.default)(command3);
|
86427
|
+
if (command3.subcommands && command3.options && Object.values(command3.options).find((opt) => opt._.config.type === "positional")) {
|
85984
86428
|
throw new BroCliError(
|
85985
86429
|
`Can't define command '${cmd.name}' - command can't have subcommands and positional args at the same time!`
|
85986
86430
|
);
|
85987
86431
|
}
|
85988
|
-
if (!
|
86432
|
+
if (!command3.handler && !command3.subcommands) {
|
85989
86433
|
throw new BroCliError(
|
85990
86434
|
`Can't define command '${cmd.name}' - command without subcommands must have a handler present!`
|
85991
86435
|
);
|
85992
86436
|
}
|
85993
|
-
const processedOptions =
|
86437
|
+
const processedOptions = command3.options ? validateOptions(command3.options) : void 0;
|
85994
86438
|
cmd.options = processedOptions;
|
85995
86439
|
cmd.name = cmd.name ?? ((_a = cmd.aliases) == null ? void 0 : _a.shift());
|
85996
86440
|
if (!cmd.name)
|
@@ -86027,33 +86471,33 @@ var command = (command2) => {
|
|
86027
86471
|
};
|
86028
86472
|
var getCommandInner = (commands, candidates, args, cliName, cliDescription) => {
|
86029
86473
|
const { data: arg, originalIndex: index4 } = candidates.shift();
|
86030
|
-
const
|
86474
|
+
const command3 = commands.find((c) => {
|
86031
86475
|
const names = c.aliases ? [c.name, ...c.aliases] : [c.name];
|
86032
86476
|
const res = names.find((name) => name === arg);
|
86033
86477
|
return res;
|
86034
86478
|
});
|
86035
|
-
if (!
|
86479
|
+
if (!command3) {
|
86036
86480
|
return {
|
86037
|
-
command:
|
86481
|
+
command: command3,
|
86038
86482
|
args
|
86039
86483
|
};
|
86040
86484
|
}
|
86041
86485
|
const newArgs = removeByIndex(args, index4);
|
86042
|
-
if (!candidates.length || !
|
86486
|
+
if (!candidates.length || !command3.subcommands) {
|
86043
86487
|
return {
|
86044
|
-
command:
|
86488
|
+
command: command3,
|
86045
86489
|
args: newArgs
|
86046
86490
|
};
|
86047
86491
|
}
|
86048
86492
|
const newCandidates = candidates.map((c) => ({ data: c.data, originalIndex: c.originalIndex - 1 }));
|
86049
|
-
const subcommand = getCommandInner(
|
86493
|
+
const subcommand = getCommandInner(command3.subcommands, newCandidates, newArgs, cliName, cliDescription);
|
86050
86494
|
if (!subcommand.command) {
|
86051
86495
|
throw new BroCliError(void 0, {
|
86052
86496
|
type: "error",
|
86053
86497
|
violation: "unknown_subcommand_error",
|
86054
86498
|
name: cliName,
|
86055
86499
|
description: cliDescription,
|
86056
|
-
command:
|
86500
|
+
command: command3,
|
86057
86501
|
offender: candidates[0].data
|
86058
86502
|
});
|
86059
86503
|
}
|
@@ -86093,8 +86537,8 @@ var getCommand = (commands, args, cliName, cliDescription) => {
|
|
86093
86537
|
args: removeByIndex(args, firstCandidate.originalIndex)
|
86094
86538
|
};
|
86095
86539
|
}
|
86096
|
-
const { command:
|
86097
|
-
if (!
|
86540
|
+
const { command: command3, args: argsRes } = getCommandInner(commands, candidates, args, cliName, cliDescription);
|
86541
|
+
if (!command3) {
|
86098
86542
|
throw new BroCliError(void 0, {
|
86099
86543
|
type: "error",
|
86100
86544
|
violation: "unknown_command_error",
|
@@ -86105,11 +86549,11 @@ var getCommand = (commands, args, cliName, cliDescription) => {
|
|
86105
86549
|
});
|
86106
86550
|
}
|
86107
86551
|
return {
|
86108
|
-
command:
|
86552
|
+
command: command3,
|
86109
86553
|
args: argsRes
|
86110
86554
|
};
|
86111
86555
|
};
|
86112
|
-
var parseArg = (
|
86556
|
+
var parseArg = (command3, options, positionals, arg, nextArg, cliName, cliDescription) => {
|
86113
86557
|
let data = void 0;
|
86114
86558
|
const argSplit = arg.split("=");
|
86115
86559
|
const hasEq = arg.includes("=");
|
@@ -86136,7 +86580,7 @@ var parseArg = (command2, options, positionals, arg, nextArg, cliName, cliDescri
|
|
86136
86580
|
name: cliName,
|
86137
86581
|
description: cliDescription,
|
86138
86582
|
violation: "enum_violation",
|
86139
|
-
command:
|
86583
|
+
command: command3,
|
86140
86584
|
option: pos[1],
|
86141
86585
|
offender: {
|
86142
86586
|
dataPart: arg
|
@@ -86182,7 +86626,7 @@ var parseArg = (command2, options, positionals, arg, nextArg, cliName, cliDescri
|
|
86182
86626
|
description: cliDescription,
|
86183
86627
|
violation: "invalid_boolean_syntax",
|
86184
86628
|
option: opt,
|
86185
|
-
command:
|
86629
|
+
command: command3,
|
86186
86630
|
offender: {
|
86187
86631
|
namePart,
|
86188
86632
|
dataPart
|
@@ -86200,7 +86644,7 @@ var parseArg = (command2, options, positionals, arg, nextArg, cliName, cliDescri
|
|
86200
86644
|
description: cliDescription,
|
86201
86645
|
violation: "invalid_string_syntax",
|
86202
86646
|
option: opt,
|
86203
|
-
command:
|
86647
|
+
command: command3,
|
86204
86648
|
offender: {
|
86205
86649
|
namePart,
|
86206
86650
|
dataPart
|
@@ -86214,7 +86658,7 @@ var parseArg = (command2, options, positionals, arg, nextArg, cliName, cliDescri
|
|
86214
86658
|
description: cliDescription,
|
86215
86659
|
violation: "enum_violation",
|
86216
86660
|
option: opt,
|
86217
|
-
command:
|
86661
|
+
command: command3,
|
86218
86662
|
offender: {
|
86219
86663
|
namePart,
|
86220
86664
|
dataPart
|
@@ -86231,7 +86675,7 @@ var parseArg = (command2, options, positionals, arg, nextArg, cliName, cliDescri
|
|
86231
86675
|
description: cliDescription,
|
86232
86676
|
violation: "invalid_number_syntax",
|
86233
86677
|
option: opt,
|
86234
|
-
command:
|
86678
|
+
command: command3,
|
86235
86679
|
offender: {
|
86236
86680
|
namePart,
|
86237
86681
|
dataPart
|
@@ -86246,7 +86690,7 @@ var parseArg = (command2, options, positionals, arg, nextArg, cliName, cliDescri
|
|
86246
86690
|
description: cliDescription,
|
86247
86691
|
violation: "invalid_number_value",
|
86248
86692
|
option: opt,
|
86249
|
-
command:
|
86693
|
+
command: command3,
|
86250
86694
|
offender: {
|
86251
86695
|
namePart,
|
86252
86696
|
dataPart
|
@@ -86260,7 +86704,7 @@ var parseArg = (command2, options, positionals, arg, nextArg, cliName, cliDescri
|
|
86260
86704
|
description: cliDescription,
|
86261
86705
|
violation: "expected_int",
|
86262
86706
|
option: opt,
|
86263
|
-
command:
|
86707
|
+
command: command3,
|
86264
86708
|
offender: {
|
86265
86709
|
namePart,
|
86266
86710
|
dataPart
|
@@ -86274,7 +86718,7 @@ var parseArg = (command2, options, positionals, arg, nextArg, cliName, cliDescri
|
|
86274
86718
|
description: cliDescription,
|
86275
86719
|
violation: "below_min",
|
86276
86720
|
option: opt,
|
86277
|
-
command:
|
86721
|
+
command: command3,
|
86278
86722
|
offender: {
|
86279
86723
|
namePart,
|
86280
86724
|
dataPart
|
@@ -86288,7 +86732,7 @@ var parseArg = (command2, options, positionals, arg, nextArg, cliName, cliDescri
|
|
86288
86732
|
description: cliDescription,
|
86289
86733
|
violation: "above_max",
|
86290
86734
|
option: opt,
|
86291
|
-
command:
|
86735
|
+
command: command3,
|
86292
86736
|
offender: {
|
86293
86737
|
namePart,
|
86294
86738
|
dataPart
|
@@ -86306,8 +86750,8 @@ var parseArg = (command2, options, positionals, arg, nextArg, cliName, cliDescri
|
|
86306
86750
|
option: option == null ? void 0 : option[1]
|
86307
86751
|
};
|
86308
86752
|
};
|
86309
|
-
var parseOptions = (
|
86310
|
-
const options =
|
86753
|
+
var parseOptions = (command3, args, cliName, cliDescription, omitKeysOfUndefinedOptions) => {
|
86754
|
+
const options = command3.options;
|
86311
86755
|
const optEntries = Object.entries(options ?? {}).map(
|
86312
86756
|
(opt) => [opt[0], opt[1].config]
|
86313
86757
|
);
|
@@ -86326,7 +86770,7 @@ var parseOptions = (command2, args, cliName, cliDescription, omitKeysOfUndefined
|
|
86326
86770
|
skipNext,
|
86327
86771
|
isHelp,
|
86328
86772
|
isVersion
|
86329
|
-
} = parseArg(
|
86773
|
+
} = parseArg(command3, nonPositionalEntries, positionalEntries, arg, nextArg, cliName, cliDescription);
|
86330
86774
|
if (!option)
|
86331
86775
|
unrecognizedArgsArr.push(arg.split("=")[0]);
|
86332
86776
|
if (skipNext)
|
@@ -86354,7 +86798,7 @@ var parseOptions = (command2, args, cliName, cliDescription, omitKeysOfUndefined
|
|
86354
86798
|
violation: "missing_args_error",
|
86355
86799
|
name: cliName,
|
86356
86800
|
description: cliDescription,
|
86357
|
-
command:
|
86801
|
+
command: command3,
|
86358
86802
|
missing: missingRequiredArr
|
86359
86803
|
});
|
86360
86804
|
}
|
@@ -86364,13 +86808,13 @@ var parseOptions = (command2, args, cliName, cliDescription, omitKeysOfUndefined
|
|
86364
86808
|
violation: "unrecognized_args_error",
|
86365
86809
|
name: cliName,
|
86366
86810
|
description: cliDescription,
|
86367
|
-
command:
|
86811
|
+
command: command3,
|
86368
86812
|
unrecognized: unrecognizedArgsArr
|
86369
86813
|
});
|
86370
86814
|
}
|
86371
86815
|
return Object.keys(result).length ? result : void 0;
|
86372
86816
|
};
|
86373
|
-
var getCommandNameWithParents = (
|
86817
|
+
var getCommandNameWithParents = (command3) => command3.parent ? `${getCommandNameWithParents(command3.parent)} ${command3.name}` : command3.name;
|
86374
86818
|
var validateCommands = (commands, parent) => {
|
86375
86819
|
const storedNames = {};
|
86376
86820
|
for (const cmd of commands) {
|
@@ -86424,13 +86868,13 @@ var run = async (commands, config) => {
|
|
86424
86868
|
}
|
86425
86869
|
const helpIndex = args.findIndex((arg) => arg === "--help" || arg === "-h");
|
86426
86870
|
if (helpIndex !== -1 && (helpIndex > 0 ? ((_a = args[helpIndex - 1]) == null ? void 0 : _a.startsWith("-")) && !args[helpIndex - 1].includes("=") ? false : true : true)) {
|
86427
|
-
const
|
86428
|
-
if (typeof
|
86429
|
-
return
|
86871
|
+
const command4 = getCommand(processedCmds, args, cliName, cliDescription).command;
|
86872
|
+
if (typeof command4 === "object") {
|
86873
|
+
return command4.help !== void 0 ? await executeOrLog(command4.help) : await eventHandler({
|
86430
86874
|
type: "command_help",
|
86431
86875
|
description: cliDescription,
|
86432
86876
|
name: cliName,
|
86433
|
-
command:
|
86877
|
+
command: command4
|
86434
86878
|
});
|
86435
86879
|
} else {
|
86436
86880
|
return help !== void 0 ? await executeOrLog(help) : await eventHandler({
|
@@ -86449,8 +86893,8 @@ var run = async (commands, config) => {
|
|
86449
86893
|
description: cliDescription
|
86450
86894
|
});
|
86451
86895
|
}
|
86452
|
-
const { command:
|
86453
|
-
if (!
|
86896
|
+
const { command: command3, args: newArgs } = getCommand(processedCmds, args, cliName, cliDescription);
|
86897
|
+
if (!command3) {
|
86454
86898
|
return help !== void 0 ? await executeOrLog(help) : await eventHandler({
|
86455
86899
|
type: "global_help",
|
86456
86900
|
description: cliDescription,
|
@@ -86458,7 +86902,7 @@ var run = async (commands, config) => {
|
|
86458
86902
|
commands: processedCmds
|
86459
86903
|
});
|
86460
86904
|
}
|
86461
|
-
if (
|
86905
|
+
if (command3 === "help") {
|
86462
86906
|
let helpCommand;
|
86463
86907
|
let newestArgs = newArgs;
|
86464
86908
|
do {
|
@@ -86478,13 +86922,13 @@ var run = async (commands, config) => {
|
|
86478
86922
|
commands: processedCmds
|
86479
86923
|
});
|
86480
86924
|
}
|
86481
|
-
const optionResult = parseOptions(
|
86925
|
+
const optionResult = parseOptions(command3, newArgs, cliName, cliDescription, omitKeysOfUndefinedOptions);
|
86482
86926
|
if (optionResult === "help") {
|
86483
|
-
return
|
86927
|
+
return command3.help !== void 0 ? await executeOrLog(command3.help) : await eventHandler({
|
86484
86928
|
type: "command_help",
|
86485
86929
|
description: cliDescription,
|
86486
86930
|
name: cliName,
|
86487
|
-
command:
|
86931
|
+
command: command3
|
86488
86932
|
});
|
86489
86933
|
}
|
86490
86934
|
if (optionResult === "version") {
|
@@ -86494,19 +86938,19 @@ var run = async (commands, config) => {
|
|
86494
86938
|
description: cliDescription
|
86495
86939
|
});
|
86496
86940
|
}
|
86497
|
-
if (
|
86941
|
+
if (command3.handler) {
|
86498
86942
|
if (config == null ? void 0 : config.hook)
|
86499
|
-
await config.hook("before",
|
86500
|
-
await
|
86943
|
+
await config.hook("before", command3);
|
86944
|
+
await command3.handler(command3.transform ? await command3.transform(optionResult) : optionResult);
|
86501
86945
|
if (config == null ? void 0 : config.hook)
|
86502
|
-
await config.hook("after",
|
86946
|
+
await config.hook("after", command3);
|
86503
86947
|
return;
|
86504
86948
|
} else {
|
86505
|
-
return
|
86949
|
+
return command3.help !== void 0 ? await executeOrLog(command3.help) : await eventHandler({
|
86506
86950
|
type: "command_help",
|
86507
86951
|
description: cliDescription,
|
86508
86952
|
name: cliName,
|
86509
|
-
command:
|
86953
|
+
command: command3
|
86510
86954
|
});
|
86511
86955
|
}
|
86512
86956
|
} catch (e2) {
|
@@ -86803,7 +87247,7 @@ var updateUpToV7 = (json) => {
|
|
86803
87247
|
return [idx[0], { columns: mappedColumns, with: {}, ...rest }];
|
86804
87248
|
})
|
86805
87249
|
);
|
86806
|
-
return [it[0], { ...table4, indexes: mappedIndexes }];
|
87250
|
+
return [it[0], { ...table4, indexes: mappedIndexes, policies: {}, isRLSEnabled: false, checkConstraints: {} }];
|
86807
87251
|
})
|
86808
87252
|
);
|
86809
87253
|
return {
|
@@ -86811,7 +87255,10 @@ var updateUpToV7 = (json) => {
|
|
86811
87255
|
version: "7",
|
86812
87256
|
dialect: "postgresql",
|
86813
87257
|
sequences: {},
|
86814
|
-
tables
|
87258
|
+
tables,
|
87259
|
+
policies: {},
|
87260
|
+
views: {},
|
87261
|
+
roles: {}
|
86815
87262
|
};
|
86816
87263
|
};
|
86817
87264
|
|
@@ -86851,7 +87298,8 @@ var updateUpToV62 = (json) => {
|
|
86851
87298
|
...schema5,
|
86852
87299
|
version: "6",
|
86853
87300
|
dialect: "sqlite",
|
86854
|
-
tables
|
87301
|
+
tables,
|
87302
|
+
views: {}
|
86855
87303
|
};
|
86856
87304
|
};
|
86857
87305
|
|
@@ -87926,7 +88374,7 @@ var optionBreakpoints = boolean().desc(
|
|
87926
88374
|
);
|
87927
88375
|
var optionDriver = string().enum(...drivers).desc("Database driver");
|
87928
88376
|
var optionCasing = string().enum("camelCase", "snake_case").desc("Casing for serialization");
|
87929
|
-
var generate =
|
88377
|
+
var generate = command2({
|
87930
88378
|
name: "generate",
|
87931
88379
|
options: {
|
87932
88380
|
config: optionConfig,
|
@@ -87972,7 +88420,7 @@ var generate = command({
|
|
87972
88420
|
}
|
87973
88421
|
}
|
87974
88422
|
});
|
87975
|
-
var migrate =
|
88423
|
+
var migrate = command2({
|
87976
88424
|
name: "migrate",
|
87977
88425
|
options: {
|
87978
88426
|
config: optionConfig
|
@@ -88079,7 +88527,7 @@ var optionsDatabaseCredentials = {
|
|
88079
88527
|
// specific cases
|
88080
88528
|
driver: optionDriver
|
88081
88529
|
};
|
88082
|
-
var push =
|
88530
|
+
var push = command2({
|
88083
88531
|
name: "push",
|
88084
88532
|
options: {
|
88085
88533
|
config: optionConfig,
|
@@ -88131,7 +88579,8 @@ var push = command({
|
|
88131
88579
|
tablesFilter,
|
88132
88580
|
schemasFilter,
|
88133
88581
|
force,
|
88134
|
-
casing: casing2
|
88582
|
+
casing: casing2,
|
88583
|
+
entities
|
88135
88584
|
} = config;
|
88136
88585
|
try {
|
88137
88586
|
if (dialect4 === "mysql") {
|
@@ -88174,6 +88623,7 @@ var push = command({
|
|
88174
88623
|
credentials2,
|
88175
88624
|
tablesFilter,
|
88176
88625
|
schemasFilter,
|
88626
|
+
entities,
|
88177
88627
|
force,
|
88178
88628
|
casing2
|
88179
88629
|
);
|
@@ -88208,7 +88658,7 @@ var push = command({
|
|
88208
88658
|
process.exit(0);
|
88209
88659
|
}
|
88210
88660
|
});
|
88211
|
-
var check =
|
88661
|
+
var check = command2({
|
88212
88662
|
name: "check",
|
88213
88663
|
options: {
|
88214
88664
|
config: optionConfig,
|
@@ -88226,7 +88676,7 @@ var check = command({
|
|
88226
88676
|
console.log("Everything's fine \u{1F436}\u{1F525}");
|
88227
88677
|
}
|
88228
88678
|
});
|
88229
|
-
var up =
|
88679
|
+
var up = command2({
|
88230
88680
|
name: "up",
|
88231
88681
|
options: {
|
88232
88682
|
config: optionConfig,
|
@@ -88252,7 +88702,7 @@ var up = command({
|
|
88252
88702
|
}
|
88253
88703
|
}
|
88254
88704
|
});
|
88255
|
-
var pull =
|
88705
|
+
var pull = command2({
|
88256
88706
|
name: "introspect",
|
88257
88707
|
aliases: ["pull"],
|
88258
88708
|
options: {
|
@@ -88383,7 +88833,7 @@ var pull = command({
|
|
88383
88833
|
process.exit(0);
|
88384
88834
|
}
|
88385
88835
|
});
|
88386
|
-
var drop =
|
88836
|
+
var drop = command2({
|
88387
88837
|
name: "drop",
|
88388
88838
|
options: {
|
88389
88839
|
config: optionConfig,
|
@@ -88400,7 +88850,7 @@ var drop = command({
|
|
88400
88850
|
await dropMigration(config);
|
88401
88851
|
}
|
88402
88852
|
});
|
88403
|
-
var studio =
|
88853
|
+
var studio = command2({
|
88404
88854
|
name: "studio",
|
88405
88855
|
options: {
|
88406
88856
|
config: optionConfig,
|
@@ -88513,14 +88963,14 @@ init_utils2();
|
|
88513
88963
|
var version2 = async () => {
|
88514
88964
|
const { npmVersion } = await ormCoreVersions();
|
88515
88965
|
const ormVersion = npmVersion ? `drizzle-orm: v${npmVersion}` : "";
|
88516
|
-
const envVersion = "0.26.2-
|
88966
|
+
const envVersion = "0.26.2-4b200a2";
|
88517
88967
|
const kitVersion = envVersion ? `v${envVersion}` : "--";
|
88518
88968
|
const versions = `drizzle-kit: ${kitVersion}
|
88519
88969
|
${ormVersion}`;
|
88520
88970
|
console.log(source_default.gray(versions), "\n");
|
88521
88971
|
};
|
88522
88972
|
var legacyCommand = (name, newName) => {
|
88523
|
-
return
|
88973
|
+
return command2({
|
88524
88974
|
name,
|
88525
88975
|
hidden: true,
|
88526
88976
|
handler: () => {
|