drizzle-kit 0.26.2-a43c673 → 0.26.2-b2b714a
Sign up to get free protection for your applications and to get access to all the features.
- package/api.d.mts +103 -1
- package/api.d.ts +103 -1
- package/api.js +1537 -566
- package/api.mjs +1537 -566
- package/bin.cjs +1115 -159
- package/index.d.mts +7 -0
- package/index.d.ts +7 -0
- package/package.json +1 -1
- package/utils.js +23 -3
- package/utils.mjs +23 -3
package/bin.cjs
CHANGED
@@ -1075,7 +1075,7 @@ var require_hanji = __commonJS({
|
|
1075
1075
|
});
|
1076
1076
|
|
1077
1077
|
// src/cli/views.ts
|
1078
|
-
var import_hanji, warning, err, info, grey, error, schema, isRenamePromptItem, ResolveColumnSelect, tableKey, ResolveSelect, ResolveSchemasSelect, Spinner, IntrospectProgress, MigrateProgress, ProgressView, DropMigrationView, trimmedRange;
|
1078
|
+
var import_hanji, warning, err, info, grey, error, schema, isRenamePromptItem, ResolveColumnSelect, tableKey, ResolveSelectNamed, ResolveSelect, ResolveSchemasSelect, Spinner, IntrospectProgress, MigrateProgress, ProgressView, DropMigrationView, trimmedRange;
|
1079
1079
|
var init_views = __esm({
|
1080
1080
|
"src/cli/views.ts"() {
|
1081
1081
|
"use strict";
|
@@ -1178,6 +1178,53 @@ Is ${source_default.bold.blue(
|
|
1178
1178
|
tableKey = (it) => {
|
1179
1179
|
return it.schema === "public" || !it.schema ? it.name : `${it.schema}.${it.name}`;
|
1180
1180
|
};
|
1181
|
+
ResolveSelectNamed = class extends import_hanji.Prompt {
|
1182
|
+
constructor(base, data, entityType) {
|
1183
|
+
super();
|
1184
|
+
this.base = base;
|
1185
|
+
this.entityType = entityType;
|
1186
|
+
this.on("attach", (terminal) => terminal.toggleCursor("hide"));
|
1187
|
+
this.state = new import_hanji.SelectState(data);
|
1188
|
+
this.state.bind(this);
|
1189
|
+
this.base = base;
|
1190
|
+
}
|
1191
|
+
render(status) {
|
1192
|
+
if (status === "submitted" || status === "aborted") {
|
1193
|
+
return "";
|
1194
|
+
}
|
1195
|
+
const key = this.base.name;
|
1196
|
+
let text = `
|
1197
|
+
Is ${source_default.bold.blue(key)} ${this.entityType} created or renamed from another ${this.entityType}?
|
1198
|
+
`;
|
1199
|
+
const isSelectedRenamed = isRenamePromptItem(
|
1200
|
+
this.state.items[this.state.selectedIdx]
|
1201
|
+
);
|
1202
|
+
const selectedPrefix = isSelectedRenamed ? source_default.yellow("\u276F ") : source_default.green("\u276F ");
|
1203
|
+
const labelLength = this.state.items.filter((it) => isRenamePromptItem(it)).map((_2) => {
|
1204
|
+
const it = _2;
|
1205
|
+
const keyFrom = it.from.name;
|
1206
|
+
return key.length + 3 + keyFrom.length;
|
1207
|
+
}).reduce((a, b) => {
|
1208
|
+
if (a > b) {
|
1209
|
+
return a;
|
1210
|
+
}
|
1211
|
+
return b;
|
1212
|
+
}, 0);
|
1213
|
+
const entityType = this.entityType;
|
1214
|
+
this.state.items.forEach((it, idx) => {
|
1215
|
+
const isSelected = idx === this.state.selectedIdx;
|
1216
|
+
const isRenamed = isRenamePromptItem(it);
|
1217
|
+
const title = isRenamed ? `${it.from.name} \u203A ${it.to.name}`.padEnd(labelLength, " ") : it.name.padEnd(labelLength, " ");
|
1218
|
+
const label = isRenamed ? `${source_default.yellow("~")} ${title} ${source_default.gray(`rename ${entityType}`)}` : `${source_default.green("+")} ${title} ${source_default.gray(`create ${entityType}`)}`;
|
1219
|
+
text += isSelected ? `${selectedPrefix}${label}` : ` ${label}`;
|
1220
|
+
text += idx != this.state.items.length - 1 ? "\n" : "";
|
1221
|
+
});
|
1222
|
+
return text;
|
1223
|
+
}
|
1224
|
+
result() {
|
1225
|
+
return this.state.items[this.state.selectedIdx];
|
1226
|
+
}
|
1227
|
+
};
|
1181
1228
|
ResolveSelect = class extends import_hanji.Prompt {
|
1182
1229
|
constructor(base, data, entityType) {
|
1183
1230
|
super();
|
@@ -1316,6 +1363,11 @@ Is ${source_default.bold.blue(
|
|
1316
1363
|
name: "foreign keys",
|
1317
1364
|
status: "fetching"
|
1318
1365
|
},
|
1366
|
+
policies: {
|
1367
|
+
count: 0,
|
1368
|
+
name: "policies",
|
1369
|
+
status: "fetching"
|
1370
|
+
},
|
1319
1371
|
checks: {
|
1320
1372
|
count: 0,
|
1321
1373
|
name: "check constraints",
|
@@ -1362,6 +1414,7 @@ Is ${source_default.bold.blue(
|
|
1362
1414
|
info2 += this.hasEnums ? this.statusText(spin, this.state.enums) : "";
|
1363
1415
|
info2 += this.statusText(spin, this.state.indexes);
|
1364
1416
|
info2 += this.statusText(spin, this.state.fks);
|
1417
|
+
info2 += this.statusText(spin, this.state.policies);
|
1365
1418
|
info2 += this.statusText(spin, this.state.checks);
|
1366
1419
|
info2 += this.statusText(spin, this.state.views);
|
1367
1420
|
return info2;
|
@@ -1748,8 +1801,8 @@ var init_lib = __esm({
|
|
1748
1801
|
return void 0;
|
1749
1802
|
};
|
1750
1803
|
util2.isInteger = typeof Number.isInteger === "function" ? (val2) => Number.isInteger(val2) : (val2) => typeof val2 === "number" && isFinite(val2) && Math.floor(val2) === val2;
|
1751
|
-
function joinValues(
|
1752
|
-
return
|
1804
|
+
function joinValues(array2, separator = " | ") {
|
1805
|
+
return array2.map((val2) => typeof val2 === "string" ? `'${val2}'` : val2).join(separator);
|
1753
1806
|
}
|
1754
1807
|
util2.joinValues = joinValues;
|
1755
1808
|
util2.jsonStringifyReplacer = (_2, value) => {
|
@@ -5779,7 +5832,7 @@ var init_vector = __esm({
|
|
5779
5832
|
});
|
5780
5833
|
|
5781
5834
|
// src/serializer/pgSchema.ts
|
5782
|
-
var indexV2, columnV2, tableV2, enumSchemaV1, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, indexColumn, index2, indexV4, indexV5, indexV6, fk2, sequenceSchema, sequenceSquashed, columnV7, column2, checkConstraint2, columnSquashed, tableV32, compositePK2, uniqueConstraint2, 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, 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;
|
5783
5836
|
var init_pgSchema = __esm({
|
5784
5837
|
"src/serializer/pgSchema.ts"() {
|
5785
5838
|
"use strict";
|
@@ -5911,6 +5964,12 @@ var init_pgSchema = __esm({
|
|
5911
5964
|
cycle: booleanType().optional(),
|
5912
5965
|
schema: stringType()
|
5913
5966
|
}).strict();
|
5967
|
+
roleSchema = objectType({
|
5968
|
+
name: stringType(),
|
5969
|
+
createDb: booleanType().optional(),
|
5970
|
+
createRole: booleanType().optional(),
|
5971
|
+
inherit: booleanType().optional()
|
5972
|
+
}).strict();
|
5914
5973
|
sequenceSquashed = objectType({
|
5915
5974
|
name: stringType(),
|
5916
5975
|
schema: stringType(),
|
@@ -5978,6 +6037,14 @@ var init_pgSchema = __esm({
|
|
5978
6037
|
columns: stringType().array(),
|
5979
6038
|
nullsNotDistinct: booleanType()
|
5980
6039
|
}).strict();
|
6040
|
+
policy = objectType({
|
6041
|
+
name: stringType(),
|
6042
|
+
as: enumType(["PERMISSIVE", "RESTRICTIVE"]).optional(),
|
6043
|
+
for: enumType(["ALL", "SELECT", "INSERT", "UPDATE", "DELETE"]).optional(),
|
6044
|
+
to: stringType().array().optional(),
|
6045
|
+
using: stringType().optional(),
|
6046
|
+
withCheck: stringType().optional()
|
6047
|
+
}).strict();
|
5981
6048
|
viewWithOption = objectType({
|
5982
6049
|
checkOption: enumType(["local", "cascaded"]).optional(),
|
5983
6050
|
securityBarrier: booleanType().optional(),
|
@@ -6058,7 +6125,9 @@ var init_pgSchema = __esm({
|
|
6058
6125
|
foreignKeys: recordType(stringType(), fk2),
|
6059
6126
|
compositePrimaryKeys: recordType(stringType(), compositePK2),
|
6060
6127
|
uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({}),
|
6061
|
-
|
6128
|
+
policies: recordType(stringType(), policy).default({}),
|
6129
|
+
checkConstraints: recordType(stringType(), checkConstraint2).default({}),
|
6130
|
+
isRLSEnabled: booleanType().default(false)
|
6062
6131
|
}).strict();
|
6063
6132
|
schemaHash2 = objectType({
|
6064
6133
|
id: stringType(),
|
@@ -6153,6 +6222,7 @@ var init_pgSchema = __esm({
|
|
6153
6222
|
schemas: recordType(stringType(), stringType()),
|
6154
6223
|
views: recordType(stringType(), view2).default({}),
|
6155
6224
|
sequences: recordType(stringType(), sequenceSchema).default({}),
|
6225
|
+
roles: recordType(stringType(), roleSchema).default({}),
|
6156
6226
|
_meta: objectType({
|
6157
6227
|
schemas: recordType(stringType(), stringType()),
|
6158
6228
|
tables: recordType(stringType(), stringType()),
|
@@ -6168,7 +6238,9 @@ var init_pgSchema = __esm({
|
|
6168
6238
|
foreignKeys: recordType(stringType(), stringType()),
|
6169
6239
|
compositePrimaryKeys: recordType(stringType(), stringType()),
|
6170
6240
|
uniqueConstraints: recordType(stringType(), stringType()),
|
6171
|
-
|
6241
|
+
policies: recordType(stringType(), stringType()),
|
6242
|
+
checkConstraints: recordType(stringType(), stringType()),
|
6243
|
+
isRLSEnabled: booleanType().default(false)
|
6172
6244
|
}).strict();
|
6173
6245
|
tableSquashedV42 = objectType({
|
6174
6246
|
name: stringType(),
|
@@ -6198,7 +6270,8 @@ var init_pgSchema = __esm({
|
|
6198
6270
|
enums: recordType(stringType(), enumSchema),
|
6199
6271
|
schemas: recordType(stringType(), stringType()),
|
6200
6272
|
views: recordType(stringType(), view2),
|
6201
|
-
sequences: recordType(stringType(), sequenceSquashed)
|
6273
|
+
sequences: recordType(stringType(), sequenceSquashed),
|
6274
|
+
roles: recordType(stringType(), roleSchema).default({})
|
6202
6275
|
}).strict();
|
6203
6276
|
pgSchemaV3 = pgSchemaInternalV3.merge(schemaHash2);
|
6204
6277
|
pgSchemaV4 = pgSchemaInternalV4.merge(schemaHash2);
|
@@ -6281,6 +6354,25 @@ var init_pgSchema = __esm({
|
|
6281
6354
|
squashFK: (fk4) => {
|
6282
6355
|
return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""};${fk4.schemaTo || "public"}`;
|
6283
6356
|
},
|
6357
|
+
squashPolicy: (policy2) => {
|
6358
|
+
var _a;
|
6359
|
+
return `${policy2.name}--${policy2.as}--${policy2.for}--${(_a = policy2.to) == null ? void 0 : _a.join(",")}--${policy2.using}--${policy2.withCheck}`;
|
6360
|
+
},
|
6361
|
+
unsquashPolicy: (policy2) => {
|
6362
|
+
const splitted = policy2.split("--");
|
6363
|
+
return {
|
6364
|
+
name: splitted[0],
|
6365
|
+
as: splitted[1],
|
6366
|
+
for: splitted[2],
|
6367
|
+
to: splitted[3].split(","),
|
6368
|
+
using: splitted[4] !== "undefined" ? splitted[4] : void 0,
|
6369
|
+
withCheck: splitted[5] !== "undefined" ? splitted[5] : void 0
|
6370
|
+
};
|
6371
|
+
},
|
6372
|
+
squashPolicyPush: (policy2) => {
|
6373
|
+
var _a;
|
6374
|
+
return `${policy2.name}--${policy2.as}--${policy2.for}--${(_a = policy2.to) == null ? void 0 : _a.join(",")}`;
|
6375
|
+
},
|
6284
6376
|
squashPK: (pk) => {
|
6285
6377
|
return `${pk.columns.join(",")};${pk.name}`;
|
6286
6378
|
},
|
@@ -6393,6 +6485,9 @@ var init_pgSchema = __esm({
|
|
6393
6485
|
return PgSquasher.squashUnique(unq);
|
6394
6486
|
}
|
6395
6487
|
);
|
6488
|
+
const squashedPolicies = mapValues(it[1].policies, (policy2) => {
|
6489
|
+
return action === "push" ? PgSquasher.squashPolicyPush(policy2) : PgSquasher.squashPolicy(policy2);
|
6490
|
+
});
|
6396
6491
|
const squashedChecksContraints = mapValues(
|
6397
6492
|
it[1].checkConstraints,
|
6398
6493
|
(check2) => {
|
@@ -6409,7 +6504,9 @@ var init_pgSchema = __esm({
|
|
6409
6504
|
foreignKeys: squashedFKs,
|
6410
6505
|
compositePrimaryKeys: squashedPKs,
|
6411
6506
|
uniqueConstraints: squashedUniqueConstraints,
|
6412
|
-
|
6507
|
+
policies: squashedPolicies,
|
6508
|
+
checkConstraints: squashedChecksContraints,
|
6509
|
+
isRLSEnabled: it[1].isRLSEnabled ?? false
|
6413
6510
|
}
|
6414
6511
|
];
|
6415
6512
|
})
|
@@ -6433,7 +6530,8 @@ var init_pgSchema = __esm({
|
|
6433
6530
|
enums: json.enums,
|
6434
6531
|
schemas: json.schemas,
|
6435
6532
|
views: json.views,
|
6436
|
-
sequences: mappedSequences
|
6533
|
+
sequences: mappedSequences,
|
6534
|
+
roles: json.roles
|
6437
6535
|
};
|
6438
6536
|
};
|
6439
6537
|
dryPg = pgSchema.parse({
|
@@ -10770,10 +10868,10 @@ var require_inflight = __commonJS({
|
|
10770
10868
|
}
|
10771
10869
|
function slice(args) {
|
10772
10870
|
var length = args.length;
|
10773
|
-
var
|
10871
|
+
var array2 = [];
|
10774
10872
|
for (var i2 = 0; i2 < length; i2++)
|
10775
|
-
|
10776
|
-
return
|
10873
|
+
array2[i2] = args[i2];
|
10874
|
+
return array2;
|
10777
10875
|
}
|
10778
10876
|
}
|
10779
10877
|
});
|
@@ -11596,6 +11694,13 @@ var init_cli = __esm({
|
|
11596
11694
|
breakpoints: booleanType().optional().default(true),
|
11597
11695
|
migrations: objectType({
|
11598
11696
|
prefix: prefix.optional().default("index")
|
11697
|
+
}).optional(),
|
11698
|
+
entities: objectType({
|
11699
|
+
roles: booleanType().or(objectType({
|
11700
|
+
provider: stringType().optional(),
|
11701
|
+
include: stringType().array().optional(),
|
11702
|
+
exclude: stringType().array().optional()
|
11703
|
+
})).optional().default(false)
|
11599
11704
|
}).optional()
|
11600
11705
|
}).passthrough();
|
11601
11706
|
configCheck = objectType({
|
@@ -17783,7 +17888,8 @@ var init_utils4 = __esm({
|
|
17783
17888
|
credentials: parsed2.data,
|
17784
17889
|
tablesFilter,
|
17785
17890
|
schemasFilter,
|
17786
|
-
prefix: ((_a = config.migrations) == null ? void 0 : _a.prefix) || "index"
|
17891
|
+
prefix: ((_a = config.migrations) == null ? void 0 : _a.prefix) || "index",
|
17892
|
+
entities: config.entities
|
17787
17893
|
};
|
17788
17894
|
}
|
17789
17895
|
if (dialect4 === "mysql") {
|
@@ -17800,7 +17906,8 @@ var init_utils4 = __esm({
|
|
17800
17906
|
credentials: parsed2.data,
|
17801
17907
|
tablesFilter,
|
17802
17908
|
schemasFilter,
|
17803
|
-
prefix: ((_b = config.migrations) == null ? void 0 : _b.prefix) || "index"
|
17909
|
+
prefix: ((_b = config.migrations) == null ? void 0 : _b.prefix) || "index",
|
17910
|
+
entities: config.entities
|
17804
17911
|
};
|
17805
17912
|
}
|
17806
17913
|
if (dialect4 === "sqlite") {
|
@@ -17817,7 +17924,8 @@ var init_utils4 = __esm({
|
|
17817
17924
|
credentials: parsed2.data,
|
17818
17925
|
tablesFilter,
|
17819
17926
|
schemasFilter,
|
17820
|
-
prefix: ((_c = config.migrations) == null ? void 0 : _c.prefix) || "index"
|
17927
|
+
prefix: ((_c = config.migrations) == null ? void 0 : _c.prefix) || "index",
|
17928
|
+
entities: config.entities
|
17821
17929
|
};
|
17822
17930
|
}
|
17823
17931
|
if (dialect4 === "turso") {
|
@@ -18861,6 +18969,8 @@ var init_pgImports = __esm({
|
|
18861
18969
|
const enums = [];
|
18862
18970
|
const schemas = [];
|
18863
18971
|
const sequences = [];
|
18972
|
+
const roles = [];
|
18973
|
+
const policies = [];
|
18864
18974
|
const views = [];
|
18865
18975
|
const matViews = [];
|
18866
18976
|
const i0values = Object.values(exports2);
|
@@ -18884,8 +18994,14 @@ var init_pgImports = __esm({
|
|
18884
18994
|
if ((0, import_pg_core.isPgSequence)(t2)) {
|
18885
18995
|
sequences.push(t2);
|
18886
18996
|
}
|
18997
|
+
if ((0, import_drizzle_orm4.is)(t2, import_pg_core.PgRole)) {
|
18998
|
+
roles.push(t2);
|
18999
|
+
}
|
19000
|
+
if ((0, import_drizzle_orm4.is)(t2, import_pg_core.PgPolicy)) {
|
19001
|
+
policies.push(t2);
|
19002
|
+
}
|
18887
19003
|
});
|
18888
|
-
return { tables, enums, schemas, sequences, views, matViews };
|
19004
|
+
return { tables, enums, schemas, sequences, views, matViews, roles, policies };
|
18889
19005
|
};
|
18890
19006
|
prepareFromPgImports = async (imports) => {
|
18891
19007
|
const tables = [];
|
@@ -18893,6 +19009,8 @@ var init_pgImports = __esm({
|
|
18893
19009
|
const schemas = [];
|
18894
19010
|
const sequences = [];
|
18895
19011
|
const views = [];
|
19012
|
+
const roles = [];
|
19013
|
+
const policies = [];
|
18896
19014
|
const matViews = [];
|
18897
19015
|
const { unregister } = await safeRegister();
|
18898
19016
|
for (let i2 = 0; i2 < imports.length; i2++) {
|
@@ -18905,9 +19023,11 @@ var init_pgImports = __esm({
|
|
18905
19023
|
sequences.push(...prepared.sequences);
|
18906
19024
|
views.push(...prepared.views);
|
18907
19025
|
matViews.push(...prepared.matViews);
|
19026
|
+
roles.push(...prepared.roles);
|
19027
|
+
policies.push(...prepared.policies);
|
18908
19028
|
}
|
18909
19029
|
unregister();
|
18910
|
-
return { tables: Array.from(new Set(tables)), enums, schemas, sequences, views, matViews };
|
19030
|
+
return { tables: Array.from(new Set(tables)), enums, schemas, sequences, views, matViews, roles, policies };
|
18911
19031
|
};
|
18912
19032
|
}
|
18913
19033
|
});
|
@@ -18915,6 +19035,7 @@ var init_pgImports = __esm({
|
|
18915
19035
|
// src/serializer/pgSerializer.ts
|
18916
19036
|
var pgSerializer_exports = {};
|
18917
19037
|
__export(pgSerializer_exports, {
|
19038
|
+
buildArrayString: () => buildArrayString,
|
18918
19039
|
fromDatabase: () => fromDatabase2,
|
18919
19040
|
generatePgSnapshot: () => generatePgSnapshot,
|
18920
19041
|
indexName: () => indexName2
|
@@ -18926,14 +19047,14 @@ function maxRangeForIdentityBasedOn(columnType) {
|
|
18926
19047
|
return columnType === "integer" ? "2147483647" : columnType === "bigint" ? "9223372036854775807" : "32767";
|
18927
19048
|
}
|
18928
19049
|
function minRangeForIdentityBasedOn(columnType) {
|
18929
|
-
return columnType === "integer" ? "-2147483648" : columnType === "
|
19050
|
+
return columnType === "integer" ? "-2147483648" : columnType === "bigint" ? "-9223372036854775808" : "-32768";
|
18930
19051
|
}
|
18931
19052
|
function stringFromDatabaseIdentityProperty(field) {
|
18932
19053
|
return typeof field === "string" ? field : typeof field === "undefined" ? void 0 : typeof field === "bigint" ? field.toString() : String(field);
|
18933
19054
|
}
|
18934
|
-
function buildArrayString(
|
19055
|
+
function buildArrayString(array2, sqlType) {
|
18935
19056
|
sqlType = sqlType.split("[")[0];
|
18936
|
-
const values =
|
19057
|
+
const values = array2.map((value) => {
|
18937
19058
|
if (typeof value === "number" || typeof value === "bigint") {
|
18938
19059
|
return value.toString();
|
18939
19060
|
} else if (typeof value === "boolean") {
|
@@ -18955,6 +19076,40 @@ function buildArrayString(array, sqlType) {
|
|
18955
19076
|
}).join(",");
|
18956
19077
|
return `{${values}}`;
|
18957
19078
|
}
|
19079
|
+
function prepareRoles(entities) {
|
19080
|
+
let useRoles = false;
|
19081
|
+
const includeRoles = [];
|
19082
|
+
const excludeRoles = [];
|
19083
|
+
if (entities && entities.roles) {
|
19084
|
+
if (typeof entities.roles === "object") {
|
19085
|
+
if (entities.roles.provider) {
|
19086
|
+
if (entities.roles.provider === "supabase") {
|
19087
|
+
excludeRoles.push(...[
|
19088
|
+
"anon",
|
19089
|
+
"authenticator",
|
19090
|
+
"authenticated",
|
19091
|
+
"service_role",
|
19092
|
+
"supabase_auth_admin",
|
19093
|
+
"supabase_storage_admin",
|
19094
|
+
"dashboard_user",
|
19095
|
+
"supabase_admin"
|
19096
|
+
]);
|
19097
|
+
} else if (entities.roles.provider === "neon") {
|
19098
|
+
excludeRoles.push(...["authenticated", "anonymous"]);
|
19099
|
+
}
|
19100
|
+
}
|
19101
|
+
if (entities.roles.include) {
|
19102
|
+
includeRoles.push(...entities.roles.include);
|
19103
|
+
}
|
19104
|
+
if (entities.roles.exclude) {
|
19105
|
+
excludeRoles.push(...entities.roles.exclude);
|
19106
|
+
}
|
19107
|
+
} else {
|
19108
|
+
useRoles = entities.roles;
|
19109
|
+
}
|
19110
|
+
}
|
19111
|
+
return { useRoles, includeRoles, excludeRoles };
|
19112
|
+
}
|
18958
19113
|
var import_drizzle_orm5, import_pg_core2, import_pg_core3, indexName2, generatePgSnapshot, trimChar, fromDatabase2, defaultForColumn, getColumnsInfoQuery;
|
18959
19114
|
var init_pgSerializer = __esm({
|
18960
19115
|
"src/serializer/pgSerializer.ts"() {
|
@@ -18970,16 +19125,28 @@ var init_pgSerializer = __esm({
|
|
18970
19125
|
indexName2 = (tableName, columns) => {
|
18971
19126
|
return `${tableName}_${columns.join("_")}_index`;
|
18972
19127
|
};
|
18973
|
-
generatePgSnapshot = (tables, enums, schemas, sequences, views, matViews, casing2, schemaFilter) => {
|
18974
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
19128
|
+
generatePgSnapshot = (tables, enums, schemas, sequences, roles, policies, views, matViews, casing2, schemaFilter) => {
|
19129
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
18975
19130
|
const dialect4 = new import_pg_core2.PgDialect({ casing: casing2 });
|
18976
19131
|
const result = {};
|
18977
19132
|
const resultViews = {};
|
18978
19133
|
const sequencesToReturn = {};
|
19134
|
+
const rolesToReturn = {};
|
18979
19135
|
const indexesInSchema = {};
|
18980
19136
|
for (const table4 of tables) {
|
18981
19137
|
const checksInTable = {};
|
18982
|
-
const {
|
19138
|
+
const {
|
19139
|
+
name: tableName,
|
19140
|
+
columns,
|
19141
|
+
indexes,
|
19142
|
+
foreignKeys,
|
19143
|
+
checks,
|
19144
|
+
schema: schema5,
|
19145
|
+
primaryKeys,
|
19146
|
+
uniqueConstraints,
|
19147
|
+
policies: policies2,
|
19148
|
+
enableRLS
|
19149
|
+
} = (0, import_pg_core3.getTableConfig)(table4);
|
18983
19150
|
if (schemaFilter && !schemaFilter.includes(schema5 ?? "public")) {
|
18984
19151
|
continue;
|
18985
19152
|
}
|
@@ -18989,6 +19156,7 @@ var init_pgSerializer = __esm({
|
|
18989
19156
|
const foreignKeysObject = {};
|
18990
19157
|
const primaryKeysObject = {};
|
18991
19158
|
const uniqueConstraintObject = {};
|
19159
|
+
const policiesObject = {};
|
18992
19160
|
columns.forEach((column7) => {
|
18993
19161
|
var _a2, _b2, _c2, _d2, _e2, _f2;
|
18994
19162
|
const name = getColumnCasing(column7, casing2);
|
@@ -19238,6 +19406,46 @@ ${withStyle.errorWarning(
|
|
19238
19406
|
with: value.config.with ?? {}
|
19239
19407
|
};
|
19240
19408
|
});
|
19409
|
+
policies2.forEach((policy2) => {
|
19410
|
+
var _a2, _b2;
|
19411
|
+
const mappedTo = [];
|
19412
|
+
if (!policy2.to) {
|
19413
|
+
mappedTo.push("public");
|
19414
|
+
} else {
|
19415
|
+
if (policy2.to && typeof policy2.to === "string") {
|
19416
|
+
mappedTo.push(policy2.to);
|
19417
|
+
} else if (policy2.to && (0, import_drizzle_orm5.is)(policy2.to, import_pg_core2.PgRole)) {
|
19418
|
+
mappedTo.push(policy2.to.name);
|
19419
|
+
} else if (policy2.to && Array.isArray(policy2.to)) {
|
19420
|
+
policy2.to.forEach((it) => {
|
19421
|
+
if (typeof it === "string") {
|
19422
|
+
mappedTo.push(it);
|
19423
|
+
} else if ((0, import_drizzle_orm5.is)(it, import_pg_core2.PgRole)) {
|
19424
|
+
mappedTo.push(it.name);
|
19425
|
+
}
|
19426
|
+
});
|
19427
|
+
}
|
19428
|
+
}
|
19429
|
+
if (policiesObject[policy2.name] !== void 0) {
|
19430
|
+
console.log(
|
19431
|
+
`
|
19432
|
+
${withStyle.errorWarning(
|
19433
|
+
`We've found duplicated policy name across ${source_default.underline.blue(tableKey2)} table. Please rename one of the policies with ${source_default.underline.blue(
|
19434
|
+
policy2.name
|
19435
|
+
)} name`
|
19436
|
+
)}`
|
19437
|
+
);
|
19438
|
+
process.exit(1);
|
19439
|
+
}
|
19440
|
+
policiesObject[policy2.name] = {
|
19441
|
+
name: policy2.name,
|
19442
|
+
as: ((_a2 = policy2.as) == null ? void 0 : _a2.toUpperCase()) ?? "PERMISSIVE",
|
19443
|
+
for: ((_b2 = policy2.for) == null ? void 0 : _b2.toUpperCase()) ?? "ALL",
|
19444
|
+
to: mappedTo.sort(),
|
19445
|
+
using: (0, import_drizzle_orm5.is)(policy2.using, import_drizzle_orm5.SQL) ? dialect4.sqlToQuery(policy2.using).sql : void 0,
|
19446
|
+
withCheck: (0, import_drizzle_orm5.is)(policy2.withCheck, import_drizzle_orm5.SQL) ? dialect4.sqlToQuery(policy2.withCheck).sql : void 0
|
19447
|
+
};
|
19448
|
+
});
|
19241
19449
|
checks.forEach((check2) => {
|
19242
19450
|
const checkName = check2.name;
|
19243
19451
|
if (typeof checksInTable[`"${schema5 ?? "public"}"."${tableName}"`] !== "undefined") {
|
@@ -19274,17 +19482,69 @@ ${withStyle.errorWarning(
|
|
19274
19482
|
foreignKeys: foreignKeysObject,
|
19275
19483
|
compositePrimaryKeys: primaryKeysObject,
|
19276
19484
|
uniqueConstraints: uniqueConstraintObject,
|
19277
|
-
|
19485
|
+
policies: policiesObject,
|
19486
|
+
checkConstraints: checksObject,
|
19487
|
+
isRLSEnabled: enableRLS
|
19488
|
+
};
|
19489
|
+
}
|
19490
|
+
for (const policy2 of policies) {
|
19491
|
+
if (!policy2._linkedTable) {
|
19492
|
+
console.log(
|
19493
|
+
`
|
19494
|
+
${withStyle.errorWarning(
|
19495
|
+
`"Policy ${policy2.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:`
|
19496
|
+
)}`
|
19497
|
+
);
|
19498
|
+
continue;
|
19499
|
+
}
|
19500
|
+
const tableConfig = (0, import_pg_core3.getTableConfig)(policy2._linkedTable);
|
19501
|
+
const tableKey2 = `${tableConfig.schema ?? "public"}.${tableConfig.name}`;
|
19502
|
+
const mappedTo = [];
|
19503
|
+
if (!policy2.to) {
|
19504
|
+
mappedTo.push("public");
|
19505
|
+
} else {
|
19506
|
+
if (policy2.to && typeof policy2.to === "string") {
|
19507
|
+
mappedTo.push(policy2.to);
|
19508
|
+
} else if (policy2.to && (0, import_drizzle_orm5.is)(policy2.to, import_pg_core2.PgRole)) {
|
19509
|
+
mappedTo.push(policy2.to.name);
|
19510
|
+
} else if (policy2.to && Array.isArray(policy2.to)) {
|
19511
|
+
policy2.to.forEach((it) => {
|
19512
|
+
if (typeof it === "string") {
|
19513
|
+
mappedTo.push(it);
|
19514
|
+
} else if ((0, import_drizzle_orm5.is)(it, import_pg_core2.PgRole)) {
|
19515
|
+
mappedTo.push(it.name);
|
19516
|
+
}
|
19517
|
+
});
|
19518
|
+
}
|
19519
|
+
}
|
19520
|
+
if (result[tableKey2].policies[policy2.name] !== void 0) {
|
19521
|
+
console.log(
|
19522
|
+
`
|
19523
|
+
${withStyle.errorWarning(
|
19524
|
+
`We've found duplicated policy name across ${source_default.underline.blue(tableKey2)} table. Please rename one of the policies with ${source_default.underline.blue(
|
19525
|
+
policy2.name
|
19526
|
+
)} name`
|
19527
|
+
)}`
|
19528
|
+
);
|
19529
|
+
process.exit(1);
|
19530
|
+
}
|
19531
|
+
result[tableKey2].policies[policy2.name] = {
|
19532
|
+
name: policy2.name,
|
19533
|
+
as: ((_a = policy2.as) == null ? void 0 : _a.toUpperCase()) ?? "PERMISSIVE",
|
19534
|
+
for: ((_b = policy2.for) == null ? void 0 : _b.toUpperCase()) ?? "ALL",
|
19535
|
+
to: mappedTo.sort(),
|
19536
|
+
using: (0, import_drizzle_orm5.is)(policy2.using, import_drizzle_orm5.SQL) ? dialect4.sqlToQuery(policy2.using).sql : void 0,
|
19537
|
+
withCheck: (0, import_drizzle_orm5.is)(policy2.withCheck, import_drizzle_orm5.SQL) ? dialect4.sqlToQuery(policy2.withCheck).sql : void 0
|
19278
19538
|
};
|
19279
19539
|
}
|
19280
19540
|
for (const sequence of sequences) {
|
19281
19541
|
const name = sequence.seqName;
|
19282
19542
|
if (typeof sequencesToReturn[`${sequence.schema ?? "public"}.${name}`] === "undefined") {
|
19283
|
-
const increment = stringFromIdentityProperty((
|
19284
|
-
const minValue = stringFromIdentityProperty((
|
19285
|
-
const maxValue = stringFromIdentityProperty((
|
19286
|
-
const startWith = stringFromIdentityProperty((
|
19287
|
-
const cache = stringFromIdentityProperty((
|
19543
|
+
const increment = stringFromIdentityProperty((_c = sequence == null ? void 0 : sequence.seqOptions) == null ? void 0 : _c.increment) ?? "1";
|
19544
|
+
const minValue = stringFromIdentityProperty((_d = sequence == null ? void 0 : sequence.seqOptions) == null ? void 0 : _d.minValue) ?? (parseFloat(increment) < 0 ? "-9223372036854775808" : "1");
|
19545
|
+
const maxValue = stringFromIdentityProperty((_e = sequence == null ? void 0 : sequence.seqOptions) == null ? void 0 : _e.maxValue) ?? (parseFloat(increment) < 0 ? "-1" : "9223372036854775807");
|
19546
|
+
const startWith = stringFromIdentityProperty((_f = sequence == null ? void 0 : sequence.seqOptions) == null ? void 0 : _f.startWith) ?? (parseFloat(increment) < 0 ? maxValue : minValue);
|
19547
|
+
const cache = stringFromIdentityProperty((_g = sequence == null ? void 0 : sequence.seqOptions) == null ? void 0 : _g.cache) ?? "1";
|
19288
19548
|
sequencesToReturn[`${sequence.schema ?? "public"}.${name}`] = {
|
19289
19549
|
name,
|
19290
19550
|
schema: sequence.schema ?? "public",
|
@@ -19293,11 +19553,21 @@ ${withStyle.errorWarning(
|
|
19293
19553
|
minValue,
|
19294
19554
|
maxValue,
|
19295
19555
|
cache,
|
19296
|
-
cycle: ((
|
19556
|
+
cycle: ((_h = sequence.seqOptions) == null ? void 0 : _h.cycle) ?? false
|
19297
19557
|
};
|
19298
19558
|
} else {
|
19299
19559
|
}
|
19300
19560
|
}
|
19561
|
+
for (const role of roles) {
|
19562
|
+
if (!role._existing) {
|
19563
|
+
rolesToReturn[role.name] = {
|
19564
|
+
name: role.name,
|
19565
|
+
createDb: role.createDb === void 0 ? false : role.createDb,
|
19566
|
+
createRole: role.createRole === void 0 ? false : role.createRole,
|
19567
|
+
inherit: role.inherit === void 0 ? true : role.inherit
|
19568
|
+
};
|
19569
|
+
}
|
19570
|
+
}
|
19301
19571
|
const combinedViews = [...views, ...matViews];
|
19302
19572
|
for (const view4 of combinedViews) {
|
19303
19573
|
let viewName;
|
@@ -19339,11 +19609,11 @@ ${withStyle.errorWarning(
|
|
19339
19609
|
const typeSchema = (0, import_drizzle_orm5.is)(column7, import_pg_core2.PgEnumColumn) ? column7.enum.schema || "public" : void 0;
|
19340
19610
|
const generated = column7.generated;
|
19341
19611
|
const identity = column7.generatedIdentity;
|
19342
|
-
const increment = stringFromIdentityProperty((
|
19343
|
-
const minValue = stringFromIdentityProperty((
|
19344
|
-
const maxValue = stringFromIdentityProperty((
|
19345
|
-
const startWith = stringFromIdentityProperty((
|
19346
|
-
const cache = stringFromIdentityProperty((
|
19612
|
+
const increment = stringFromIdentityProperty((_i = identity == null ? void 0 : identity.sequenceOptions) == null ? void 0 : _i.increment) ?? "1";
|
19613
|
+
const minValue = stringFromIdentityProperty((_j = identity == null ? void 0 : identity.sequenceOptions) == null ? void 0 : _j.minValue) ?? (parseFloat(increment) < 0 ? minRangeForIdentityBasedOn(column7.columnType) : "1");
|
19614
|
+
const maxValue = stringFromIdentityProperty((_k = identity == null ? void 0 : identity.sequenceOptions) == null ? void 0 : _k.maxValue) ?? (parseFloat(increment) < 0 ? "-1" : maxRangeForIdentityBasedOn(column7.getSQLType()));
|
19615
|
+
const startWith = stringFromIdentityProperty((_l = identity == null ? void 0 : identity.sequenceOptions) == null ? void 0 : _l.startWith) ?? (parseFloat(increment) < 0 ? maxValue : minValue);
|
19616
|
+
const cache = stringFromIdentityProperty((_m = identity == null ? void 0 : identity.sequenceOptions) == null ? void 0 : _m.cache) ?? "1";
|
19347
19617
|
const columnToSet = {
|
19348
19618
|
name: column7.name,
|
19349
19619
|
type: column7.getSQLType(),
|
@@ -19363,7 +19633,7 @@ ${withStyle.errorWarning(
|
|
19363
19633
|
minValue,
|
19364
19634
|
maxValue,
|
19365
19635
|
cache,
|
19366
|
-
cycle: ((
|
19636
|
+
cycle: ((_n = identity == null ? void 0 : identity.sequenceOptions) == null ? void 0 : _n.cycle) ?? false
|
19367
19637
|
} : void 0
|
19368
19638
|
};
|
19369
19639
|
if (column7.isUnique) {
|
@@ -19454,6 +19724,7 @@ ${withStyle.errorWarning(
|
|
19454
19724
|
enums: enumsToReturn,
|
19455
19725
|
schemas: schemasObject,
|
19456
19726
|
sequences: sequencesToReturn,
|
19727
|
+
roles: rolesToReturn,
|
19457
19728
|
views: resultViews,
|
19458
19729
|
_meta: {
|
19459
19730
|
schemas: {},
|
@@ -19471,7 +19742,7 @@ ${withStyle.errorWarning(
|
|
19471
19742
|
--end;
|
19472
19743
|
return start > 0 || end < str.length ? str.substring(start, end) : str.toString();
|
19473
19744
|
};
|
19474
|
-
fromDatabase2 = async (db, tablesFilter = () => true, schemaFilters, progressCallback) => {
|
19745
|
+
fromDatabase2 = async (db, tablesFilter = () => true, schemaFilters, entities, progressCallback) => {
|
19475
19746
|
const result = {};
|
19476
19747
|
const views = {};
|
19477
19748
|
const internals = { tables: {} };
|
@@ -19484,7 +19755,8 @@ ${withStyle.errorWarning(
|
|
19484
19755
|
WHEN c.relkind = 'r' THEN 'table'
|
19485
19756
|
WHEN c.relkind = 'v' THEN 'view'
|
19486
19757
|
WHEN c.relkind = 'm' THEN 'materialized_view'
|
19487
|
-
END AS type
|
19758
|
+
END AS type,
|
19759
|
+
c.relrowsecurity AS rls_enabled
|
19488
19760
|
FROM
|
19489
19761
|
pg_catalog.pg_class c
|
19490
19762
|
JOIN
|
@@ -19570,6 +19842,64 @@ WHERE
|
|
19570
19842
|
if (progressCallback) {
|
19571
19843
|
progressCallback("enums", Object.keys(enumsToReturn).length, "done");
|
19572
19844
|
}
|
19845
|
+
const allRoles = await db.query(
|
19846
|
+
`SELECT rolname, rolinherit, rolcreatedb, rolcreaterole FROM pg_roles;`
|
19847
|
+
);
|
19848
|
+
const rolesToReturn = {};
|
19849
|
+
const preparedRoles = prepareRoles(entities);
|
19850
|
+
if (preparedRoles.useRoles || !(preparedRoles.includeRoles.length === 0 && preparedRoles.excludeRoles.length === 0)) {
|
19851
|
+
for (const dbRole of allRoles) {
|
19852
|
+
if (preparedRoles.useRoles) {
|
19853
|
+
rolesToReturn[dbRole.rolname] = {
|
19854
|
+
createDb: dbRole.rolcreatedb,
|
19855
|
+
createRole: dbRole.rolcreatedb,
|
19856
|
+
inherit: dbRole.rolinherit,
|
19857
|
+
name: dbRole.rolname
|
19858
|
+
};
|
19859
|
+
} else {
|
19860
|
+
if (preparedRoles.includeRoles.length === 0 && preparedRoles.excludeRoles.length === 0)
|
19861
|
+
continue;
|
19862
|
+
if (preparedRoles.includeRoles.includes(dbRole.rolname) && preparedRoles.excludeRoles.includes(dbRole.rolname))
|
19863
|
+
continue;
|
19864
|
+
if (preparedRoles.excludeRoles.includes(dbRole.rolname))
|
19865
|
+
continue;
|
19866
|
+
if (!preparedRoles.includeRoles.includes(dbRole.rolname))
|
19867
|
+
continue;
|
19868
|
+
rolesToReturn[dbRole.rolname] = {
|
19869
|
+
createDb: dbRole.rolcreatedb,
|
19870
|
+
createRole: dbRole.rolcreaterole,
|
19871
|
+
inherit: dbRole.rolinherit,
|
19872
|
+
name: dbRole.rolname
|
19873
|
+
};
|
19874
|
+
}
|
19875
|
+
}
|
19876
|
+
}
|
19877
|
+
const wherePolicies = schemaFilters.map((t2) => `schemaname = '${t2}'`).join(" or ");
|
19878
|
+
const policiesByTable = {};
|
19879
|
+
const allPolicies = await db.query(`SELECT schemaname, tablename, policyname as name, permissive as "as", roles as to, cmd as for, qual as using, with_check as "withCheck" FROM pg_policies${wherePolicies === "" ? "" : ` WHERE ${wherePolicies}`};`);
|
19880
|
+
for (const dbPolicy of allPolicies) {
|
19881
|
+
const { tablename, schemaname, to, withCheck, using, ...rest } = dbPolicy;
|
19882
|
+
const tableForPolicy = policiesByTable[`${schemaname}.${tablename}`];
|
19883
|
+
const parsedTo = to;
|
19884
|
+
const parsedWithCheck = withCheck === null ? void 0 : withCheck;
|
19885
|
+
const parsedUsing = using === null ? void 0 : using;
|
19886
|
+
if (tableForPolicy) {
|
19887
|
+
tableForPolicy[dbPolicy.name] = { ...rest, to: parsedTo };
|
19888
|
+
} else {
|
19889
|
+
policiesByTable[`${schemaname}.${tablename}`] = {
|
19890
|
+
[dbPolicy.name]: { ...rest, to: parsedTo, withCheck: parsedWithCheck, using: parsedUsing }
|
19891
|
+
};
|
19892
|
+
}
|
19893
|
+
}
|
19894
|
+
if (progressCallback) {
|
19895
|
+
progressCallback(
|
19896
|
+
"policies",
|
19897
|
+
Object.values(policiesByTable).reduce((total, innerRecord) => {
|
19898
|
+
return total + Object.keys(innerRecord).length;
|
19899
|
+
}, 0),
|
19900
|
+
"done"
|
19901
|
+
);
|
19902
|
+
}
|
19573
19903
|
const sequencesInColumns = [];
|
19574
19904
|
const all = allTables.filter((it) => it.type === "table").map((row) => {
|
19575
19905
|
return new Promise(async (res, rej) => {
|
@@ -19934,7 +20264,7 @@ WHERE
|
|
19934
20264
|
}
|
19935
20265
|
],
|
19936
20266
|
isUnique: indexIsUnique,
|
19937
|
-
// should not be a part of diff
|
20267
|
+
// should not be a part of diff detects
|
19938
20268
|
concurrently: false,
|
19939
20269
|
method: indexMethod,
|
19940
20270
|
where: indexWhere === null ? void 0 : indexWhere,
|
@@ -19954,7 +20284,9 @@ WHERE
|
|
19954
20284
|
foreignKeys: foreignKeysToReturn,
|
19955
20285
|
compositePrimaryKeys: primaryKeys,
|
19956
20286
|
uniqueConstraints: uniqueConstrains,
|
19957
|
-
checkConstraints
|
20287
|
+
checkConstraints,
|
20288
|
+
policies: policiesByTable[`${tableSchema}.${tableName}`] ?? {},
|
20289
|
+
isRLSEnabled: row.rls_enabled
|
19958
20290
|
};
|
19959
20291
|
} catch (e2) {
|
19960
20292
|
rej(e2);
|
@@ -20154,6 +20486,7 @@ WHERE
|
|
20154
20486
|
enums: enumsToReturn,
|
20155
20487
|
schemas: schemasObject,
|
20156
20488
|
sequences: sequencesToReturn,
|
20489
|
+
roles: rolesToReturn,
|
20157
20490
|
views,
|
20158
20491
|
_meta: {
|
20159
20492
|
schemas: {},
|
@@ -21063,10 +21396,10 @@ ${filenames.join("\n")}
|
|
21063
21396
|
const filenames = prepareFilenames(path5);
|
21064
21397
|
const { prepareFromPgImports: prepareFromPgImports2 } = await Promise.resolve().then(() => (init_pgImports(), pgImports_exports));
|
21065
21398
|
const { generatePgSnapshot: generatePgSnapshot2 } = await Promise.resolve().then(() => (init_pgSerializer(), pgSerializer_exports));
|
21066
|
-
const { tables, enums, schemas, sequences, views, matViews } = await prepareFromPgImports2(
|
21399
|
+
const { tables, enums, schemas, sequences, views, matViews, roles, policies } = await prepareFromPgImports2(
|
21067
21400
|
filenames
|
21068
21401
|
);
|
21069
|
-
return generatePgSnapshot2(tables, enums, schemas, sequences, views, matViews, casing2, schemaFilter);
|
21402
|
+
return generatePgSnapshot2(tables, enums, schemas, sequences, roles, policies, views, matViews, casing2, schemaFilter);
|
21070
21403
|
};
|
21071
21404
|
serializeSQLite = async (path5, casing2) => {
|
21072
21405
|
const filenames = prepareFilenames(path5);
|
@@ -21261,57 +21594,57 @@ var require_heap = __commonJS({
|
|
21261
21594
|
}
|
21262
21595
|
return [].splice.apply(a, [lo, lo - lo].concat(x2)), x2;
|
21263
21596
|
};
|
21264
|
-
heappush = function(
|
21597
|
+
heappush = function(array2, item, cmp) {
|
21265
21598
|
if (cmp == null) {
|
21266
21599
|
cmp = defaultCmp;
|
21267
21600
|
}
|
21268
|
-
|
21269
|
-
return _siftdown(
|
21601
|
+
array2.push(item);
|
21602
|
+
return _siftdown(array2, 0, array2.length - 1, cmp);
|
21270
21603
|
};
|
21271
|
-
heappop = function(
|
21604
|
+
heappop = function(array2, cmp) {
|
21272
21605
|
var lastelt, returnitem;
|
21273
21606
|
if (cmp == null) {
|
21274
21607
|
cmp = defaultCmp;
|
21275
21608
|
}
|
21276
|
-
lastelt =
|
21277
|
-
if (
|
21278
|
-
returnitem =
|
21279
|
-
|
21280
|
-
_siftup(
|
21609
|
+
lastelt = array2.pop();
|
21610
|
+
if (array2.length) {
|
21611
|
+
returnitem = array2[0];
|
21612
|
+
array2[0] = lastelt;
|
21613
|
+
_siftup(array2, 0, cmp);
|
21281
21614
|
} else {
|
21282
21615
|
returnitem = lastelt;
|
21283
21616
|
}
|
21284
21617
|
return returnitem;
|
21285
21618
|
};
|
21286
|
-
heapreplace = function(
|
21619
|
+
heapreplace = function(array2, item, cmp) {
|
21287
21620
|
var returnitem;
|
21288
21621
|
if (cmp == null) {
|
21289
21622
|
cmp = defaultCmp;
|
21290
21623
|
}
|
21291
|
-
returnitem =
|
21292
|
-
|
21293
|
-
_siftup(
|
21624
|
+
returnitem = array2[0];
|
21625
|
+
array2[0] = item;
|
21626
|
+
_siftup(array2, 0, cmp);
|
21294
21627
|
return returnitem;
|
21295
21628
|
};
|
21296
|
-
heappushpop = function(
|
21629
|
+
heappushpop = function(array2, item, cmp) {
|
21297
21630
|
var _ref;
|
21298
21631
|
if (cmp == null) {
|
21299
21632
|
cmp = defaultCmp;
|
21300
21633
|
}
|
21301
|
-
if (
|
21302
|
-
_ref = [
|
21303
|
-
_siftup(
|
21634
|
+
if (array2.length && cmp(array2[0], item) < 0) {
|
21635
|
+
_ref = [array2[0], item], item = _ref[0], array2[0] = _ref[1];
|
21636
|
+
_siftup(array2, 0, cmp);
|
21304
21637
|
}
|
21305
21638
|
return item;
|
21306
21639
|
};
|
21307
|
-
heapify = function(
|
21640
|
+
heapify = function(array2, cmp) {
|
21308
21641
|
var i2, _i, _j, _len, _ref, _ref1, _results, _results1;
|
21309
21642
|
if (cmp == null) {
|
21310
21643
|
cmp = defaultCmp;
|
21311
21644
|
}
|
21312
21645
|
_ref1 = function() {
|
21313
21646
|
_results1 = [];
|
21314
|
-
for (var _j2 = 0, _ref2 = floor(
|
21647
|
+
for (var _j2 = 0, _ref2 = floor(array2.length / 2); 0 <= _ref2 ? _j2 < _ref2 : _j2 > _ref2; 0 <= _ref2 ? _j2++ : _j2--) {
|
21315
21648
|
_results1.push(_j2);
|
21316
21649
|
}
|
21317
21650
|
return _results1;
|
@@ -21319,51 +21652,51 @@ var require_heap = __commonJS({
|
|
21319
21652
|
_results = [];
|
21320
21653
|
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
21321
21654
|
i2 = _ref1[_i];
|
21322
|
-
_results.push(_siftup(
|
21655
|
+
_results.push(_siftup(array2, i2, cmp));
|
21323
21656
|
}
|
21324
21657
|
return _results;
|
21325
21658
|
};
|
21326
|
-
updateItem = function(
|
21659
|
+
updateItem = function(array2, item, cmp) {
|
21327
21660
|
var pos;
|
21328
21661
|
if (cmp == null) {
|
21329
21662
|
cmp = defaultCmp;
|
21330
21663
|
}
|
21331
|
-
pos =
|
21664
|
+
pos = array2.indexOf(item);
|
21332
21665
|
if (pos === -1) {
|
21333
21666
|
return;
|
21334
21667
|
}
|
21335
|
-
_siftdown(
|
21336
|
-
return _siftup(
|
21668
|
+
_siftdown(array2, 0, pos, cmp);
|
21669
|
+
return _siftup(array2, pos, cmp);
|
21337
21670
|
};
|
21338
|
-
nlargest = function(
|
21671
|
+
nlargest = function(array2, n, cmp) {
|
21339
21672
|
var elem, result, _i, _len, _ref;
|
21340
21673
|
if (cmp == null) {
|
21341
21674
|
cmp = defaultCmp;
|
21342
21675
|
}
|
21343
|
-
result =
|
21676
|
+
result = array2.slice(0, n);
|
21344
21677
|
if (!result.length) {
|
21345
21678
|
return result;
|
21346
21679
|
}
|
21347
21680
|
heapify(result, cmp);
|
21348
|
-
_ref =
|
21681
|
+
_ref = array2.slice(n);
|
21349
21682
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
21350
21683
|
elem = _ref[_i];
|
21351
21684
|
heappushpop(result, elem, cmp);
|
21352
21685
|
}
|
21353
21686
|
return result.sort(cmp).reverse();
|
21354
21687
|
};
|
21355
|
-
nsmallest = function(
|
21688
|
+
nsmallest = function(array2, n, cmp) {
|
21356
21689
|
var elem, i2, los, result, _i, _j, _len, _ref, _ref1, _results;
|
21357
21690
|
if (cmp == null) {
|
21358
21691
|
cmp = defaultCmp;
|
21359
21692
|
}
|
21360
|
-
if (n * 10 <=
|
21361
|
-
result =
|
21693
|
+
if (n * 10 <= array2.length) {
|
21694
|
+
result = array2.slice(0, n).sort(cmp);
|
21362
21695
|
if (!result.length) {
|
21363
21696
|
return result;
|
21364
21697
|
}
|
21365
21698
|
los = result[result.length - 1];
|
21366
|
-
_ref =
|
21699
|
+
_ref = array2.slice(n);
|
21367
21700
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
21368
21701
|
elem = _ref[_i];
|
21369
21702
|
if (cmp(elem, los) < 0) {
|
@@ -21374,51 +21707,51 @@ var require_heap = __commonJS({
|
|
21374
21707
|
}
|
21375
21708
|
return result;
|
21376
21709
|
}
|
21377
|
-
heapify(
|
21710
|
+
heapify(array2, cmp);
|
21378
21711
|
_results = [];
|
21379
|
-
for (i2 = _j = 0, _ref1 = min(n,
|
21380
|
-
_results.push(heappop(
|
21712
|
+
for (i2 = _j = 0, _ref1 = min(n, array2.length); 0 <= _ref1 ? _j < _ref1 : _j > _ref1; i2 = 0 <= _ref1 ? ++_j : --_j) {
|
21713
|
+
_results.push(heappop(array2, cmp));
|
21381
21714
|
}
|
21382
21715
|
return _results;
|
21383
21716
|
};
|
21384
|
-
_siftdown = function(
|
21717
|
+
_siftdown = function(array2, startpos, pos, cmp) {
|
21385
21718
|
var newitem, parent, parentpos;
|
21386
21719
|
if (cmp == null) {
|
21387
21720
|
cmp = defaultCmp;
|
21388
21721
|
}
|
21389
|
-
newitem =
|
21722
|
+
newitem = array2[pos];
|
21390
21723
|
while (pos > startpos) {
|
21391
21724
|
parentpos = pos - 1 >> 1;
|
21392
|
-
parent =
|
21725
|
+
parent = array2[parentpos];
|
21393
21726
|
if (cmp(newitem, parent) < 0) {
|
21394
|
-
|
21727
|
+
array2[pos] = parent;
|
21395
21728
|
pos = parentpos;
|
21396
21729
|
continue;
|
21397
21730
|
}
|
21398
21731
|
break;
|
21399
21732
|
}
|
21400
|
-
return
|
21733
|
+
return array2[pos] = newitem;
|
21401
21734
|
};
|
21402
|
-
_siftup = function(
|
21735
|
+
_siftup = function(array2, pos, cmp) {
|
21403
21736
|
var childpos, endpos, newitem, rightpos, startpos;
|
21404
21737
|
if (cmp == null) {
|
21405
21738
|
cmp = defaultCmp;
|
21406
21739
|
}
|
21407
|
-
endpos =
|
21740
|
+
endpos = array2.length;
|
21408
21741
|
startpos = pos;
|
21409
|
-
newitem =
|
21742
|
+
newitem = array2[pos];
|
21410
21743
|
childpos = 2 * pos + 1;
|
21411
21744
|
while (childpos < endpos) {
|
21412
21745
|
rightpos = childpos + 1;
|
21413
|
-
if (rightpos < endpos && !(cmp(
|
21746
|
+
if (rightpos < endpos && !(cmp(array2[childpos], array2[rightpos]) < 0)) {
|
21414
21747
|
childpos = rightpos;
|
21415
21748
|
}
|
21416
|
-
|
21749
|
+
array2[pos] = array2[childpos];
|
21417
21750
|
pos = childpos;
|
21418
21751
|
childpos = 2 * pos + 1;
|
21419
21752
|
}
|
21420
|
-
|
21421
|
-
return _siftdown(
|
21753
|
+
array2[pos] = newitem;
|
21754
|
+
return _siftdown(array2, startpos, pos, cmp);
|
21422
21755
|
};
|
21423
21756
|
Heap = function() {
|
21424
21757
|
Heap2.push = heappush;
|
@@ -23331,12 +23664,12 @@ var require_lib = __commonJS({
|
|
23331
23664
|
}
|
23332
23665
|
return bestMatch;
|
23333
23666
|
}
|
23334
|
-
scalarize(
|
23667
|
+
scalarize(array2, originals, fuzzyOriginals) {
|
23335
23668
|
const fuzzyMatches = [];
|
23336
23669
|
if (fuzzyOriginals) {
|
23337
23670
|
const keyScores = {};
|
23338
|
-
for (let index4 = 0; index4 <
|
23339
|
-
const item =
|
23671
|
+
for (let index4 = 0; index4 < array2.length; index4++) {
|
23672
|
+
const item = array2[index4];
|
23340
23673
|
if (this.isScalar(item)) {
|
23341
23674
|
continue;
|
23342
23675
|
}
|
@@ -23350,8 +23683,8 @@ var require_lib = __commonJS({
|
|
23350
23683
|
}
|
23351
23684
|
}
|
23352
23685
|
const result = [];
|
23353
|
-
for (let index4 = 0; index4 <
|
23354
|
-
const item =
|
23686
|
+
for (let index4 = 0; index4 < array2.length; index4++) {
|
23687
|
+
const item = array2[index4];
|
23355
23688
|
if (this.isScalar(item)) {
|
23356
23689
|
result.push(item);
|
23357
23690
|
} else {
|
@@ -23573,6 +23906,37 @@ function diffColumns(left, right) {
|
|
23573
23906
|
);
|
23574
23907
|
return alteredTables;
|
23575
23908
|
}
|
23909
|
+
function diffPolicies(left, right) {
|
23910
|
+
left = JSON.parse(JSON.stringify(left));
|
23911
|
+
right = JSON.parse(JSON.stringify(right));
|
23912
|
+
const result = (0, import_json_diff.diff)(left, right) ?? {};
|
23913
|
+
const alteredTables = Object.fromEntries(
|
23914
|
+
Object.entries(result).filter((it) => {
|
23915
|
+
return !(it[0].includes("__added") || it[0].includes("__deleted"));
|
23916
|
+
}).map((tableEntry) => {
|
23917
|
+
const deletedPolicies = Object.entries(tableEntry[1].policies ?? {}).filter((it) => {
|
23918
|
+
return it[0].endsWith("__deleted");
|
23919
|
+
}).map((it) => {
|
23920
|
+
return it[1];
|
23921
|
+
});
|
23922
|
+
const addedPolicies = Object.entries(tableEntry[1].policies ?? {}).filter((it) => {
|
23923
|
+
return it[0].endsWith("__added");
|
23924
|
+
}).map((it) => {
|
23925
|
+
return it[1];
|
23926
|
+
});
|
23927
|
+
tableEntry[1].policies = {
|
23928
|
+
added: addedPolicies,
|
23929
|
+
deleted: deletedPolicies
|
23930
|
+
};
|
23931
|
+
const table4 = left[tableEntry[0]];
|
23932
|
+
return [
|
23933
|
+
tableEntry[0],
|
23934
|
+
{ name: table4.name, schema: table4.schema, ...tableEntry[1] }
|
23935
|
+
];
|
23936
|
+
})
|
23937
|
+
);
|
23938
|
+
return alteredTables;
|
23939
|
+
}
|
23576
23940
|
function applyJsonDiff(json1, json2) {
|
23577
23941
|
json1 = JSON.parse(JSON.stringify(json1));
|
23578
23942
|
json2 = JSON.parse(JSON.stringify(json2));
|
@@ -23582,6 +23946,7 @@ function applyJsonDiff(json1, json2) {
|
|
23582
23946
|
difference.tables = difference.tables || {};
|
23583
23947
|
difference.enums = difference.enums || {};
|
23584
23948
|
difference.sequences = difference.sequences || {};
|
23949
|
+
difference.roles = difference.roles || {};
|
23585
23950
|
difference.views = difference.views || {};
|
23586
23951
|
const schemaKeys = Object.keys(difference.schemas);
|
23587
23952
|
for (let key of schemaKeys) {
|
@@ -23638,6 +24003,10 @@ function applyJsonDiff(json1, json2) {
|
|
23638
24003
|
const alteredSequences = sequencesEntries.filter((it) => !(it[0].includes("__added") || it[0].includes("__deleted")) && "values" in it[1]).map((it) => {
|
23639
24004
|
return json2.sequences[it[0]];
|
23640
24005
|
});
|
24006
|
+
const rolesEntries = Object.entries(difference.roles);
|
24007
|
+
const alteredRoles = rolesEntries.filter((it) => !(it[0].includes("__added") || it[0].includes("__deleted"))).map((it) => {
|
24008
|
+
return json2.roles[it[0]];
|
24009
|
+
});
|
23641
24010
|
const viewsEntries = Object.entries(difference.views);
|
23642
24011
|
const alteredViews = viewsEntries.filter((it) => !(it[0].includes("__added") || it[0].includes("__deleted"))).map(
|
23643
24012
|
([nameWithSchema, view4]) => {
|
@@ -23717,6 +24086,7 @@ function applyJsonDiff(json1, json2) {
|
|
23717
24086
|
alteredTablesWithColumns,
|
23718
24087
|
alteredEnums,
|
23719
24088
|
alteredSequences,
|
24089
|
+
alteredRoles,
|
23720
24090
|
alteredViews
|
23721
24091
|
};
|
23722
24092
|
}
|
@@ -23777,6 +24147,21 @@ var init_jsonDiffer = __esm({
|
|
23777
24147
|
return !it[0].endsWith("__deleted") && !it[0].endsWith("__added");
|
23778
24148
|
})
|
23779
24149
|
);
|
24150
|
+
const deletedPolicies = Object.fromEntries(
|
24151
|
+
Object.entries(table4.policies__deleted || {}).concat(
|
24152
|
+
Object.entries(table4.policies || {}).filter((it) => it[0].includes("__deleted"))
|
24153
|
+
).map((entry) => [entry[0].replace("__deleted", ""), entry[1]])
|
24154
|
+
);
|
24155
|
+
const addedPolicies = Object.fromEntries(
|
24156
|
+
Object.entries(table4.policies__added || {}).concat(
|
24157
|
+
Object.entries(table4.policies || {}).filter((it) => it[0].includes("__added"))
|
24158
|
+
).map((entry) => [entry[0].replace("__added", ""), entry[1]])
|
24159
|
+
);
|
24160
|
+
const alteredPolicies = Object.fromEntries(
|
24161
|
+
Object.entries(table4.policies || {}).filter((it) => {
|
24162
|
+
return !it[0].endsWith("__deleted") && !it[0].endsWith("__added");
|
24163
|
+
})
|
24164
|
+
);
|
23780
24165
|
const deletedForeignKeys = Object.fromEntries(
|
23781
24166
|
Object.entries(table4.foreignKeys__deleted || {}).concat(
|
23782
24167
|
Object.entries(table4.foreignKeys || {}).filter((it) => it[0].includes("__deleted"))
|
@@ -23854,6 +24239,9 @@ var init_jsonDiffer = __esm({
|
|
23854
24239
|
addedUniqueConstraints,
|
23855
24240
|
deletedUniqueConstraints,
|
23856
24241
|
alteredUniqueConstraints,
|
24242
|
+
deletedPolicies,
|
24243
|
+
addedPolicies,
|
24244
|
+
alteredPolicies,
|
23857
24245
|
addedCheckConstraints,
|
23858
24246
|
deletedCheckConstraints,
|
23859
24247
|
alteredCheckConstraints
|
@@ -24156,7 +24544,7 @@ function fromJson(statements, dialect4, action, json2) {
|
|
24156
24544
|
}).filter((it) => it !== "");
|
24157
24545
|
return result;
|
24158
24546
|
}
|
24159
|
-
var pgNativeTypes, isPgNativeType, Convertor, 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;
|
24547
|
+
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;
|
24160
24548
|
var init_sqlgenerator = __esm({
|
24161
24549
|
"src/sqlgenerator.ts"() {
|
24162
24550
|
"use strict";
|
@@ -24213,12 +24601,110 @@ var init_sqlgenerator = __esm({
|
|
24213
24601
|
};
|
24214
24602
|
Convertor = class {
|
24215
24603
|
};
|
24604
|
+
PgCreateRoleConvertor = class extends Convertor {
|
24605
|
+
can(statement, dialect4) {
|
24606
|
+
return statement.type === "create_role" && dialect4 === "postgresql";
|
24607
|
+
}
|
24608
|
+
convert(statement) {
|
24609
|
+
return `CREATE ROLE "${statement.name}"${statement.values.createDb || statement.values.createRole || !statement.values.inherit ? ` WITH${statement.values.createDb ? " CREATEDB" : ""}${statement.values.createRole ? " CREATEROLE" : ""}${statement.values.inherit ? "" : " NOINHERIT"}` : ""};`;
|
24610
|
+
}
|
24611
|
+
};
|
24612
|
+
PgDropRoleConvertor = class extends Convertor {
|
24613
|
+
can(statement, dialect4) {
|
24614
|
+
return statement.type === "drop_role" && dialect4 === "postgresql";
|
24615
|
+
}
|
24616
|
+
convert(statement) {
|
24617
|
+
return `DROP ROLE "${statement.name}";`;
|
24618
|
+
}
|
24619
|
+
};
|
24620
|
+
PgRenameRoleConvertor = class extends Convertor {
|
24621
|
+
can(statement, dialect4) {
|
24622
|
+
return statement.type === "rename_role" && dialect4 === "postgresql";
|
24623
|
+
}
|
24624
|
+
convert(statement) {
|
24625
|
+
return `ALTER ROLE "${statement.nameFrom}" RENAME TO "${statement.nameTo}";`;
|
24626
|
+
}
|
24627
|
+
};
|
24628
|
+
PgAlterRoleConvertor = class extends Convertor {
|
24629
|
+
can(statement, dialect4) {
|
24630
|
+
return statement.type === "alter_role" && dialect4 === "postgresql";
|
24631
|
+
}
|
24632
|
+
convert(statement) {
|
24633
|
+
return `ALTER ROLE "${statement.name}"${` WITH${statement.values.createDb ? " CREATEDB" : " NOCREATEDB"}${statement.values.createRole ? " CREATEROLE" : " NOCREATEROLE"}${statement.values.inherit ? " INHERIT" : " NOINHERIT"}`};`;
|
24634
|
+
}
|
24635
|
+
};
|
24636
|
+
PgCreatePolicyConvertor = class extends Convertor {
|
24637
|
+
can(statement, dialect4) {
|
24638
|
+
return statement.type === "create_policy" && dialect4 === "postgresql";
|
24639
|
+
}
|
24640
|
+
convert(statement) {
|
24641
|
+
var _a, _b, _c;
|
24642
|
+
const policy2 = statement.data;
|
24643
|
+
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
24644
|
+
const usingPart = policy2.using ? ` USING (${policy2.using})` : "";
|
24645
|
+
const withCheckPart = policy2.withCheck ? ` WITH CHECK (${policy2.withCheck})` : "";
|
24646
|
+
const policyToPart = (_a = policy2.to) == null ? void 0 : _a.map(
|
24647
|
+
(v) => ["current_user", "current_role", "session_user", "public"].includes(v) ? v : `"${v}"`
|
24648
|
+
).join(", ");
|
24649
|
+
return `CREATE POLICY "${policy2.name}" ON ${tableNameWithSchema} AS ${(_b = policy2.as) == null ? void 0 : _b.toUpperCase()} FOR ${(_c = policy2.for) == null ? void 0 : _c.toUpperCase()} TO ${policyToPart}${usingPart}${withCheckPart};`;
|
24650
|
+
}
|
24651
|
+
};
|
24652
|
+
PgDropPolicyConvertor = class extends Convertor {
|
24653
|
+
can(statement, dialect4) {
|
24654
|
+
return statement.type === "drop_policy" && dialect4 === "postgresql";
|
24655
|
+
}
|
24656
|
+
convert(statement) {
|
24657
|
+
const policy2 = statement.data;
|
24658
|
+
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
24659
|
+
return `DROP POLICY "${policy2.name}" ON ${tableNameWithSchema} CASCADE;`;
|
24660
|
+
}
|
24661
|
+
};
|
24662
|
+
PgRenamePolicyConvertor = class extends Convertor {
|
24663
|
+
can(statement, dialect4) {
|
24664
|
+
return statement.type === "rename_policy" && dialect4 === "postgresql";
|
24665
|
+
}
|
24666
|
+
convert(statement) {
|
24667
|
+
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
24668
|
+
return `ALTER POLICY "${statement.oldName}" ON ${tableNameWithSchema} RENAME TO "${statement.newName}";`;
|
24669
|
+
}
|
24670
|
+
};
|
24671
|
+
PgAlterPolicyConvertor = class extends Convertor {
|
24672
|
+
can(statement, dialect4) {
|
24673
|
+
return statement.type === "alter_policy" && dialect4 === "postgresql";
|
24674
|
+
}
|
24675
|
+
convert(statement) {
|
24676
|
+
const newPolicy = PgSquasher.unsquashPolicy(statement.newData);
|
24677
|
+
const oldPolicy = PgSquasher.unsquashPolicy(statement.oldData);
|
24678
|
+
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
24679
|
+
const usingPart = newPolicy.using ? ` USING (${newPolicy.using})` : oldPolicy.using ? ` USING (${oldPolicy.using})` : "";
|
24680
|
+
const withCheckPart = newPolicy.withCheck ? ` WITH CHECK (${newPolicy.withCheck})` : oldPolicy.withCheck ? ` WITH CHECK (${oldPolicy.withCheck})` : "";
|
24681
|
+
return `ALTER POLICY "${oldPolicy.name}" ON ${tableNameWithSchema} TO ${newPolicy.to}${usingPart}${withCheckPart};`;
|
24682
|
+
}
|
24683
|
+
};
|
24684
|
+
PgEnableRlsConvertor = class extends Convertor {
|
24685
|
+
can(statement, dialect4) {
|
24686
|
+
return statement.type === "enable_rls" && dialect4 === "postgresql";
|
24687
|
+
}
|
24688
|
+
convert(statement) {
|
24689
|
+
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
24690
|
+
return `ALTER TABLE ${tableNameWithSchema} ENABLE ROW LEVEL SECURITY;`;
|
24691
|
+
}
|
24692
|
+
};
|
24693
|
+
PgDisableRlsConvertor = class extends Convertor {
|
24694
|
+
can(statement, dialect4) {
|
24695
|
+
return statement.type === "disable_rls" && dialect4 === "postgresql";
|
24696
|
+
}
|
24697
|
+
convert(statement) {
|
24698
|
+
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
24699
|
+
return `ALTER TABLE ${tableNameWithSchema} DISABLE ROW LEVEL SECURITY;`;
|
24700
|
+
}
|
24701
|
+
};
|
24216
24702
|
PgCreateTableConvertor = class extends Convertor {
|
24217
24703
|
can(statement, dialect4) {
|
24218
24704
|
return statement.type === "create_table" && dialect4 === "postgresql";
|
24219
24705
|
}
|
24220
24706
|
convert(st) {
|
24221
|
-
const { tableName, schema: schema5, columns, compositePKs, uniqueConstraints, checkConstraints } = st;
|
24707
|
+
const { tableName, schema: schema5, columns, compositePKs, uniqueConstraints, checkConstraints, policies, isRLSEnabled } = st;
|
24222
24708
|
let statement = "";
|
24223
24709
|
const name = schema5 ? `"${schema5}"."${tableName}"` : `"${tableName}"`;
|
24224
24710
|
statement += `CREATE TABLE IF NOT EXISTS ${name} (
|
@@ -24262,7 +24748,12 @@ var init_sqlgenerator = __esm({
|
|
24262
24748
|
);`;
|
24263
24749
|
statement += `
|
24264
24750
|
`;
|
24265
|
-
|
24751
|
+
const enableRls = new PgEnableRlsConvertor().convert({
|
24752
|
+
type: "enable_rls",
|
24753
|
+
tableName,
|
24754
|
+
schema: schema5
|
24755
|
+
});
|
24756
|
+
return [statement, ...policies && policies.length > 0 || isRLSEnabled ? [enableRls] : []];
|
24266
24757
|
}
|
24267
24758
|
};
|
24268
24759
|
MySqlCreateTableConvertor = class extends Convertor {
|
@@ -24867,9 +25358,21 @@ WITH ${withCheckOption} CHECK OPTION` : "";
|
|
24867
25358
|
return statement.type === "drop_table" && dialect4 === "postgresql";
|
24868
25359
|
}
|
24869
25360
|
convert(statement) {
|
24870
|
-
const { tableName, schema: schema5 } = statement;
|
25361
|
+
const { tableName, schema: schema5, policies } = statement;
|
24871
25362
|
const tableNameWithSchema = schema5 ? `"${schema5}"."${tableName}"` : `"${tableName}"`;
|
24872
|
-
|
25363
|
+
const dropPolicyConvertor = new PgDropPolicyConvertor();
|
25364
|
+
const droppedPolicies = (policies == null ? void 0 : policies.map((p2) => {
|
25365
|
+
return dropPolicyConvertor.convert({
|
25366
|
+
type: "drop_policy",
|
25367
|
+
tableName,
|
25368
|
+
data: PgSquasher.unsquashPolicy(p2),
|
25369
|
+
schema: schema5
|
25370
|
+
});
|
25371
|
+
})) ?? [];
|
25372
|
+
return [
|
25373
|
+
...droppedPolicies,
|
25374
|
+
`DROP TABLE ${tableNameWithSchema} CASCADE;`
|
25375
|
+
];
|
24873
25376
|
}
|
24874
25377
|
};
|
24875
25378
|
MySQLDropTableConvertor = class extends Convertor {
|
@@ -26074,6 +26577,16 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
26074
26577
|
convertors.push(new PgAlterTableAlterColumnDropNotNullConvertor());
|
26075
26578
|
convertors.push(new PgAlterTableAlterColumnSetDefaultConvertor());
|
26076
26579
|
convertors.push(new PgAlterTableAlterColumnDropDefaultConvertor());
|
26580
|
+
convertors.push(new PgAlterPolicyConvertor());
|
26581
|
+
convertors.push(new PgCreatePolicyConvertor());
|
26582
|
+
convertors.push(new PgDropPolicyConvertor());
|
26583
|
+
convertors.push(new PgRenamePolicyConvertor());
|
26584
|
+
convertors.push(new PgEnableRlsConvertor());
|
26585
|
+
convertors.push(new PgDisableRlsConvertor());
|
26586
|
+
convertors.push(new PgDropRoleConvertor());
|
26587
|
+
convertors.push(new PgAlterRoleConvertor());
|
26588
|
+
convertors.push(new PgCreateRoleConvertor());
|
26589
|
+
convertors.push(new PgRenameRoleConvertor());
|
26077
26590
|
convertors.push(new PgAlterTableAlterColumnSetExpressionConvertor());
|
26078
26591
|
convertors.push(new PgAlterTableAlterColumnDropGeneratedConvertor());
|
26079
26592
|
convertors.push(new PgAlterTableAlterColumnAlterrGeneratedConvertor());
|
@@ -26374,7 +26887,7 @@ var init_sqlitePushUtils = __esm({
|
|
26374
26887
|
});
|
26375
26888
|
|
26376
26889
|
// src/jsonStatements.ts
|
26377
|
-
var preparePgCreateTableJson, prepareMySqlCreateTableJson, prepareSQLiteCreateTable, prepareDropTableJson, prepareRenameTableJson, prepareCreateEnumJson, prepareAddValuesToEnumJson, prepareDropEnumValues, prepareDropEnumJson, prepareMoveEnumJson, prepareRenameEnumJson, prepareCreateSequenceJson, prepareAlterSequenceJson, prepareDropSequenceJson, prepareMoveSequenceJson, prepareRenameSequenceJson, prepareCreateSchemasJson, prepareRenameSchemasJson, prepareDeleteSchemasJson, prepareRenameColumns, _prepareDropColumns, _prepareAddColumns, _prepareSqliteAddColumns, prepareAlterColumnsMysql, preparePgAlterColumns, prepareSqliteAlterColumns, 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;
|
26890
|
+
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;
|
26378
26891
|
var init_jsonStatements = __esm({
|
26379
26892
|
"src/jsonStatements.ts"() {
|
26380
26893
|
"use strict";
|
@@ -26385,7 +26898,7 @@ var init_jsonStatements = __esm({
|
|
26385
26898
|
init_pgSchema();
|
26386
26899
|
init_sqliteSchema();
|
26387
26900
|
preparePgCreateTableJson = (table4, json2) => {
|
26388
|
-
const { name, schema: schema5, columns, compositePrimaryKeys, uniqueConstraints, checkConstraints } = table4;
|
26901
|
+
const { name, schema: schema5, columns, compositePrimaryKeys, uniqueConstraints, checkConstraints, policies, isRLSEnabled } = table4;
|
26389
26902
|
const tableKey2 = `${schema5 || "public"}.${name}`;
|
26390
26903
|
const compositePkName = Object.values(compositePrimaryKeys).length > 0 ? json2.tables[tableKey2].compositePrimaryKeys[`${PgSquasher.unsquashPK(Object.values(compositePrimaryKeys)[0]).name}`].name : "";
|
26391
26904
|
return {
|
@@ -26396,7 +26909,9 @@ var init_jsonStatements = __esm({
|
|
26396
26909
|
compositePKs: Object.values(compositePrimaryKeys),
|
26397
26910
|
compositePkName,
|
26398
26911
|
uniqueConstraints: Object.values(uniqueConstraints),
|
26399
|
-
|
26912
|
+
policies: Object.values(policies),
|
26913
|
+
checkConstraints: Object.values(checkConstraints),
|
26914
|
+
isRLSEnabled: isRLSEnabled ?? false
|
26400
26915
|
};
|
26401
26916
|
};
|
26402
26917
|
prepareMySqlCreateTableJson = (table4, json2, internals) => {
|
@@ -26436,7 +26951,8 @@ var init_jsonStatements = __esm({
|
|
26436
26951
|
return {
|
26437
26952
|
type: "drop_table",
|
26438
26953
|
tableName: table4.name,
|
26439
|
-
schema: table4.schema
|
26954
|
+
schema: table4.schema,
|
26955
|
+
policies: table4.policies ? Object.values(table4.policies) : []
|
26440
26956
|
};
|
26441
26957
|
};
|
26442
26958
|
prepareRenameTableJson = (tableFrom, tableTo) => {
|
@@ -26555,6 +27071,41 @@ var init_jsonStatements = __esm({
|
|
26555
27071
|
schema: schema5
|
26556
27072
|
};
|
26557
27073
|
};
|
27074
|
+
prepareCreateRoleJson = (role) => {
|
27075
|
+
return {
|
27076
|
+
type: "create_role",
|
27077
|
+
name: role.name,
|
27078
|
+
values: {
|
27079
|
+
createDb: role.createDb,
|
27080
|
+
createRole: role.createRole,
|
27081
|
+
inherit: role.inherit
|
27082
|
+
}
|
27083
|
+
};
|
27084
|
+
};
|
27085
|
+
prepareAlterRoleJson = (role) => {
|
27086
|
+
return {
|
27087
|
+
type: "alter_role",
|
27088
|
+
name: role.name,
|
27089
|
+
values: {
|
27090
|
+
createDb: role.createDb,
|
27091
|
+
createRole: role.createRole,
|
27092
|
+
inherit: role.inherit
|
27093
|
+
}
|
27094
|
+
};
|
27095
|
+
};
|
27096
|
+
prepareDropRoleJson = (name) => {
|
27097
|
+
return {
|
27098
|
+
type: "drop_role",
|
27099
|
+
name
|
27100
|
+
};
|
27101
|
+
};
|
27102
|
+
prepareRenameRoleJson = (nameFrom, nameTo) => {
|
27103
|
+
return {
|
27104
|
+
type: "rename_role",
|
27105
|
+
nameFrom,
|
27106
|
+
nameTo
|
27107
|
+
};
|
27108
|
+
};
|
26558
27109
|
prepareCreateSchemasJson = (values) => {
|
26559
27110
|
return values.map((it) => {
|
26560
27111
|
return {
|
@@ -27455,6 +28006,46 @@ var init_jsonStatements = __esm({
|
|
27455
28006
|
}
|
27456
28007
|
return [...dropPkStatements, ...setPkStatements, ...statements];
|
27457
28008
|
};
|
28009
|
+
prepareRenamePolicyJsons = (tableName, schema5, renames) => {
|
28010
|
+
return renames.map((it) => {
|
28011
|
+
return {
|
28012
|
+
type: "rename_policy",
|
28013
|
+
tableName,
|
28014
|
+
oldName: it.from.name,
|
28015
|
+
newName: it.to.name,
|
28016
|
+
schema: schema5
|
28017
|
+
};
|
28018
|
+
});
|
28019
|
+
};
|
28020
|
+
prepareCreatePolicyJsons = (tableName, schema5, policies) => {
|
28021
|
+
return policies.map((it) => {
|
28022
|
+
return {
|
28023
|
+
type: "create_policy",
|
28024
|
+
tableName,
|
28025
|
+
data: it,
|
28026
|
+
schema: schema5
|
28027
|
+
};
|
28028
|
+
});
|
28029
|
+
};
|
28030
|
+
prepareDropPolicyJsons = (tableName, schema5, policies) => {
|
28031
|
+
return policies.map((it) => {
|
28032
|
+
return {
|
28033
|
+
type: "drop_policy",
|
28034
|
+
tableName,
|
28035
|
+
data: it,
|
28036
|
+
schema: schema5
|
28037
|
+
};
|
28038
|
+
});
|
28039
|
+
};
|
28040
|
+
prepareAlterPolicyJson = (tableName, schema5, oldPolicy, newPolicy) => {
|
28041
|
+
return {
|
28042
|
+
type: "alter_policy",
|
28043
|
+
tableName,
|
28044
|
+
oldData: oldPolicy,
|
28045
|
+
newData: newPolicy,
|
28046
|
+
schema: schema5
|
28047
|
+
};
|
28048
|
+
};
|
27458
28049
|
preparePgCreateIndexesJson = (tableName, schema5, indexes, fullSchema, action) => {
|
27459
28050
|
if (action === "push") {
|
27460
28051
|
return Object.values(indexes).map((indexData) => {
|
@@ -28253,7 +28844,9 @@ var init_snapshotsDiffer = __esm({
|
|
28253
28844
|
foreignKeys: recordType(stringType(), stringType()),
|
28254
28845
|
compositePrimaryKeys: recordType(stringType(), stringType()).default({}),
|
28255
28846
|
uniqueConstraints: recordType(stringType(), stringType()).default({}),
|
28256
|
-
|
28847
|
+
policies: recordType(stringType(), stringType()).default({}),
|
28848
|
+
checkConstraints: recordType(stringType(), stringType()).default({}),
|
28849
|
+
isRLSEnabled: booleanType().default(false)
|
28257
28850
|
}).strict();
|
28258
28851
|
alteredTableScheme = objectType({
|
28259
28852
|
name: stringType(),
|
@@ -28295,6 +28888,15 @@ var init_snapshotsDiffer = __esm({
|
|
28295
28888
|
__old: stringType()
|
28296
28889
|
})
|
28297
28890
|
),
|
28891
|
+
addedPolicies: recordType(stringType(), stringType()),
|
28892
|
+
deletedPolicies: recordType(stringType(), stringType()),
|
28893
|
+
alteredPolicies: recordType(
|
28894
|
+
stringType(),
|
28895
|
+
objectType({
|
28896
|
+
__new: stringType(),
|
28897
|
+
__old: stringType()
|
28898
|
+
})
|
28899
|
+
),
|
28298
28900
|
addedCheckConstraints: recordType(
|
28299
28901
|
stringType(),
|
28300
28902
|
stringType()
|
@@ -28356,6 +28958,7 @@ var init_snapshotsDiffer = __esm({
|
|
28356
28958
|
alteredTablesWithColumns: alteredTableScheme.array(),
|
28357
28959
|
alteredEnums: changedEnumSchema.array(),
|
28358
28960
|
alteredSequences: sequenceSquashed.array(),
|
28961
|
+
alteredRoles: roleSchema.array(),
|
28359
28962
|
alteredViews: alteredPgViewSchema.array()
|
28360
28963
|
}).strict();
|
28361
28964
|
diffResultSchemeMysql = objectType({
|
@@ -28413,7 +29016,7 @@ var init_snapshotsDiffer = __esm({
|
|
28413
29016
|
}
|
28414
29017
|
return column7;
|
28415
29018
|
};
|
28416
|
-
applyPgSnapshotsDiff = async (json1, json2, schemasResolver2, enumsResolver2, sequencesResolver2, tablesResolver2, columnsResolver2, viewsResolver2, prevFull, curFull, action) => {
|
29019
|
+
applyPgSnapshotsDiff = async (json1, json2, schemasResolver2, enumsResolver2, sequencesResolver2, policyResolver2, roleResolver2, tablesResolver2, columnsResolver2, viewsResolver2, prevFull, curFull, action) => {
|
28417
29020
|
const schemasDiff = diffSchemasOrTables(json1.schemas, json2.schemas);
|
28418
29021
|
const {
|
28419
29022
|
created: createdSchemas,
|
@@ -28563,6 +29166,47 @@ var init_snapshotsDiffer = __esm({
|
|
28563
29166
|
return [tableKey2, tableValue];
|
28564
29167
|
}
|
28565
29168
|
);
|
29169
|
+
const rolesDiff = diffSchemasOrTables(
|
29170
|
+
schemasPatchedSnap1.roles,
|
29171
|
+
json2.roles
|
29172
|
+
);
|
29173
|
+
const {
|
29174
|
+
created: createdRoles,
|
29175
|
+
deleted: deletedRoles,
|
29176
|
+
renamed: renamedRoles
|
29177
|
+
} = await roleResolver2({
|
29178
|
+
created: rolesDiff.added,
|
29179
|
+
deleted: rolesDiff.deleted
|
29180
|
+
});
|
29181
|
+
schemasPatchedSnap1.roles = mapEntries(
|
29182
|
+
schemasPatchedSnap1.roles,
|
29183
|
+
(_2, it) => {
|
29184
|
+
const { name } = nameChangeFor(it, renamedRoles);
|
29185
|
+
it.name = name;
|
29186
|
+
return [name, it];
|
29187
|
+
}
|
29188
|
+
);
|
29189
|
+
const rolesChangeMap = renamedRoles.reduce(
|
29190
|
+
(acc, it) => {
|
29191
|
+
acc[it.from.name] = {
|
29192
|
+
nameFrom: it.from.name,
|
29193
|
+
nameTo: it.to.name
|
29194
|
+
};
|
29195
|
+
return acc;
|
29196
|
+
},
|
29197
|
+
{}
|
29198
|
+
);
|
29199
|
+
schemasPatchedSnap1.roles = mapEntries(
|
29200
|
+
schemasPatchedSnap1.roles,
|
29201
|
+
(roleKey, roleValue) => {
|
29202
|
+
const key = roleKey;
|
29203
|
+
const change = rolesChangeMap[key];
|
29204
|
+
if (change) {
|
29205
|
+
roleValue.name = change.nameTo;
|
29206
|
+
}
|
29207
|
+
return [roleKey, roleValue];
|
29208
|
+
}
|
29209
|
+
);
|
28566
29210
|
const tablesDiff = diffSchemasOrTables(
|
28567
29211
|
schemasPatchedSnap1.tables,
|
28568
29212
|
json2.tables
|
@@ -28641,7 +29285,66 @@ var init_snapshotsDiffer = __esm({
|
|
28641
29285
|
return [tableKey2, tableValue];
|
28642
29286
|
}
|
28643
29287
|
);
|
28644
|
-
const
|
29288
|
+
const policyRes = diffPolicies(tablesPatchedSnap1.tables, json2.tables);
|
29289
|
+
const policyRenames = [];
|
29290
|
+
const policyCreates = [];
|
29291
|
+
const policyDeletes = [];
|
29292
|
+
for (let entry of Object.values(policyRes)) {
|
29293
|
+
const { renamed, created, deleted } = await policyResolver2({
|
29294
|
+
tableName: entry.name,
|
29295
|
+
schema: entry.schema,
|
29296
|
+
deleted: entry.policies.deleted.map(PgSquasher.unsquashPolicy),
|
29297
|
+
created: entry.policies.added.map(PgSquasher.unsquashPolicy)
|
29298
|
+
});
|
29299
|
+
if (created.length > 0) {
|
29300
|
+
policyCreates.push({
|
29301
|
+
table: entry.name,
|
29302
|
+
schema: entry.schema,
|
29303
|
+
columns: created
|
29304
|
+
});
|
29305
|
+
}
|
29306
|
+
if (deleted.length > 0) {
|
29307
|
+
policyDeletes.push({
|
29308
|
+
table: entry.name,
|
29309
|
+
schema: entry.schema,
|
29310
|
+
columns: deleted
|
29311
|
+
});
|
29312
|
+
}
|
29313
|
+
if (renamed.length > 0) {
|
29314
|
+
policyRenames.push({
|
29315
|
+
table: entry.name,
|
29316
|
+
schema: entry.schema,
|
29317
|
+
renames: renamed
|
29318
|
+
});
|
29319
|
+
}
|
29320
|
+
}
|
29321
|
+
const policyRenamesDict = columnRenames.reduce(
|
29322
|
+
(acc, it) => {
|
29323
|
+
acc[`${it.schema || "public"}.${it.table}`] = it.renames;
|
29324
|
+
return acc;
|
29325
|
+
},
|
29326
|
+
{}
|
29327
|
+
);
|
29328
|
+
const policyPatchedSnap1 = copy(tablesPatchedSnap1);
|
29329
|
+
policyPatchedSnap1.tables = mapEntries(
|
29330
|
+
policyPatchedSnap1.tables,
|
29331
|
+
(tableKey2, tableValue) => {
|
29332
|
+
const patchedPolicies = mapKeys(
|
29333
|
+
tableValue.policies,
|
29334
|
+
(policyKey, policy2) => {
|
29335
|
+
const rens = policyRenamesDict[`${tableValue.schema || "public"}.${tableValue.name}`] || [];
|
29336
|
+
const newName = columnChangeFor(policyKey, rens);
|
29337
|
+
const unsquashedPolicy = PgSquasher.unsquashPolicy(policy2);
|
29338
|
+
unsquashedPolicy.name = newName;
|
29339
|
+
policy2 = PgSquasher.squashPolicy(unsquashedPolicy);
|
29340
|
+
return newName;
|
29341
|
+
}
|
29342
|
+
);
|
29343
|
+
tableValue.policies = patchedPolicies;
|
29344
|
+
return [tableKey2, tableValue];
|
29345
|
+
}
|
29346
|
+
);
|
29347
|
+
const viewsDiff = diffSchemasOrTables(policyPatchedSnap1.views, json2.views);
|
28645
29348
|
const {
|
28646
29349
|
created: createdViews,
|
28647
29350
|
deleted: deletedViews,
|
@@ -28659,7 +29362,7 @@ var init_snapshotsDiffer = __esm({
|
|
28659
29362
|
movedViews.forEach((it) => {
|
28660
29363
|
movedViewDic[`${it.schemaFrom}.${it.name}`] = { to: it.schemaTo, from: it.schemaFrom };
|
28661
29364
|
});
|
28662
|
-
const viewsPatchedSnap1 = copy(
|
29365
|
+
const viewsPatchedSnap1 = copy(policyPatchedSnap1);
|
28663
29366
|
viewsPatchedSnap1.views = mapEntries(
|
28664
29367
|
viewsPatchedSnap1.views,
|
28665
29368
|
(viewKey, viewValue) => {
|
@@ -28718,13 +29421,15 @@ var init_snapshotsDiffer = __esm({
|
|
28718
29421
|
const jsonDeletedUniqueConstraints = [];
|
28719
29422
|
const jsonAlteredUniqueConstraints = [];
|
28720
29423
|
const jsonSetTableSchemas = [];
|
28721
|
-
|
28722
|
-
|
28723
|
-
|
28724
|
-
|
28725
|
-
|
28726
|
-
|
28727
|
-
|
29424
|
+
if (movedTables) {
|
29425
|
+
for (let it of movedTables) {
|
29426
|
+
jsonSetTableSchemas.push({
|
29427
|
+
type: "alter_table_set_schema",
|
29428
|
+
tableName: it.name,
|
29429
|
+
schemaFrom: it.schemaFrom || "public",
|
29430
|
+
schemaTo: it.schemaTo || "public"
|
29431
|
+
});
|
29432
|
+
}
|
28728
29433
|
}
|
28729
29434
|
const jsonDeletedCheckConstraints = [];
|
28730
29435
|
const jsonCreatedCheckConstraints = [];
|
@@ -28851,7 +29556,106 @@ var init_snapshotsDiffer = __esm({
|
|
28851
29556
|
it.deletedIndexes || {}
|
28852
29557
|
);
|
28853
29558
|
}).flat();
|
29559
|
+
const jsonCreatePoliciesStatements = [];
|
29560
|
+
const jsonDropPoliciesStatements = [];
|
29561
|
+
const jsonAlterPoliciesStatements = [];
|
29562
|
+
const jsonRenamePoliciesStatements = [];
|
29563
|
+
const jsonEnableRLSStatements = [];
|
29564
|
+
const jsonDisableRLSStatements = [];
|
29565
|
+
for (let it of policyRenames) {
|
29566
|
+
jsonRenamePoliciesStatements.push(
|
29567
|
+
...prepareRenamePolicyJsons(it.table, it.schema, it.renames)
|
29568
|
+
);
|
29569
|
+
}
|
29570
|
+
for (const it of policyCreates) {
|
29571
|
+
jsonCreatePoliciesStatements.push(
|
29572
|
+
...prepareCreatePolicyJsons(
|
29573
|
+
it.table,
|
29574
|
+
it.schema,
|
29575
|
+
it.columns
|
29576
|
+
)
|
29577
|
+
);
|
29578
|
+
}
|
29579
|
+
for (const it of policyDeletes) {
|
29580
|
+
jsonDropPoliciesStatements.push(
|
29581
|
+
...prepareDropPolicyJsons(
|
29582
|
+
it.table,
|
29583
|
+
it.schema,
|
29584
|
+
it.columns
|
29585
|
+
)
|
29586
|
+
);
|
29587
|
+
}
|
28854
29588
|
alteredTables.forEach((it) => {
|
29589
|
+
Object.keys(it.alteredPolicies).forEach((policyName) => {
|
29590
|
+
const newPolicy = PgSquasher.unsquashPolicy(it.alteredPolicies[policyName].__new);
|
29591
|
+
const oldPolicy = PgSquasher.unsquashPolicy(it.alteredPolicies[policyName].__old);
|
29592
|
+
if (newPolicy.as !== oldPolicy.as) {
|
29593
|
+
jsonDropPoliciesStatements.push(
|
29594
|
+
...prepareDropPolicyJsons(
|
29595
|
+
it.name,
|
29596
|
+
it.schema,
|
29597
|
+
[oldPolicy]
|
29598
|
+
)
|
29599
|
+
);
|
29600
|
+
jsonCreatePoliciesStatements.push(
|
29601
|
+
...prepareCreatePolicyJsons(
|
29602
|
+
it.name,
|
29603
|
+
it.schema,
|
29604
|
+
[newPolicy]
|
29605
|
+
)
|
29606
|
+
);
|
29607
|
+
return;
|
29608
|
+
}
|
29609
|
+
if (newPolicy.for !== oldPolicy.for) {
|
29610
|
+
jsonDropPoliciesStatements.push(
|
29611
|
+
...prepareDropPolicyJsons(
|
29612
|
+
it.name,
|
29613
|
+
it.schema,
|
29614
|
+
[oldPolicy]
|
29615
|
+
)
|
29616
|
+
);
|
29617
|
+
jsonCreatePoliciesStatements.push(
|
29618
|
+
...prepareCreatePolicyJsons(
|
29619
|
+
it.name,
|
29620
|
+
it.schema,
|
29621
|
+
[newPolicy]
|
29622
|
+
)
|
29623
|
+
);
|
29624
|
+
return;
|
29625
|
+
}
|
29626
|
+
jsonAlterPoliciesStatements.push(
|
29627
|
+
prepareAlterPolicyJson(
|
29628
|
+
it.name,
|
29629
|
+
it.schema,
|
29630
|
+
it.alteredPolicies[policyName].__old,
|
29631
|
+
it.alteredPolicies[policyName].__new
|
29632
|
+
)
|
29633
|
+
);
|
29634
|
+
});
|
29635
|
+
for (const table4 of Object.values(json2.tables)) {
|
29636
|
+
const policiesInCurrentState = Object.keys(table4.policies);
|
29637
|
+
const tableInPreviousState = columnsPatchedSnap1.tables[`${table4.schema === "" ? "public" : table4.schema}.${table4.name}`];
|
29638
|
+
const policiesInPreviousState = tableInPreviousState ? Object.keys(tableInPreviousState.policies) : [];
|
29639
|
+
if (policiesInPreviousState.length === 0 && policiesInCurrentState.length > 0 && !table4.isRLSEnabled) {
|
29640
|
+
jsonEnableRLSStatements.push({ type: "enable_rls", tableName: table4.name, schema: table4.schema });
|
29641
|
+
}
|
29642
|
+
if (policiesInPreviousState.length > 0 && policiesInCurrentState.length === 0 && !table4.isRLSEnabled) {
|
29643
|
+
jsonDisableRLSStatements.push({ type: "disable_rls", tableName: table4.name, schema: table4.schema });
|
29644
|
+
}
|
29645
|
+
if (table4.isRLSEnabled !== tableInPreviousState.isRLSEnabled) {
|
29646
|
+
if (table4.isRLSEnabled) {
|
29647
|
+
jsonEnableRLSStatements.push({ type: "enable_rls", tableName: table4.name, schema: table4.schema });
|
29648
|
+
} else if (!table4.isRLSEnabled && policiesInCurrentState.length === 0) {
|
29649
|
+
jsonDisableRLSStatements.push({ type: "disable_rls", tableName: table4.name, schema: table4.schema });
|
29650
|
+
}
|
29651
|
+
}
|
29652
|
+
}
|
29653
|
+
for (const table4 of Object.values(columnsPatchedSnap1.tables)) {
|
29654
|
+
const tableInCurrentState = json2.tables[`${table4.schema === "" ? "public" : table4.schema}.${table4.name}`];
|
29655
|
+
if (tableInCurrentState === void 0 && !table4.isRLSEnabled) {
|
29656
|
+
jsonDisableRLSStatements.push({ type: "disable_rls", tableName: table4.name, schema: table4.schema });
|
29657
|
+
}
|
29658
|
+
}
|
28855
29659
|
const droppedIndexes = Object.keys(it.alteredIndexes).reduce(
|
28856
29660
|
(current, item) => {
|
28857
29661
|
current[item] = it.alteredIndexes[item].__old;
|
@@ -28939,6 +29743,18 @@ var init_snapshotsDiffer = __esm({
|
|
28939
29743
|
const jsonAlterSequences = typedResult.alteredSequences.map((it) => {
|
28940
29744
|
return prepareAlterSequenceJson(it);
|
28941
29745
|
}).flat() ?? [];
|
29746
|
+
const createRoles = createdRoles.map((it) => {
|
29747
|
+
return prepareCreateRoleJson(it);
|
29748
|
+
}) ?? [];
|
29749
|
+
const dropRoles = deletedRoles.map((it) => {
|
29750
|
+
return prepareDropRoleJson(it.name);
|
29751
|
+
});
|
29752
|
+
const renameRoles = renamedRoles.map((it) => {
|
29753
|
+
return prepareRenameRoleJson(it.from.name, it.to.name);
|
29754
|
+
});
|
29755
|
+
const jsonAlterRoles = typedResult.alteredRoles.map((it) => {
|
29756
|
+
return prepareAlterRoleJson(it);
|
29757
|
+
}).flat() ?? [];
|
28942
29758
|
const createSchemas = prepareCreateSchemasJson(
|
28943
29759
|
createdSchemas.map((it) => it.name)
|
28944
29760
|
);
|
@@ -28951,6 +29767,11 @@ var init_snapshotsDiffer = __esm({
|
|
28951
29767
|
const createTables = createdTables.map((it) => {
|
28952
29768
|
return preparePgCreateTableJson(it, curFull);
|
28953
29769
|
});
|
29770
|
+
jsonCreatePoliciesStatements.push(...[].concat(
|
29771
|
+
...createdTables.map(
|
29772
|
+
(it) => prepareCreatePolicyJsons(it.name, it.schema, Object.values(it.policies).map(PgSquasher.unsquashPolicy))
|
29773
|
+
)
|
29774
|
+
));
|
28954
29775
|
const createViews = [];
|
28955
29776
|
const dropViews = [];
|
28956
29777
|
const renameViews = [];
|
@@ -29092,7 +29913,13 @@ var init_snapshotsDiffer = __esm({
|
|
29092
29913
|
jsonStatements.push(...moveSequences);
|
29093
29914
|
jsonStatements.push(...renameSequences);
|
29094
29915
|
jsonStatements.push(...jsonAlterSequences);
|
29916
|
+
jsonStatements.push(...renameRoles);
|
29917
|
+
jsonStatements.push(...dropRoles);
|
29918
|
+
jsonStatements.push(...createRoles);
|
29919
|
+
jsonStatements.push(...jsonAlterRoles);
|
29095
29920
|
jsonStatements.push(...createTables);
|
29921
|
+
jsonStatements.push(...jsonEnableRLSStatements);
|
29922
|
+
jsonStatements.push(...jsonDisableRLSStatements);
|
29096
29923
|
jsonStatements.push(...dropViews);
|
29097
29924
|
jsonStatements.push(...renameViews);
|
29098
29925
|
jsonStatements.push(...alterViews);
|
@@ -29118,6 +29945,10 @@ var init_snapshotsDiffer = __esm({
|
|
29118
29945
|
jsonStatements.push(...jsonCreatedCheckConstraints);
|
29119
29946
|
jsonStatements.push(...jsonAlteredUniqueConstraints);
|
29120
29947
|
jsonStatements.push(...jsonAlterEnumsWithDroppedValues);
|
29948
|
+
jsonStatements.push(...jsonRenamePoliciesStatements);
|
29949
|
+
jsonStatements.push(...jsonDropPoliciesStatements);
|
29950
|
+
jsonStatements.push(...jsonCreatePoliciesStatements);
|
29951
|
+
jsonStatements.push(...jsonAlterPoliciesStatements);
|
29121
29952
|
jsonStatements.push(...createViews);
|
29122
29953
|
jsonStatements.push(...dropEnums);
|
29123
29954
|
jsonStatements.push(...dropSequences);
|
@@ -31703,6 +32534,7 @@ __export(migrate_exports, {
|
|
31703
32534
|
embeddedMigrations: () => embeddedMigrations,
|
31704
32535
|
enumsResolver: () => enumsResolver,
|
31705
32536
|
mySqlViewsResolver: () => mySqlViewsResolver,
|
32537
|
+
policyResolver: () => policyResolver,
|
31706
32538
|
prepareAndMigrateLibSQL: () => prepareAndMigrateLibSQL,
|
31707
32539
|
prepareAndMigrateMysql: () => prepareAndMigrateMysql,
|
31708
32540
|
prepareAndMigratePg: () => prepareAndMigratePg,
|
@@ -31713,8 +32545,10 @@ __export(migrate_exports, {
|
|
31713
32545
|
prepareSQLitePush: () => prepareSQLitePush,
|
31714
32546
|
prepareSnapshotFolderName: () => prepareSnapshotFolderName,
|
31715
32547
|
promptColumnsConflicts: () => promptColumnsConflicts,
|
32548
|
+
promptNamedConflict: () => promptNamedConflict,
|
31716
32549
|
promptNamedWithSchemasConflict: () => promptNamedWithSchemasConflict,
|
31717
32550
|
promptSchemasConflict: () => promptSchemasConflict,
|
32551
|
+
roleResolver: () => roleResolver,
|
31718
32552
|
schemasResolver: () => schemasResolver,
|
31719
32553
|
sequencesResolver: () => sequencesResolver,
|
31720
32554
|
sqliteViewsResolver: () => sqliteViewsResolver,
|
@@ -31722,7 +32556,7 @@ __export(migrate_exports, {
|
|
31722
32556
|
viewsResolver: () => viewsResolver,
|
31723
32557
|
writeResult: () => writeResult
|
31724
32558
|
});
|
31725
|
-
var import_fs5, import_hanji3, import_path4, schemasResolver, tablesResolver, viewsResolver, mySqlViewsResolver, sqliteViewsResolver, sequencesResolver, enumsResolver, columnsResolver, prepareAndMigratePg, preparePgPush, prepareMySQLPush, prepareAndMigrateMysql, prepareAndMigrateSqlite, prepareAndMigrateLibSQL, prepareSQLitePush, prepareLibSQLPush, promptColumnsConflicts, promptNamedWithSchemasConflict, promptSchemasConflict, BREAKPOINT, writeResult, embeddedMigrations, prepareSnapshotFolderName, two;
|
32559
|
+
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;
|
31726
32560
|
var init_migrate = __esm({
|
31727
32561
|
"src/cli/commands/migrate.ts"() {
|
31728
32562
|
"use strict";
|
@@ -31841,6 +32675,32 @@ var init_migrate = __esm({
|
|
31841
32675
|
throw e2;
|
31842
32676
|
}
|
31843
32677
|
};
|
32678
|
+
roleResolver = async (input) => {
|
32679
|
+
const result = await promptNamedConflict(
|
32680
|
+
input.created,
|
32681
|
+
input.deleted,
|
32682
|
+
"role"
|
32683
|
+
);
|
32684
|
+
return {
|
32685
|
+
created: result.created,
|
32686
|
+
deleted: result.deleted,
|
32687
|
+
renamed: result.renamed
|
32688
|
+
};
|
32689
|
+
};
|
32690
|
+
policyResolver = async (input) => {
|
32691
|
+
const result = await promptColumnsConflicts(
|
32692
|
+
input.tableName,
|
32693
|
+
input.created,
|
32694
|
+
input.deleted
|
32695
|
+
);
|
32696
|
+
return {
|
32697
|
+
tableName: input.tableName,
|
32698
|
+
schema: input.schema,
|
32699
|
+
created: result.created,
|
32700
|
+
deleted: result.deleted,
|
32701
|
+
renamed: result.renamed
|
32702
|
+
};
|
32703
|
+
};
|
31844
32704
|
enumsResolver = async (input) => {
|
31845
32705
|
try {
|
31846
32706
|
const { created, deleted, moved, renamed } = await promptNamedWithSchemasConflict(
|
@@ -31911,6 +32771,8 @@ var init_migrate = __esm({
|
|
31911
32771
|
schemasResolver,
|
31912
32772
|
enumsResolver,
|
31913
32773
|
sequencesResolver,
|
32774
|
+
policyResolver,
|
32775
|
+
roleResolver,
|
31914
32776
|
tablesResolver,
|
31915
32777
|
columnsResolver,
|
31916
32778
|
viewsResolver,
|
@@ -31947,6 +32809,8 @@ var init_migrate = __esm({
|
|
31947
32809
|
schemasResolver,
|
31948
32810
|
enumsResolver,
|
31949
32811
|
sequencesResolver,
|
32812
|
+
policyResolver,
|
32813
|
+
roleResolver,
|
31950
32814
|
tablesResolver,
|
31951
32815
|
columnsResolver,
|
31952
32816
|
viewsResolver,
|
@@ -32241,6 +33105,56 @@ var init_migrate = __esm({
|
|
32241
33105
|
result.deleted.push(...leftMissing);
|
32242
33106
|
return result;
|
32243
33107
|
};
|
33108
|
+
promptNamedConflict = async (newItems, missingItems, entity) => {
|
33109
|
+
if (missingItems.length === 0 || newItems.length === 0) {
|
33110
|
+
return {
|
33111
|
+
created: newItems,
|
33112
|
+
renamed: [],
|
33113
|
+
deleted: missingItems
|
33114
|
+
};
|
33115
|
+
}
|
33116
|
+
const result = { created: [], renamed: [], deleted: [] };
|
33117
|
+
let index4 = 0;
|
33118
|
+
let leftMissing = [...missingItems];
|
33119
|
+
do {
|
33120
|
+
const created = newItems[index4];
|
33121
|
+
const renames = leftMissing.map((it) => {
|
33122
|
+
return { from: it, to: created };
|
33123
|
+
});
|
33124
|
+
const promptData = [created, ...renames];
|
33125
|
+
const { status, data } = await (0, import_hanji3.render)(
|
33126
|
+
new ResolveSelectNamed(created, promptData, entity)
|
33127
|
+
);
|
33128
|
+
if (status === "aborted") {
|
33129
|
+
console.error("ERROR");
|
33130
|
+
process.exit(1);
|
33131
|
+
}
|
33132
|
+
if (isRenamePromptItem(data)) {
|
33133
|
+
console.log(
|
33134
|
+
`${source_default.yellow("~")} ${data.from.name} \u203A ${data.to.name} ${source_default.gray(
|
33135
|
+
`${entity} will be renamed/moved`
|
33136
|
+
)}`
|
33137
|
+
);
|
33138
|
+
if (data.from.name !== data.to.name) {
|
33139
|
+
result.renamed.push(data);
|
33140
|
+
}
|
33141
|
+
delete leftMissing[leftMissing.indexOf(data.from)];
|
33142
|
+
leftMissing = leftMissing.filter(Boolean);
|
33143
|
+
} else {
|
33144
|
+
console.log(
|
33145
|
+
`${source_default.green("+")} ${data.name} ${source_default.gray(
|
33146
|
+
`${entity} will be created`
|
33147
|
+
)}`
|
33148
|
+
);
|
33149
|
+
result.created.push(created);
|
33150
|
+
}
|
33151
|
+
index4 += 1;
|
33152
|
+
} while (index4 < newItems.length);
|
33153
|
+
console.log(source_default.gray(`--- all ${entity} conflicts resolved ---
|
33154
|
+
`));
|
33155
|
+
result.deleted.push(...leftMissing);
|
33156
|
+
return result;
|
33157
|
+
};
|
32244
33158
|
promptNamedWithSchemasConflict = async (newItems, missingItems, entity) => {
|
32245
33159
|
if (missingItems.length === 0 || newItems.length === 0) {
|
32246
33160
|
return {
|
@@ -41069,9 +41983,9 @@ var init_body2 = __esm({
|
|
41069
41983
|
// ../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/headers.js
|
41070
41984
|
function fromRawHeaders(headers = []) {
|
41071
41985
|
return new Headers2(
|
41072
|
-
headers.reduce((result, value, index4,
|
41986
|
+
headers.reduce((result, value, index4, array2) => {
|
41073
41987
|
if (index4 % 2 === 0) {
|
41074
|
-
result.push(
|
41988
|
+
result.push(array2.slice(index4, index4 + 2));
|
41075
41989
|
}
|
41076
41990
|
return result;
|
41077
41991
|
}, []).filter(([name, value]) => {
|
@@ -41469,7 +42383,7 @@ function determineRequestsReferrer(request, { referrerURLCallback, referrerOrigi
|
|
41469
42383
|
if (request.referrer === "no-referrer" || request.referrerPolicy === "") {
|
41470
42384
|
return null;
|
41471
42385
|
}
|
41472
|
-
const
|
42386
|
+
const policy2 = request.referrerPolicy;
|
41473
42387
|
if (request.referrer === "about:client") {
|
41474
42388
|
return "no-referrer";
|
41475
42389
|
}
|
@@ -41486,7 +42400,7 @@ function determineRequestsReferrer(request, { referrerURLCallback, referrerOrigi
|
|
41486
42400
|
referrerOrigin = referrerOriginCallback(referrerOrigin);
|
41487
42401
|
}
|
41488
42402
|
const currentURL = new URL(request.url);
|
41489
|
-
switch (
|
42403
|
+
switch (policy2) {
|
41490
42404
|
case "no-referrer":
|
41491
42405
|
return "no-referrer";
|
41492
42406
|
case "origin":
|
@@ -41522,18 +42436,18 @@ function determineRequestsReferrer(request, { referrerURLCallback, referrerOrigi
|
|
41522
42436
|
}
|
41523
42437
|
return referrerURL;
|
41524
42438
|
default:
|
41525
|
-
throw new TypeError(`Invalid referrerPolicy: ${
|
42439
|
+
throw new TypeError(`Invalid referrerPolicy: ${policy2}`);
|
41526
42440
|
}
|
41527
42441
|
}
|
41528
42442
|
function parseReferrerPolicyFromHeader(headers) {
|
41529
42443
|
const policyTokens = (headers.get("referrer-policy") || "").split(/[,\s]+/);
|
41530
|
-
let
|
42444
|
+
let policy2 = "";
|
41531
42445
|
for (const token of policyTokens) {
|
41532
42446
|
if (token && ReferrerPolicy.has(token)) {
|
41533
|
-
|
42447
|
+
policy2 = token;
|
41534
42448
|
}
|
41535
42449
|
}
|
41536
|
-
return
|
42450
|
+
return policy2;
|
41537
42451
|
}
|
41538
42452
|
var import_node_net, ReferrerPolicy, DEFAULT_REFERRER_POLICY;
|
41539
42453
|
var init_referrer = __esm({
|
@@ -62180,7 +63094,7 @@ var require_fromWebToken = __commonJS({
|
|
62180
63094
|
var fromWebToken2 = (init2) => async () => {
|
62181
63095
|
var _a;
|
62182
63096
|
(_a = init2.logger) == null ? void 0 : _a.debug("@aws-sdk/credential-provider-web-identity", "fromWebToken");
|
62183
|
-
const { roleArn, roleSessionName, webIdentityToken, providerId, policyArns, policy, durationSeconds } = init2;
|
63097
|
+
const { roleArn, roleSessionName, webIdentityToken, providerId, policyArns, policy: policy2, durationSeconds } = init2;
|
62184
63098
|
let { roleAssumerWithWebIdentity } = init2;
|
62185
63099
|
if (!roleAssumerWithWebIdentity) {
|
62186
63100
|
const { getDefaultRoleAssumerWithWebIdentity } = await Promise.resolve().then(() => __importStar2(require_dist_cjs50()));
|
@@ -62196,7 +63110,7 @@ var require_fromWebToken = __commonJS({
|
|
62196
63110
|
WebIdentityToken: webIdentityToken,
|
62197
63111
|
ProviderId: providerId,
|
62198
63112
|
PolicyArns: policyArns,
|
62199
|
-
Policy:
|
63113
|
+
Policy: policy2,
|
62200
63114
|
DurationSeconds: durationSeconds
|
62201
63115
|
});
|
62202
63116
|
};
|
@@ -65660,13 +66574,13 @@ var require_event_stream = __commonJS({
|
|
65660
66574
|
es.writeArray = function(done) {
|
65661
66575
|
if ("function" !== typeof done)
|
65662
66576
|
throw new Error("function writeArray (done): done must be function");
|
65663
|
-
var a = new Stream3(),
|
66577
|
+
var a = new Stream3(), array2 = [], isDone = false;
|
65664
66578
|
a.write = function(l) {
|
65665
|
-
|
66579
|
+
array2.push(l);
|
65666
66580
|
};
|
65667
66581
|
a.end = function() {
|
65668
66582
|
isDone = true;
|
65669
|
-
done(null,
|
66583
|
+
done(null, array2);
|
65670
66584
|
};
|
65671
66585
|
a.writable = true;
|
65672
66586
|
a.readable = false;
|
@@ -65674,23 +66588,23 @@ var require_event_stream = __commonJS({
|
|
65674
66588
|
a.writable = a.readable = false;
|
65675
66589
|
if (isDone)
|
65676
66590
|
return;
|
65677
|
-
done(new Error("destroyed before end"),
|
66591
|
+
done(new Error("destroyed before end"), array2);
|
65678
66592
|
};
|
65679
66593
|
return a;
|
65680
66594
|
};
|
65681
|
-
es.readArray = function(
|
66595
|
+
es.readArray = function(array2) {
|
65682
66596
|
var stream = new Stream3(), i2 = 0, paused = false, ended = false;
|
65683
66597
|
stream.readable = true;
|
65684
66598
|
stream.writable = false;
|
65685
|
-
if (!Array.isArray(
|
66599
|
+
if (!Array.isArray(array2))
|
65686
66600
|
throw new Error("event-stream.read expects an array");
|
65687
66601
|
stream.resume = function() {
|
65688
66602
|
if (ended)
|
65689
66603
|
return;
|
65690
66604
|
paused = false;
|
65691
|
-
var l =
|
66605
|
+
var l = array2.length;
|
65692
66606
|
while (i2 < l && !paused && !ended) {
|
65693
|
-
stream.emit("data",
|
66607
|
+
stream.emit("data", array2[i2++]);
|
65694
66608
|
}
|
65695
66609
|
if (i2 == l && !ended)
|
65696
66610
|
ended = true, stream.readable = false, stream.emit("end");
|
@@ -69315,8 +70229,8 @@ var require_utils4 = __commonJS({
|
|
69315
70229
|
"use strict";
|
69316
70230
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
69317
70231
|
exports2.string = exports2.stream = exports2.pattern = exports2.path = exports2.fs = exports2.errno = exports2.array = void 0;
|
69318
|
-
var
|
69319
|
-
exports2.array =
|
70232
|
+
var array2 = require_array();
|
70233
|
+
exports2.array = array2;
|
69320
70234
|
var errno = require_errno();
|
69321
70235
|
exports2.errno = errno;
|
69322
70236
|
var fs9 = require_fs2();
|
@@ -79966,17 +80880,11 @@ var init_pgPushUtils = __esm({
|
|
79966
80880
|
}
|
79967
80881
|
const stmnt = fromJson([statement], "postgresql");
|
79968
80882
|
if (typeof stmnt !== "undefined") {
|
79969
|
-
|
79970
|
-
statementsToExecute.push(
|
79971
|
-
`DROP TABLE ${concatSchemaAndTableName(statement.schema, statement.tableName)} CASCADE;`
|
79972
|
-
);
|
79973
|
-
} else {
|
79974
|
-
statementsToExecute.push(...stmnt);
|
79975
|
-
}
|
80883
|
+
statementsToExecute.push(...stmnt);
|
79976
80884
|
}
|
79977
80885
|
}
|
79978
80886
|
return {
|
79979
|
-
statementsToExecute,
|
80887
|
+
statementsToExecute: [...new Set(statementsToExecute)],
|
79980
80888
|
shouldAskForApprove,
|
79981
80889
|
infoToPrint,
|
79982
80890
|
matViewsToRemove: [...new Set(matViewsToRemove)],
|
@@ -81124,7 +82032,7 @@ var init_pgIntrospect = __esm({
|
|
81124
82032
|
init_global();
|
81125
82033
|
init_pgSerializer();
|
81126
82034
|
init_views();
|
81127
|
-
pgPushIntrospect = async (db, filters, schemaFilters) => {
|
82035
|
+
pgPushIntrospect = async (db, filters, schemaFilters, entities = { roles: true }) => {
|
81128
82036
|
const matchers = filters.map((it) => {
|
81129
82037
|
return new Minimatch(it);
|
81130
82038
|
});
|
@@ -81153,7 +82061,7 @@ var init_pgIntrospect = __esm({
|
|
81153
82061
|
);
|
81154
82062
|
const res = await (0, import_hanji9.renderWithTask)(
|
81155
82063
|
progress,
|
81156
|
-
fromDatabase2(db, filter2, schemaFilters)
|
82064
|
+
fromDatabase2(db, filter2, schemaFilters, entities)
|
81157
82065
|
);
|
81158
82066
|
const schema5 = { id: originUUID, prevId: "", ...res };
|
81159
82067
|
const { internal, ...schemaWithoutInternals } = schema5;
|
@@ -81743,11 +82651,11 @@ var init_push = __esm({
|
|
81743
82651
|
console.log(e2);
|
81744
82652
|
}
|
81745
82653
|
};
|
81746
|
-
pgPush = async (schemaPath, verbose, strict, credentials2, tablesFilter, schemasFilter, force, casing2) => {
|
82654
|
+
pgPush = async (schemaPath, verbose, strict, credentials2, tablesFilter, schemasFilter, entities, force, casing2) => {
|
81747
82655
|
const { preparePostgresDB: preparePostgresDB2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
|
81748
82656
|
const { pgPushIntrospect: pgPushIntrospect2 } = await Promise.resolve().then(() => (init_pgIntrospect(), pgIntrospect_exports));
|
81749
82657
|
const db = await preparePostgresDB2(credentials2);
|
81750
|
-
const { schema: schema5 } = await pgPushIntrospect2(db, tablesFilter, schemasFilter);
|
82658
|
+
const { schema: schema5 } = await pgPushIntrospect2(db, tablesFilter, schemasFilter, entities);
|
81751
82659
|
const { preparePgPush: preparePgPush2 } = await Promise.resolve().then(() => (init_migrate(), migrate_exports));
|
81752
82660
|
const statements = await preparePgPush2(schemaPath, schema5, schemasFilter, casing2);
|
81753
82661
|
try {
|
@@ -83004,7 +83912,7 @@ function generateIdentityParams(identity) {
|
|
83004
83912
|
}
|
83005
83913
|
return `.generatedByDefaultAsIdentity(${paramsObj})`;
|
83006
83914
|
}
|
83007
|
-
var import_drizzle_orm9, import_relations, import_casing5, pgImportsList, timeConfig2, possibleIntervals, intervalStrToObj, intervalConfig, mapColumnDefault3, importsPatch2, relations3, escapeColumnKey3, withCasing2, dbColumnName3, paramNameFor, schemaToTypeScript3, isCyclic3, isSelf3, buildArrayDefault, mapDefault, column6, dimensionsInArray, createTableColumns3, createTableIndexes3, createTablePKs3, createTableUniques3, createTableChecks3, createTableFKs3;
|
83915
|
+
var import_drizzle_orm9, import_relations, import_casing5, 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;
|
83008
83916
|
var init_introspect_pg = __esm({
|
83009
83917
|
"src/introspect-pg.ts"() {
|
83010
83918
|
"use strict";
|
@@ -83178,6 +84086,9 @@ var init_introspect_pg = __esm({
|
|
83178
84086
|
const checkImports = Object.values(it.checkConstraints).map(
|
83179
84087
|
(it2) => "check"
|
83180
84088
|
);
|
84089
|
+
const policiesImports = Object.values(it.policies).map(
|
84090
|
+
(it2) => "pgPolicy"
|
84091
|
+
);
|
83181
84092
|
if (it.schema && it.schema !== "public" && it.schema !== "") {
|
83182
84093
|
res.pg.push("pgSchema");
|
83183
84094
|
}
|
@@ -83185,6 +84096,7 @@ var init_introspect_pg = __esm({
|
|
83185
84096
|
res.pg.push(...fkImpots);
|
83186
84097
|
res.pg.push(...pkImports);
|
83187
84098
|
res.pg.push(...uniqueImports);
|
84099
|
+
res.pg.push(...policiesImports);
|
83188
84100
|
res.pg.push(...checkImports);
|
83189
84101
|
const columnImports = Object.values(it.columns).map((col) => {
|
83190
84102
|
let patched = (importsPatch2[col.type] || col.type).replace("[]", "");
|
@@ -83243,6 +84155,9 @@ var init_introspect_pg = __esm({
|
|
83243
84155
|
imports.pg.push("pgEnum");
|
83244
84156
|
}
|
83245
84157
|
});
|
84158
|
+
if (Object.keys(schema5.roles).length > 0) {
|
84159
|
+
imports.pg.push("pgRole");
|
84160
|
+
}
|
83246
84161
|
const enumStatements = Object.values(schema5.enums).map((it) => {
|
83247
84162
|
const enumSchema3 = schemas[it.schema];
|
83248
84163
|
const paramName = paramNameFor(it.name, enumSchema3);
|
@@ -83278,9 +84193,16 @@ var init_introspect_pg = __esm({
|
|
83278
84193
|
}
|
83279
84194
|
return `export const ${withCasing2(paramName, casing2)} = ${func}("${it.name}"${params ? `, { ${params.trimChar(",")} }` : ""})
|
83280
84195
|
`;
|
83281
|
-
}).join("").concat("
|
84196
|
+
}).join("").concat("");
|
83282
84197
|
const schemaStatements = Object.entries(schemas).map((it) => {
|
83283
84198
|
return `export const ${it[1]} = pgSchema("${it[0]}");
|
84199
|
+
`;
|
84200
|
+
}).join("");
|
84201
|
+
const rolesNameToTsKey = {};
|
84202
|
+
const rolesStatements = Object.entries(schema5.roles).map((it) => {
|
84203
|
+
const fields = it[1];
|
84204
|
+
rolesNameToTsKey[fields.name] = it[0];
|
84205
|
+
return `export const ${withCasing2(it[0], casing2)} = pgRole("${fields.name}", ${!fields.createDb && !fields.createRole && fields.inherit ? "" : `${`, { ${fields.createDb ? `createDb: true,` : ""}${fields.createRole ? ` createRole: true,` : ""}${!fields.inherit ? ` inherit: false ` : ""}`.trimChar(",")}}`} );
|
83284
84206
|
`;
|
83285
84207
|
}).join("");
|
83286
84208
|
const tableStatements = Object.values(schema5.tables).map((table4) => {
|
@@ -83299,8 +84221,8 @@ var init_introspect_pg = __esm({
|
|
83299
84221
|
schema5.internal
|
83300
84222
|
);
|
83301
84223
|
statement += "}";
|
83302
|
-
if (Object.keys(table4.indexes).length > 0 || Object.values(table4.foreignKeys).length > 0 || Object.keys(table4.compositePrimaryKeys).length > 0 || Object.keys(table4.uniqueConstraints).length > 0 || Object.keys(table4.checkConstraints).length > 0) {
|
83303
|
-
statement += "
|
84224
|
+
if (Object.keys(table4.indexes).length > 0 || Object.values(table4.foreignKeys).length > 0 || Object.values(table4.policies).length > 0 || Object.keys(table4.compositePrimaryKeys).length > 0 || Object.keys(table4.uniqueConstraints).length > 0 || Object.keys(table4.checkConstraints).length > 0) {
|
84225
|
+
statement += ", ";
|
83304
84226
|
statement += "(table) => {\n";
|
83305
84227
|
statement += " return {\n";
|
83306
84228
|
statement += createTableIndexes3(table4.name, Object.values(table4.indexes), casing2);
|
@@ -83313,6 +84235,11 @@ var init_introspect_pg = __esm({
|
|
83313
84235
|
Object.values(table4.uniqueConstraints),
|
83314
84236
|
casing2
|
83315
84237
|
);
|
84238
|
+
statement += createTablePolicies(
|
84239
|
+
Object.values(table4.policies),
|
84240
|
+
casing2,
|
84241
|
+
rolesNameToTsKey
|
84242
|
+
);
|
83316
84243
|
statement += createTableChecks3(
|
83317
84244
|
Object.values(table4.checkConstraints),
|
83318
84245
|
casing2
|
@@ -83346,11 +84273,14 @@ var init_introspect_pg = __esm({
|
|
83346
84273
|
return statement;
|
83347
84274
|
}).join("\n\n");
|
83348
84275
|
const uniquePgImports = ["pgTable", ...new Set(imports.pg)];
|
83349
|
-
const importsTs = `import { ${uniquePgImports.join(
|
83350
|
-
|
84276
|
+
const importsTs = `import { ${uniquePgImports.join(
|
84277
|
+
", "
|
84278
|
+
)} } from "drizzle-orm/pg-core"
|
84279
|
+
import { sql } from "drizzle-orm"
|
83351
84280
|
|
83352
84281
|
`;
|
83353
84282
|
let decalrations = schemaStatements;
|
84283
|
+
decalrations += rolesStatements;
|
83354
84284
|
decalrations += enumStatements;
|
83355
84285
|
decalrations += sequencesStatements;
|
83356
84286
|
decalrations += "\n";
|
@@ -83749,6 +84679,23 @@ var init_introspect_pg = __esm({
|
|
83749
84679
|
}).join(", ")}]${it.name ? `, name: "${it.name}"` : ""}}`;
|
83750
84680
|
statement += ")";
|
83751
84681
|
statement += `,
|
84682
|
+
`;
|
84683
|
+
});
|
84684
|
+
return statement;
|
84685
|
+
};
|
84686
|
+
createTablePolicies = (policies, casing2, rolesNameToTsKey = {}) => {
|
84687
|
+
let statement = "";
|
84688
|
+
policies.forEach((it) => {
|
84689
|
+
var _a, _b, _c;
|
84690
|
+
const idxKey = withCasing2(it.name, casing2);
|
84691
|
+
const mappedItTo = (_a = it.to) == null ? void 0 : _a.map((v) => {
|
84692
|
+
return rolesNameToTsKey[v] ? withCasing2(rolesNameToTsKey[v], casing2) : `"${v}"`;
|
84693
|
+
});
|
84694
|
+
statement += ` ${idxKey}: `;
|
84695
|
+
statement += "pgPolicy(";
|
84696
|
+
statement += `"${it.name}", { `;
|
84697
|
+
statement += `as: "${(_b = it.as) == null ? void 0 : _b.toLowerCase()}", for: "${(_c = it.for) == null ? void 0 : _c.toLowerCase()}", to: [${mappedItTo == null ? void 0 : mappedItTo.join(", ")}]${it.using ? `, using: sql\`${it.using}\`` : ""}${it.withCheck ? `, withCheck: sql\`${it.withCheck}\` ` : ""}`;
|
84698
|
+
statement += ` }),
|
83752
84699
|
`;
|
83753
84700
|
});
|
83754
84701
|
return statement;
|
@@ -83839,7 +84786,7 @@ var init_introspect = __esm({
|
|
83839
84786
|
init_utils();
|
83840
84787
|
init_views();
|
83841
84788
|
init_migrate();
|
83842
|
-
introspectPostgres = async (casing2, out, breakpoints, credentials2, tablesFilter, schemasFilter, prefix2) => {
|
84789
|
+
introspectPostgres = async (casing2, out, breakpoints, credentials2, tablesFilter, schemasFilter, prefix2, entities) => {
|
83843
84790
|
const { preparePostgresDB: preparePostgresDB2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
|
83844
84791
|
const db = await preparePostgresDB2(credentials2);
|
83845
84792
|
const matchers = tablesFilter.map((it) => {
|
@@ -83867,9 +84814,15 @@ var init_introspect = __esm({
|
|
83867
84814
|
const progress = new IntrospectProgress(true);
|
83868
84815
|
const res = await (0, import_hanji12.renderWithTask)(
|
83869
84816
|
progress,
|
83870
|
-
fromDatabase2(
|
83871
|
-
|
83872
|
-
|
84817
|
+
fromDatabase2(
|
84818
|
+
db,
|
84819
|
+
filter2,
|
84820
|
+
schemasFilter,
|
84821
|
+
entities,
|
84822
|
+
(stage, count, status) => {
|
84823
|
+
progress.update(stage, count, status);
|
84824
|
+
}
|
84825
|
+
)
|
83873
84826
|
);
|
83874
84827
|
const schema5 = { id: originUUID, prevId: "", ...res };
|
83875
84828
|
const ts = schemaToTypeScript3(schema5, casing2);
|
@@ -83888,6 +84841,7 @@ var init_introspect = __esm({
|
|
83888
84841
|
schemasResolver,
|
83889
84842
|
enumsResolver,
|
83890
84843
|
sequencesResolver,
|
84844
|
+
policyResolver,
|
83891
84845
|
tablesResolver,
|
83892
84846
|
columnsResolver,
|
83893
84847
|
viewsResolver,
|
@@ -87414,7 +88368,8 @@ var pull = command({
|
|
87414
88368
|
breakpoints,
|
87415
88369
|
tablesFilter,
|
87416
88370
|
schemasFilter,
|
87417
|
-
prefix: prefix2
|
88371
|
+
prefix: prefix2,
|
88372
|
+
entities
|
87418
88373
|
} = config;
|
87419
88374
|
(0, import_fs13.mkdirSync)(out, { recursive: true });
|
87420
88375
|
console.log(
|
@@ -87453,7 +88408,8 @@ var pull = command({
|
|
87453
88408
|
credentials2,
|
87454
88409
|
tablesFilter,
|
87455
88410
|
schemasFilter,
|
87456
|
-
prefix2
|
88411
|
+
prefix2,
|
88412
|
+
entities
|
87457
88413
|
);
|
87458
88414
|
} else if (dialect4 === "mysql") {
|
87459
88415
|
const { introspectMysql: introspectMysql2 } = await Promise.resolve().then(() => (init_introspect(), introspect_exports));
|
@@ -87624,7 +88580,7 @@ init_utils2();
|
|
87624
88580
|
var version2 = async () => {
|
87625
88581
|
const { npmVersion } = await ormCoreVersions();
|
87626
88582
|
const ormVersion = npmVersion ? `drizzle-orm: v${npmVersion}` : "";
|
87627
|
-
const envVersion = "0.26.2-
|
88583
|
+
const envVersion = "0.26.2-b2b714a";
|
87628
88584
|
const kitVersion = envVersion ? `v${envVersion}` : "--";
|
87629
88585
|
const versions = `drizzle-kit: ${kitVersion}
|
87630
88586
|
${ormVersion}`;
|