drizzle-kit 0.25.0-225f91d → 0.25.0-22c3e40
Sign up to get free protection for your applications and to get access to all the features.
- package/api.d.mts +0 -96
- package/api.d.ts +0 -96
- package/api.js +655 -1436
- package/api.mjs +655 -1436
- package/bin.cjs +244 -1023
- package/index.d.mts +0 -7
- package/index.d.ts +0 -7
- package/package.json +2 -2
- package/utils.js +3 -21
- package/utils.mjs +3 -21
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,
|
1078
|
+
var import_hanji, warning, err, info, grey, error, schema, isRenamePromptItem, ResolveColumnSelect, tableKey, 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,53 +1178,6 @@ 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
|
-
};
|
1228
1181
|
ResolveSelect = class extends import_hanji.Prompt {
|
1229
1182
|
constructor(base, data, entityType) {
|
1230
1183
|
super();
|
@@ -1362,11 +1315,6 @@ Is ${source_default.bold.blue(
|
|
1362
1315
|
count: 0,
|
1363
1316
|
name: "foreign keys",
|
1364
1317
|
status: "fetching"
|
1365
|
-
},
|
1366
|
-
policies: {
|
1367
|
-
count: 0,
|
1368
|
-
name: "policies",
|
1369
|
-
status: "fetching"
|
1370
1318
|
}
|
1371
1319
|
};
|
1372
1320
|
this.formatCount = (count) => {
|
@@ -1404,7 +1352,6 @@ Is ${source_default.bold.blue(
|
|
1404
1352
|
info2 += this.hasEnums ? this.statusText(spin, this.state.enums) : "";
|
1405
1353
|
info2 += this.statusText(spin, this.state.indexes);
|
1406
1354
|
info2 += this.statusText(spin, this.state.fks);
|
1407
|
-
info2 += this.statusText(spin, this.state.policies);
|
1408
1355
|
return info2;
|
1409
1356
|
}
|
1410
1357
|
};
|
@@ -1789,8 +1736,8 @@ var init_lib = __esm({
|
|
1789
1736
|
return void 0;
|
1790
1737
|
};
|
1791
1738
|
util2.isInteger = typeof Number.isInteger === "function" ? (val2) => Number.isInteger(val2) : (val2) => typeof val2 === "number" && isFinite(val2) && Math.floor(val2) === val2;
|
1792
|
-
function joinValues(
|
1793
|
-
return
|
1739
|
+
function joinValues(array, separator = " | ") {
|
1740
|
+
return array.map((val2) => typeof val2 === "string" ? `'${val2}'` : val2).join(separator);
|
1794
1741
|
}
|
1795
1742
|
util2.joinValues = joinValues;
|
1796
1743
|
util2.jsonStringifyReplacer = (_2, value) => {
|
@@ -5759,7 +5706,7 @@ var init_vector = __esm({
|
|
5759
5706
|
});
|
5760
5707
|
|
5761
5708
|
// src/serializer/pgSchema.ts
|
5762
|
-
var indexV2, columnV2, tableV2, enumSchemaV1, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, indexColumn, index2, indexV4, indexV5, indexV6, fk2, sequenceSchema,
|
5709
|
+
var indexV2, columnV2, tableV2, enumSchemaV1, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, indexColumn, index2, indexV4, indexV5, indexV6, fk2, sequenceSchema, sequenceSquashed, columnV7, column2, columnSquashed, tableV32, compositePK2, uniqueConstraint2, 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;
|
5763
5710
|
var init_pgSchema = __esm({
|
5764
5711
|
"src/serializer/pgSchema.ts"() {
|
5765
5712
|
"use strict";
|
@@ -5891,12 +5838,6 @@ var init_pgSchema = __esm({
|
|
5891
5838
|
cycle: booleanType().optional(),
|
5892
5839
|
schema: stringType()
|
5893
5840
|
}).strict();
|
5894
|
-
roleSchema = objectType({
|
5895
|
-
name: stringType(),
|
5896
|
-
createDb: booleanType().optional(),
|
5897
|
-
createRole: booleanType().optional(),
|
5898
|
-
inherit: booleanType().optional()
|
5899
|
-
}).strict();
|
5900
5841
|
sequenceSquashed = objectType({
|
5901
5842
|
name: stringType(),
|
5902
5843
|
schema: stringType(),
|
@@ -5960,14 +5901,6 @@ var init_pgSchema = __esm({
|
|
5960
5901
|
columns: stringType().array(),
|
5961
5902
|
nullsNotDistinct: booleanType()
|
5962
5903
|
}).strict();
|
5963
|
-
policy = objectType({
|
5964
|
-
name: stringType(),
|
5965
|
-
as: enumType(["PERMISSIVE", "RESTRICTIVE"]).optional(),
|
5966
|
-
for: enumType(["ALL", "SELECT", "INSERT", "UPDATE", "DELETE"]).optional(),
|
5967
|
-
to: stringType().array().optional(),
|
5968
|
-
using: stringType().optional(),
|
5969
|
-
withCheck: stringType().optional()
|
5970
|
-
}).strict();
|
5971
5904
|
tableV42 = objectType({
|
5972
5905
|
name: stringType(),
|
5973
5906
|
schema: stringType(),
|
@@ -6009,8 +5942,7 @@ var init_pgSchema = __esm({
|
|
6009
5942
|
indexes: recordType(stringType(), index2),
|
6010
5943
|
foreignKeys: recordType(stringType(), fk2),
|
6011
5944
|
compositePrimaryKeys: recordType(stringType(), compositePK2),
|
6012
|
-
uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
|
6013
|
-
policies: recordType(stringType(), policy).default({})
|
5945
|
+
uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
|
6014
5946
|
}).strict();
|
6015
5947
|
schemaHash2 = objectType({
|
6016
5948
|
id: stringType(),
|
@@ -6104,7 +6036,6 @@ var init_pgSchema = __esm({
|
|
6104
6036
|
enums: recordType(stringType(), enumSchema),
|
6105
6037
|
schemas: recordType(stringType(), stringType()),
|
6106
6038
|
sequences: recordType(stringType(), sequenceSchema).default({}),
|
6107
|
-
roles: recordType(stringType(), roleSchema).default({}),
|
6108
6039
|
_meta: objectType({
|
6109
6040
|
schemas: recordType(stringType(), stringType()),
|
6110
6041
|
tables: recordType(stringType(), stringType()),
|
@@ -6119,8 +6050,7 @@ var init_pgSchema = __esm({
|
|
6119
6050
|
indexes: recordType(stringType(), stringType()),
|
6120
6051
|
foreignKeys: recordType(stringType(), stringType()),
|
6121
6052
|
compositePrimaryKeys: recordType(stringType(), stringType()),
|
6122
|
-
uniqueConstraints: recordType(stringType(), stringType())
|
6123
|
-
policies: recordType(stringType(), stringType())
|
6053
|
+
uniqueConstraints: recordType(stringType(), stringType())
|
6124
6054
|
}).strict();
|
6125
6055
|
tableSquashedV42 = objectType({
|
6126
6056
|
name: stringType(),
|
@@ -6149,8 +6079,7 @@ var init_pgSchema = __esm({
|
|
6149
6079
|
tables: recordType(stringType(), tableSquashed2),
|
6150
6080
|
enums: recordType(stringType(), enumSchema),
|
6151
6081
|
schemas: recordType(stringType(), stringType()),
|
6152
|
-
sequences: recordType(stringType(), sequenceSquashed)
|
6153
|
-
roles: recordType(stringType(), roleSchema).default({})
|
6082
|
+
sequences: recordType(stringType(), sequenceSquashed)
|
6154
6083
|
}).strict();
|
6155
6084
|
pgSchemaV3 = pgSchemaInternalV3.merge(schemaHash2);
|
6156
6085
|
pgSchemaV4 = pgSchemaInternalV4.merge(schemaHash2);
|
@@ -6233,25 +6162,6 @@ var init_pgSchema = __esm({
|
|
6233
6162
|
squashFK: (fk4) => {
|
6234
6163
|
return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""};${fk4.schemaTo || "public"}`;
|
6235
6164
|
},
|
6236
|
-
squashPolicy: (policy2) => {
|
6237
|
-
var _a;
|
6238
|
-
return `${policy2.name}--${policy2.as}--${policy2.for}--${(_a = policy2.to) == null ? void 0 : _a.join(",")}--${policy2.using}--${policy2.withCheck}`;
|
6239
|
-
},
|
6240
|
-
unsquashPolicy: (policy2) => {
|
6241
|
-
const splitted = policy2.split("--");
|
6242
|
-
return {
|
6243
|
-
name: splitted[0],
|
6244
|
-
as: splitted[1],
|
6245
|
-
for: splitted[2],
|
6246
|
-
to: splitted[3].split(","),
|
6247
|
-
using: splitted[4] !== "undefined" ? splitted[4] : void 0,
|
6248
|
-
withCheck: splitted[5] !== "undefined" ? splitted[5] : void 0
|
6249
|
-
};
|
6250
|
-
},
|
6251
|
-
squashPolicyPush: (policy2) => {
|
6252
|
-
var _a;
|
6253
|
-
return `${policy2.name}--${policy2.as}--${policy2.for}--${(_a = policy2.to) == null ? void 0 : _a.join(",")}`;
|
6254
|
-
},
|
6255
6165
|
squashPK: (pk) => {
|
6256
6166
|
return `${pk.columns.join(",")};${pk.name}`;
|
6257
6167
|
},
|
@@ -6354,9 +6264,6 @@ var init_pgSchema = __esm({
|
|
6354
6264
|
return PgSquasher.squashUnique(unq);
|
6355
6265
|
}
|
6356
6266
|
);
|
6357
|
-
const squashedPolicies = mapValues(it[1].policies, (policy2) => {
|
6358
|
-
return action === "push" ? PgSquasher.squashPolicyPush(policy2) : PgSquasher.squashPolicy(policy2);
|
6359
|
-
});
|
6360
6267
|
return [
|
6361
6268
|
it[0],
|
6362
6269
|
{
|
@@ -6366,8 +6273,7 @@ var init_pgSchema = __esm({
|
|
6366
6273
|
indexes: squashedIndexes,
|
6367
6274
|
foreignKeys: squashedFKs,
|
6368
6275
|
compositePrimaryKeys: squashedPKs,
|
6369
|
-
uniqueConstraints: squashedUniqueConstraints
|
6370
|
-
policies: squashedPolicies
|
6276
|
+
uniqueConstraints: squashedUniqueConstraints
|
6371
6277
|
}
|
6372
6278
|
];
|
6373
6279
|
})
|
@@ -6390,8 +6296,7 @@ var init_pgSchema = __esm({
|
|
6390
6296
|
tables: mappedTables,
|
6391
6297
|
enums: json.enums,
|
6392
6298
|
schemas: json.schemas,
|
6393
|
-
sequences: mappedSequences
|
6394
|
-
roles: json.roles
|
6299
|
+
sequences: mappedSequences
|
6395
6300
|
};
|
6396
6301
|
};
|
6397
6302
|
dryPg = pgSchema.parse({
|
@@ -10691,10 +10596,10 @@ var require_inflight = __commonJS({
|
|
10691
10596
|
}
|
10692
10597
|
function slice(args) {
|
10693
10598
|
var length = args.length;
|
10694
|
-
var
|
10599
|
+
var array = [];
|
10695
10600
|
for (var i2 = 0; i2 < length; i2++)
|
10696
|
-
|
10697
|
-
return
|
10601
|
+
array[i2] = args[i2];
|
10602
|
+
return array;
|
10698
10603
|
}
|
10699
10604
|
}
|
10700
10605
|
});
|
@@ -11517,13 +11422,6 @@ var init_cli = __esm({
|
|
11517
11422
|
breakpoints: booleanType().optional().default(true),
|
11518
11423
|
migrations: objectType({
|
11519
11424
|
prefix: prefix.optional().default("index")
|
11520
|
-
}).optional(),
|
11521
|
-
entities: objectType({
|
11522
|
-
roles: booleanType().or(objectType({
|
11523
|
-
provider: stringType().optional(),
|
11524
|
-
include: stringType().array().optional(),
|
11525
|
-
exclude: stringType().array().optional()
|
11526
|
-
})).optional().default(false)
|
11527
11425
|
}).optional()
|
11528
11426
|
}).passthrough();
|
11529
11427
|
configCheck = objectType({
|
@@ -17711,8 +17609,7 @@ var init_utils4 = __esm({
|
|
17711
17609
|
credentials: parsed2.data,
|
17712
17610
|
tablesFilter,
|
17713
17611
|
schemasFilter,
|
17714
|
-
prefix: ((_a = config.migrations) == null ? void 0 : _a.prefix) || "index"
|
17715
|
-
entities: config.entities
|
17612
|
+
prefix: ((_a = config.migrations) == null ? void 0 : _a.prefix) || "index"
|
17716
17613
|
};
|
17717
17614
|
}
|
17718
17615
|
if (dialect4 === "mysql") {
|
@@ -17729,8 +17626,7 @@ var init_utils4 = __esm({
|
|
17729
17626
|
credentials: parsed2.data,
|
17730
17627
|
tablesFilter,
|
17731
17628
|
schemasFilter,
|
17732
|
-
prefix: ((_b = config.migrations) == null ? void 0 : _b.prefix) || "index"
|
17733
|
-
entities: config.entities
|
17629
|
+
prefix: ((_b = config.migrations) == null ? void 0 : _b.prefix) || "index"
|
17734
17630
|
};
|
17735
17631
|
}
|
17736
17632
|
if (dialect4 === "sqlite") {
|
@@ -17747,8 +17643,7 @@ var init_utils4 = __esm({
|
|
17747
17643
|
credentials: parsed2.data,
|
17748
17644
|
tablesFilter,
|
17749
17645
|
schemasFilter,
|
17750
|
-
prefix: ((_c = config.migrations) == null ? void 0 : _c.prefix) || "index"
|
17751
|
-
entities: config.entities
|
17646
|
+
prefix: ((_c = config.migrations) == null ? void 0 : _c.prefix) || "index"
|
17752
17647
|
};
|
17753
17648
|
}
|
17754
17649
|
if (dialect4 === "turso") {
|
@@ -18604,7 +18499,6 @@ var init_pgImports = __esm({
|
|
18604
18499
|
const enums = [];
|
18605
18500
|
const schemas = [];
|
18606
18501
|
const sequences = [];
|
18607
|
-
const roles = [];
|
18608
18502
|
const i0values = Object.values(exports2);
|
18609
18503
|
i0values.forEach((t2) => {
|
18610
18504
|
if ((0, import_pg_core.isPgEnum)(t2)) {
|
@@ -18620,18 +18514,14 @@ var init_pgImports = __esm({
|
|
18620
18514
|
if ((0, import_pg_core.isPgSequence)(t2)) {
|
18621
18515
|
sequences.push(t2);
|
18622
18516
|
}
|
18623
|
-
if ((0, import_drizzle_orm4.is)(t2, import_pg_core.PgRole)) {
|
18624
|
-
roles.push(t2);
|
18625
|
-
}
|
18626
18517
|
});
|
18627
|
-
return { tables, enums, schemas, sequences
|
18518
|
+
return { tables, enums, schemas, sequences };
|
18628
18519
|
};
|
18629
18520
|
prepareFromPgImports = async (imports) => {
|
18630
18521
|
let tables = [];
|
18631
18522
|
let enums = [];
|
18632
18523
|
let schemas = [];
|
18633
18524
|
let sequences = [];
|
18634
|
-
let roles = [];
|
18635
18525
|
const { unregister } = await safeRegister();
|
18636
18526
|
for (let i2 = 0; i2 < imports.length; i2++) {
|
18637
18527
|
const it = imports[i2];
|
@@ -18641,10 +18531,9 @@ var init_pgImports = __esm({
|
|
18641
18531
|
enums.push(...prepared.enums);
|
18642
18532
|
schemas.push(...prepared.schemas);
|
18643
18533
|
sequences.push(...prepared.sequences);
|
18644
|
-
roles.push(...prepared.roles);
|
18645
18534
|
}
|
18646
18535
|
unregister();
|
18647
|
-
return { tables: Array.from(new Set(tables)), enums, schemas, sequences
|
18536
|
+
return { tables: Array.from(new Set(tables)), enums, schemas, sequences };
|
18648
18537
|
};
|
18649
18538
|
}
|
18650
18539
|
});
|
@@ -18652,11 +18541,9 @@ var init_pgImports = __esm({
|
|
18652
18541
|
// src/serializer/pgSerializer.ts
|
18653
18542
|
var pgSerializer_exports = {};
|
18654
18543
|
__export(pgSerializer_exports, {
|
18655
|
-
buildArrayString: () => buildArrayString,
|
18656
18544
|
fromDatabase: () => fromDatabase2,
|
18657
18545
|
generatePgSnapshot: () => generatePgSnapshot,
|
18658
|
-
indexName: () => indexName2
|
18659
|
-
minRangeForIdentityBasedOn: () => minRangeForIdentityBasedOn
|
18546
|
+
indexName: () => indexName2
|
18660
18547
|
});
|
18661
18548
|
function stringFromIdentityProperty(field) {
|
18662
18549
|
return typeof field === "string" ? field : typeof field === "undefined" ? void 0 : String(field);
|
@@ -18670,9 +18557,9 @@ function minRangeForIdentityBasedOn(columnType) {
|
|
18670
18557
|
function stringFromDatabaseIdentityProperty(field) {
|
18671
18558
|
return typeof field === "string" ? field : typeof field === "undefined" ? void 0 : typeof field === "bigint" ? field.toString() : String(field);
|
18672
18559
|
}
|
18673
|
-
function buildArrayString(
|
18560
|
+
function buildArrayString(array, sqlType) {
|
18674
18561
|
sqlType = sqlType.split("[")[0];
|
18675
|
-
const values =
|
18562
|
+
const values = array.map((value) => {
|
18676
18563
|
if (typeof value === "number" || typeof value === "bigint") {
|
18677
18564
|
return value.toString();
|
18678
18565
|
} else if (typeof value === "boolean") {
|
@@ -18694,40 +18581,6 @@ function buildArrayString(array2, sqlType) {
|
|
18694
18581
|
}).join(",");
|
18695
18582
|
return `{${values}}`;
|
18696
18583
|
}
|
18697
|
-
function prepareRoles(entities) {
|
18698
|
-
let useRoles = false;
|
18699
|
-
const includeRoles = [];
|
18700
|
-
const excludeRoles = [];
|
18701
|
-
if (entities && entities.roles) {
|
18702
|
-
if (typeof entities.roles === "object") {
|
18703
|
-
if (entities.roles.provider) {
|
18704
|
-
if (entities.roles.provider === "supabase") {
|
18705
|
-
excludeRoles.push(...[
|
18706
|
-
"anon",
|
18707
|
-
"authenticator",
|
18708
|
-
"authenticated",
|
18709
|
-
"service_role",
|
18710
|
-
"supabase_auth_admin",
|
18711
|
-
"supabase_storage_admin",
|
18712
|
-
"dashboard_user",
|
18713
|
-
"supabase_admin"
|
18714
|
-
]);
|
18715
|
-
} else if (entities.roles.provider === "neon") {
|
18716
|
-
excludeRoles.push(...["authenticated", "anonymous"]);
|
18717
|
-
}
|
18718
|
-
}
|
18719
|
-
if (entities.roles.include) {
|
18720
|
-
includeRoles.push(...entities.roles.include);
|
18721
|
-
}
|
18722
|
-
if (entities.roles.exclude) {
|
18723
|
-
excludeRoles.push(...entities.roles.exclude);
|
18724
|
-
}
|
18725
|
-
} else {
|
18726
|
-
useRoles = entities.roles;
|
18727
|
-
}
|
18728
|
-
}
|
18729
|
-
return { useRoles, includeRoles, excludeRoles };
|
18730
|
-
}
|
18731
18584
|
var import_drizzle_orm5, import_pg_core2, import_pg_core3, indexName2, generatePgSnapshot, trimChar, fromDatabase2, defaultForColumn;
|
18732
18585
|
var init_pgSerializer = __esm({
|
18733
18586
|
"src/serializer/pgSerializer.ts"() {
|
@@ -18743,12 +18596,11 @@ var init_pgSerializer = __esm({
|
|
18743
18596
|
indexName2 = (tableName, columns) => {
|
18744
18597
|
return `${tableName}_${columns.join("_")}_index`;
|
18745
18598
|
};
|
18746
|
-
generatePgSnapshot = (tables, enums, schemas, sequences,
|
18599
|
+
generatePgSnapshot = (tables, enums, schemas, sequences, casing2, schemaFilter) => {
|
18747
18600
|
var _a, _b, _c, _d, _e, _f;
|
18748
18601
|
const dialect4 = new import_pg_core2.PgDialect({ casing: casing2 });
|
18749
18602
|
const result = {};
|
18750
18603
|
const sequencesToReturn = {};
|
18751
|
-
const rolesToReturn = {};
|
18752
18604
|
const indexesInSchema = {};
|
18753
18605
|
for (const table4 of tables) {
|
18754
18606
|
const {
|
@@ -18759,8 +18611,7 @@ var init_pgSerializer = __esm({
|
|
18759
18611
|
checks,
|
18760
18612
|
schema: schema5,
|
18761
18613
|
primaryKeys,
|
18762
|
-
uniqueConstraints
|
18763
|
-
policies
|
18614
|
+
uniqueConstraints
|
18764
18615
|
} = (0, import_pg_core3.getTableConfig)(table4);
|
18765
18616
|
if (schemaFilter && !schemaFilter.includes(schema5 ?? "public")) {
|
18766
18617
|
continue;
|
@@ -18770,7 +18621,6 @@ var init_pgSerializer = __esm({
|
|
18770
18621
|
const foreignKeysObject = {};
|
18771
18622
|
const primaryKeysObject = {};
|
18772
18623
|
const uniqueConstraintObject = {};
|
18773
|
-
const policiesObject = {};
|
18774
18624
|
columns.forEach((column7) => {
|
18775
18625
|
var _a2, _b2, _c2, _d2, _e2, _f2;
|
18776
18626
|
const name = getColumnCasing(column7, casing2);
|
@@ -19035,35 +18885,6 @@ ${withStyle.errorWarning(
|
|
19035
18885
|
with: value.config.with ?? {}
|
19036
18886
|
};
|
19037
18887
|
});
|
19038
|
-
policies.forEach((policy2) => {
|
19039
|
-
var _a2, _b2;
|
19040
|
-
const mappedTo = [];
|
19041
|
-
if (!policy2.to) {
|
19042
|
-
mappedTo.push("public");
|
19043
|
-
} else {
|
19044
|
-
if (policy2.to && typeof policy2.to === "string") {
|
19045
|
-
mappedTo.push(policy2.to);
|
19046
|
-
} else if (policy2.to && (0, import_drizzle_orm5.is)(policy2.to, import_pg_core2.PgRole)) {
|
19047
|
-
mappedTo.push(policy2.to.name);
|
19048
|
-
} else if (policy2.to && Array.isArray(policy2.to)) {
|
19049
|
-
policy2.to.forEach((it) => {
|
19050
|
-
if (typeof it === "string") {
|
19051
|
-
mappedTo.push(it);
|
19052
|
-
} else if ((0, import_drizzle_orm5.is)(it, import_pg_core2.PgRole)) {
|
19053
|
-
mappedTo.push(it.name);
|
19054
|
-
}
|
19055
|
-
});
|
19056
|
-
}
|
19057
|
-
}
|
19058
|
-
policiesObject[policy2.name] = {
|
19059
|
-
name: policy2.name,
|
19060
|
-
as: ((_a2 = policy2.as) == null ? void 0 : _a2.toUpperCase()) ?? "PERMISSIVE",
|
19061
|
-
for: ((_b2 = policy2.for) == null ? void 0 : _b2.toUpperCase()) ?? "ALL",
|
19062
|
-
to: mappedTo.sort(),
|
19063
|
-
using: (0, import_drizzle_orm5.is)(policy2.using, import_drizzle_orm5.SQL) ? dialect4.sqlToQuery(policy2.using).sql : void 0,
|
19064
|
-
withCheck: (0, import_drizzle_orm5.is)(policy2.withCheck, import_drizzle_orm5.SQL) ? dialect4.sqlToQuery(policy2.withCheck).sql : void 0
|
19065
|
-
};
|
19066
|
-
});
|
19067
18888
|
const tableKey2 = `${schema5 ?? "public"}.${tableName}`;
|
19068
18889
|
result[tableKey2] = {
|
19069
18890
|
name: tableName,
|
@@ -19072,8 +18893,7 @@ ${withStyle.errorWarning(
|
|
19072
18893
|
indexes: indexesObject,
|
19073
18894
|
foreignKeys: foreignKeysObject,
|
19074
18895
|
compositePrimaryKeys: primaryKeysObject,
|
19075
|
-
uniqueConstraints: uniqueConstraintObject
|
19076
|
-
policies: policiesObject
|
18896
|
+
uniqueConstraints: uniqueConstraintObject
|
19077
18897
|
};
|
19078
18898
|
}
|
19079
18899
|
for (const sequence of sequences) {
|
@@ -19097,16 +18917,6 @@ ${withStyle.errorWarning(
|
|
19097
18917
|
} else {
|
19098
18918
|
}
|
19099
18919
|
}
|
19100
|
-
for (const role of roles) {
|
19101
|
-
if (!role._existing) {
|
19102
|
-
rolesToReturn[role.name] = {
|
19103
|
-
name: role.name,
|
19104
|
-
createDb: role.createDb === void 0 ? false : role.createDb,
|
19105
|
-
createRole: role.createRole === void 0 ? false : role.createRole,
|
19106
|
-
inherit: role.inherit === void 0 ? true : role.inherit
|
19107
|
-
};
|
19108
|
-
}
|
19109
|
-
}
|
19110
18920
|
const enumsToReturn = enums.reduce((map, obj) => {
|
19111
18921
|
const enumSchema3 = obj.schema || "public";
|
19112
18922
|
const key = `${enumSchema3}.${obj.enumName}`;
|
@@ -19133,7 +18943,6 @@ ${withStyle.errorWarning(
|
|
19133
18943
|
enums: enumsToReturn,
|
19134
18944
|
schemas: schemasObject,
|
19135
18945
|
sequences: sequencesToReturn,
|
19136
|
-
roles: rolesToReturn,
|
19137
18946
|
_meta: {
|
19138
18947
|
schemas: {},
|
19139
18948
|
tables: {},
|
@@ -19150,7 +18959,7 @@ ${withStyle.errorWarning(
|
|
19150
18959
|
--end;
|
19151
18960
|
return start > 0 || end < str.length ? str.substring(start, end) : str.toString();
|
19152
18961
|
};
|
19153
|
-
fromDatabase2 = async (db, tablesFilter = () => true, schemaFilters,
|
18962
|
+
fromDatabase2 = async (db, tablesFilter = () => true, schemaFilters, progressCallback) => {
|
19154
18963
|
const result = {};
|
19155
18964
|
const internals = { tables: {} };
|
19156
18965
|
const where = schemaFilters.map((t2) => `table_schema = '${t2}'`).join(" or ");
|
@@ -19232,64 +19041,6 @@ ${withStyle.errorWarning(
|
|
19232
19041
|
if (progressCallback) {
|
19233
19042
|
progressCallback("enums", Object.keys(enumsToReturn).length, "done");
|
19234
19043
|
}
|
19235
|
-
const allRoles = await db.query(
|
19236
|
-
`SELECT rolname, rolinherit, rolcreatedb, rolcreaterole FROM pg_roles;`
|
19237
|
-
);
|
19238
|
-
const rolesToReturn = {};
|
19239
|
-
const preparedRoles = prepareRoles(entities);
|
19240
|
-
if (preparedRoles.useRoles || !(preparedRoles.includeRoles.length === 0 && preparedRoles.excludeRoles.length === 0)) {
|
19241
|
-
for (const dbRole of allRoles) {
|
19242
|
-
if (preparedRoles.useRoles) {
|
19243
|
-
rolesToReturn[dbRole.rolname] = {
|
19244
|
-
createDb: dbRole.rolcreatedb,
|
19245
|
-
createRole: dbRole.rolcreatedb,
|
19246
|
-
inherit: dbRole.rolinherit,
|
19247
|
-
name: dbRole.rolname
|
19248
|
-
};
|
19249
|
-
} else {
|
19250
|
-
if (preparedRoles.includeRoles.length === 0 && preparedRoles.excludeRoles.length === 0)
|
19251
|
-
continue;
|
19252
|
-
if (preparedRoles.includeRoles.includes(dbRole.rolname) && preparedRoles.excludeRoles.includes(dbRole.rolname))
|
19253
|
-
continue;
|
19254
|
-
if (preparedRoles.excludeRoles.includes(dbRole.rolname))
|
19255
|
-
continue;
|
19256
|
-
if (!preparedRoles.includeRoles.includes(dbRole.rolname))
|
19257
|
-
continue;
|
19258
|
-
rolesToReturn[dbRole.rolname] = {
|
19259
|
-
createDb: dbRole.rolcreatedb,
|
19260
|
-
createRole: dbRole.rolcreaterole,
|
19261
|
-
inherit: dbRole.rolinherit,
|
19262
|
-
name: dbRole.rolname
|
19263
|
-
};
|
19264
|
-
}
|
19265
|
-
}
|
19266
|
-
}
|
19267
|
-
const wherePolicies = schemaFilters.map((t2) => `schemaname = '${t2}'`).join(" or ");
|
19268
|
-
const policiesByTable = {};
|
19269
|
-
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}`};`);
|
19270
|
-
for (const dbPolicy of allPolicies) {
|
19271
|
-
const { tablename, schemaname, to, withCheck, using, ...rest } = dbPolicy;
|
19272
|
-
const tableForPolicy = policiesByTable[`${schemaname}.${tablename}`];
|
19273
|
-
const parsedTo = to === "{}" ? [] : to.substring(1, to.length - 1).split(/\s*,\s*/g).sort();
|
19274
|
-
const parsedWithCheck = withCheck === null ? void 0 : withCheck;
|
19275
|
-
const parsedUsing = using === null ? void 0 : using;
|
19276
|
-
if (tableForPolicy) {
|
19277
|
-
tableForPolicy[dbPolicy.name] = { ...rest, to: parsedTo };
|
19278
|
-
} else {
|
19279
|
-
policiesByTable[`${schemaname}.${tablename}`] = {
|
19280
|
-
[dbPolicy.name]: { ...rest, to: parsedTo, withCheck: parsedWithCheck, using: parsedUsing }
|
19281
|
-
};
|
19282
|
-
}
|
19283
|
-
}
|
19284
|
-
if (progressCallback) {
|
19285
|
-
progressCallback(
|
19286
|
-
"policies",
|
19287
|
-
Object.values(policiesByTable).reduce((total, innerRecord) => {
|
19288
|
-
return total + Object.keys(innerRecord).length;
|
19289
|
-
}, 0),
|
19290
|
-
"done"
|
19291
|
-
);
|
19292
|
-
}
|
19293
19044
|
const sequencesInColumns = [];
|
19294
19045
|
const all = allTables.map((row) => {
|
19295
19046
|
return new Promise(async (res, rej) => {
|
@@ -19686,8 +19437,7 @@ ${withStyle.errorWarning(
|
|
19686
19437
|
indexes: indexToReturn,
|
19687
19438
|
foreignKeys: foreignKeysToReturn,
|
19688
19439
|
compositePrimaryKeys: primaryKeys,
|
19689
|
-
uniqueConstraints: uniqueConstrains
|
19690
|
-
policies: policiesByTable[`${tableSchema}.${tableName}`] ?? {}
|
19440
|
+
uniqueConstraints: uniqueConstrains
|
19691
19441
|
};
|
19692
19442
|
} catch (e2) {
|
19693
19443
|
rej(e2);
|
@@ -19714,7 +19464,6 @@ ${withStyle.errorWarning(
|
|
19714
19464
|
enums: enumsToReturn,
|
19715
19465
|
schemas: schemasObject,
|
19716
19466
|
sequences: sequencesToReturn,
|
19717
|
-
roles: rolesToReturn,
|
19718
19467
|
_meta: {
|
19719
19468
|
schemas: {},
|
19720
19469
|
tables: {},
|
@@ -20379,10 +20128,10 @@ ${filenames.join("\n")}
|
|
20379
20128
|
const filenames = prepareFilenames(path5);
|
20380
20129
|
const { prepareFromPgImports: prepareFromPgImports2 } = await Promise.resolve().then(() => (init_pgImports(), pgImports_exports));
|
20381
20130
|
const { generatePgSnapshot: generatePgSnapshot2 } = await Promise.resolve().then(() => (init_pgSerializer(), pgSerializer_exports));
|
20382
|
-
const { tables, enums, schemas, sequences
|
20131
|
+
const { tables, enums, schemas, sequences } = await prepareFromPgImports2(
|
20383
20132
|
filenames
|
20384
20133
|
);
|
20385
|
-
return generatePgSnapshot2(tables, enums, schemas, sequences,
|
20134
|
+
return generatePgSnapshot2(tables, enums, schemas, sequences, casing2, schemaFilter);
|
20386
20135
|
};
|
20387
20136
|
serializeSQLite = async (path5, casing2) => {
|
20388
20137
|
const filenames = prepareFilenames(path5);
|
@@ -20577,57 +20326,57 @@ var require_heap = __commonJS({
|
|
20577
20326
|
}
|
20578
20327
|
return [].splice.apply(a, [lo, lo - lo].concat(x2)), x2;
|
20579
20328
|
};
|
20580
|
-
heappush = function(
|
20329
|
+
heappush = function(array, item, cmp) {
|
20581
20330
|
if (cmp == null) {
|
20582
20331
|
cmp = defaultCmp;
|
20583
20332
|
}
|
20584
|
-
|
20585
|
-
return _siftdown(
|
20333
|
+
array.push(item);
|
20334
|
+
return _siftdown(array, 0, array.length - 1, cmp);
|
20586
20335
|
};
|
20587
|
-
heappop = function(
|
20336
|
+
heappop = function(array, cmp) {
|
20588
20337
|
var lastelt, returnitem;
|
20589
20338
|
if (cmp == null) {
|
20590
20339
|
cmp = defaultCmp;
|
20591
20340
|
}
|
20592
|
-
lastelt =
|
20593
|
-
if (
|
20594
|
-
returnitem =
|
20595
|
-
|
20596
|
-
_siftup(
|
20341
|
+
lastelt = array.pop();
|
20342
|
+
if (array.length) {
|
20343
|
+
returnitem = array[0];
|
20344
|
+
array[0] = lastelt;
|
20345
|
+
_siftup(array, 0, cmp);
|
20597
20346
|
} else {
|
20598
20347
|
returnitem = lastelt;
|
20599
20348
|
}
|
20600
20349
|
return returnitem;
|
20601
20350
|
};
|
20602
|
-
heapreplace = function(
|
20351
|
+
heapreplace = function(array, item, cmp) {
|
20603
20352
|
var returnitem;
|
20604
20353
|
if (cmp == null) {
|
20605
20354
|
cmp = defaultCmp;
|
20606
20355
|
}
|
20607
|
-
returnitem =
|
20608
|
-
|
20609
|
-
_siftup(
|
20356
|
+
returnitem = array[0];
|
20357
|
+
array[0] = item;
|
20358
|
+
_siftup(array, 0, cmp);
|
20610
20359
|
return returnitem;
|
20611
20360
|
};
|
20612
|
-
heappushpop = function(
|
20361
|
+
heappushpop = function(array, item, cmp) {
|
20613
20362
|
var _ref;
|
20614
20363
|
if (cmp == null) {
|
20615
20364
|
cmp = defaultCmp;
|
20616
20365
|
}
|
20617
|
-
if (
|
20618
|
-
_ref = [
|
20619
|
-
_siftup(
|
20366
|
+
if (array.length && cmp(array[0], item) < 0) {
|
20367
|
+
_ref = [array[0], item], item = _ref[0], array[0] = _ref[1];
|
20368
|
+
_siftup(array, 0, cmp);
|
20620
20369
|
}
|
20621
20370
|
return item;
|
20622
20371
|
};
|
20623
|
-
heapify = function(
|
20372
|
+
heapify = function(array, cmp) {
|
20624
20373
|
var i2, _i, _j, _len, _ref, _ref1, _results, _results1;
|
20625
20374
|
if (cmp == null) {
|
20626
20375
|
cmp = defaultCmp;
|
20627
20376
|
}
|
20628
20377
|
_ref1 = function() {
|
20629
20378
|
_results1 = [];
|
20630
|
-
for (var _j2 = 0, _ref2 = floor(
|
20379
|
+
for (var _j2 = 0, _ref2 = floor(array.length / 2); 0 <= _ref2 ? _j2 < _ref2 : _j2 > _ref2; 0 <= _ref2 ? _j2++ : _j2--) {
|
20631
20380
|
_results1.push(_j2);
|
20632
20381
|
}
|
20633
20382
|
return _results1;
|
@@ -20635,51 +20384,51 @@ var require_heap = __commonJS({
|
|
20635
20384
|
_results = [];
|
20636
20385
|
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
20637
20386
|
i2 = _ref1[_i];
|
20638
|
-
_results.push(_siftup(
|
20387
|
+
_results.push(_siftup(array, i2, cmp));
|
20639
20388
|
}
|
20640
20389
|
return _results;
|
20641
20390
|
};
|
20642
|
-
updateItem = function(
|
20391
|
+
updateItem = function(array, item, cmp) {
|
20643
20392
|
var pos;
|
20644
20393
|
if (cmp == null) {
|
20645
20394
|
cmp = defaultCmp;
|
20646
20395
|
}
|
20647
|
-
pos =
|
20396
|
+
pos = array.indexOf(item);
|
20648
20397
|
if (pos === -1) {
|
20649
20398
|
return;
|
20650
20399
|
}
|
20651
|
-
_siftdown(
|
20652
|
-
return _siftup(
|
20400
|
+
_siftdown(array, 0, pos, cmp);
|
20401
|
+
return _siftup(array, pos, cmp);
|
20653
20402
|
};
|
20654
|
-
nlargest = function(
|
20403
|
+
nlargest = function(array, n, cmp) {
|
20655
20404
|
var elem, result, _i, _len, _ref;
|
20656
20405
|
if (cmp == null) {
|
20657
20406
|
cmp = defaultCmp;
|
20658
20407
|
}
|
20659
|
-
result =
|
20408
|
+
result = array.slice(0, n);
|
20660
20409
|
if (!result.length) {
|
20661
20410
|
return result;
|
20662
20411
|
}
|
20663
20412
|
heapify(result, cmp);
|
20664
|
-
_ref =
|
20413
|
+
_ref = array.slice(n);
|
20665
20414
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
20666
20415
|
elem = _ref[_i];
|
20667
20416
|
heappushpop(result, elem, cmp);
|
20668
20417
|
}
|
20669
20418
|
return result.sort(cmp).reverse();
|
20670
20419
|
};
|
20671
|
-
nsmallest = function(
|
20420
|
+
nsmallest = function(array, n, cmp) {
|
20672
20421
|
var elem, i2, los, result, _i, _j, _len, _ref, _ref1, _results;
|
20673
20422
|
if (cmp == null) {
|
20674
20423
|
cmp = defaultCmp;
|
20675
20424
|
}
|
20676
|
-
if (n * 10 <=
|
20677
|
-
result =
|
20425
|
+
if (n * 10 <= array.length) {
|
20426
|
+
result = array.slice(0, n).sort(cmp);
|
20678
20427
|
if (!result.length) {
|
20679
20428
|
return result;
|
20680
20429
|
}
|
20681
20430
|
los = result[result.length - 1];
|
20682
|
-
_ref =
|
20431
|
+
_ref = array.slice(n);
|
20683
20432
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
20684
20433
|
elem = _ref[_i];
|
20685
20434
|
if (cmp(elem, los) < 0) {
|
@@ -20690,51 +20439,51 @@ var require_heap = __commonJS({
|
|
20690
20439
|
}
|
20691
20440
|
return result;
|
20692
20441
|
}
|
20693
|
-
heapify(
|
20442
|
+
heapify(array, cmp);
|
20694
20443
|
_results = [];
|
20695
|
-
for (i2 = _j = 0, _ref1 = min(n,
|
20696
|
-
_results.push(heappop(
|
20444
|
+
for (i2 = _j = 0, _ref1 = min(n, array.length); 0 <= _ref1 ? _j < _ref1 : _j > _ref1; i2 = 0 <= _ref1 ? ++_j : --_j) {
|
20445
|
+
_results.push(heappop(array, cmp));
|
20697
20446
|
}
|
20698
20447
|
return _results;
|
20699
20448
|
};
|
20700
|
-
_siftdown = function(
|
20449
|
+
_siftdown = function(array, startpos, pos, cmp) {
|
20701
20450
|
var newitem, parent, parentpos;
|
20702
20451
|
if (cmp == null) {
|
20703
20452
|
cmp = defaultCmp;
|
20704
20453
|
}
|
20705
|
-
newitem =
|
20454
|
+
newitem = array[pos];
|
20706
20455
|
while (pos > startpos) {
|
20707
20456
|
parentpos = pos - 1 >> 1;
|
20708
|
-
parent =
|
20457
|
+
parent = array[parentpos];
|
20709
20458
|
if (cmp(newitem, parent) < 0) {
|
20710
|
-
|
20459
|
+
array[pos] = parent;
|
20711
20460
|
pos = parentpos;
|
20712
20461
|
continue;
|
20713
20462
|
}
|
20714
20463
|
break;
|
20715
20464
|
}
|
20716
|
-
return
|
20465
|
+
return array[pos] = newitem;
|
20717
20466
|
};
|
20718
|
-
_siftup = function(
|
20467
|
+
_siftup = function(array, pos, cmp) {
|
20719
20468
|
var childpos, endpos, newitem, rightpos, startpos;
|
20720
20469
|
if (cmp == null) {
|
20721
20470
|
cmp = defaultCmp;
|
20722
20471
|
}
|
20723
|
-
endpos =
|
20472
|
+
endpos = array.length;
|
20724
20473
|
startpos = pos;
|
20725
|
-
newitem =
|
20474
|
+
newitem = array[pos];
|
20726
20475
|
childpos = 2 * pos + 1;
|
20727
20476
|
while (childpos < endpos) {
|
20728
20477
|
rightpos = childpos + 1;
|
20729
|
-
if (rightpos < endpos && !(cmp(
|
20478
|
+
if (rightpos < endpos && !(cmp(array[childpos], array[rightpos]) < 0)) {
|
20730
20479
|
childpos = rightpos;
|
20731
20480
|
}
|
20732
|
-
|
20481
|
+
array[pos] = array[childpos];
|
20733
20482
|
pos = childpos;
|
20734
20483
|
childpos = 2 * pos + 1;
|
20735
20484
|
}
|
20736
|
-
|
20737
|
-
return _siftdown(
|
20485
|
+
array[pos] = newitem;
|
20486
|
+
return _siftdown(array, startpos, pos, cmp);
|
20738
20487
|
};
|
20739
20488
|
Heap = function() {
|
20740
20489
|
Heap2.push = heappush;
|
@@ -22647,12 +22396,12 @@ var require_lib = __commonJS({
|
|
22647
22396
|
}
|
22648
22397
|
return bestMatch;
|
22649
22398
|
}
|
22650
|
-
scalarize(
|
22399
|
+
scalarize(array, originals, fuzzyOriginals) {
|
22651
22400
|
const fuzzyMatches = [];
|
22652
22401
|
if (fuzzyOriginals) {
|
22653
22402
|
const keyScores = {};
|
22654
|
-
for (let index4 = 0; index4 <
|
22655
|
-
const item =
|
22403
|
+
for (let index4 = 0; index4 < array.length; index4++) {
|
22404
|
+
const item = array[index4];
|
22656
22405
|
if (this.isScalar(item)) {
|
22657
22406
|
continue;
|
22658
22407
|
}
|
@@ -22666,8 +22415,8 @@ var require_lib = __commonJS({
|
|
22666
22415
|
}
|
22667
22416
|
}
|
22668
22417
|
const result = [];
|
22669
|
-
for (let index4 = 0; index4 <
|
22670
|
-
const item =
|
22418
|
+
for (let index4 = 0; index4 < array.length; index4++) {
|
22419
|
+
const item = array[index4];
|
22671
22420
|
if (this.isScalar(item)) {
|
22672
22421
|
result.push(item);
|
22673
22422
|
} else {
|
@@ -22889,37 +22638,6 @@ function diffColumns(left, right) {
|
|
22889
22638
|
);
|
22890
22639
|
return alteredTables;
|
22891
22640
|
}
|
22892
|
-
function diffPolicies(left, right) {
|
22893
|
-
left = JSON.parse(JSON.stringify(left));
|
22894
|
-
right = JSON.parse(JSON.stringify(right));
|
22895
|
-
const result = (0, import_json_diff.diff)(left, right) ?? {};
|
22896
|
-
const alteredTables = Object.fromEntries(
|
22897
|
-
Object.entries(result).filter((it) => {
|
22898
|
-
return !(it[0].includes("__added") || it[0].includes("__deleted"));
|
22899
|
-
}).map((tableEntry) => {
|
22900
|
-
const deletedPolicies = Object.entries(tableEntry[1].policies ?? {}).filter((it) => {
|
22901
|
-
return it[0].endsWith("__deleted");
|
22902
|
-
}).map((it) => {
|
22903
|
-
return it[1];
|
22904
|
-
});
|
22905
|
-
const addedPolicies = Object.entries(tableEntry[1].policies ?? {}).filter((it) => {
|
22906
|
-
return it[0].endsWith("__added");
|
22907
|
-
}).map((it) => {
|
22908
|
-
return it[1];
|
22909
|
-
});
|
22910
|
-
tableEntry[1].policies = {
|
22911
|
-
added: addedPolicies,
|
22912
|
-
deleted: deletedPolicies
|
22913
|
-
};
|
22914
|
-
const table4 = left[tableEntry[0]];
|
22915
|
-
return [
|
22916
|
-
tableEntry[0],
|
22917
|
-
{ name: table4.name, schema: table4.schema, ...tableEntry[1] }
|
22918
|
-
];
|
22919
|
-
})
|
22920
|
-
);
|
22921
|
-
return alteredTables;
|
22922
|
-
}
|
22923
22641
|
function applyJsonDiff(json1, json2) {
|
22924
22642
|
json1 = JSON.parse(JSON.stringify(json1));
|
22925
22643
|
json2 = JSON.parse(JSON.stringify(json2));
|
@@ -22929,7 +22647,6 @@ function applyJsonDiff(json1, json2) {
|
|
22929
22647
|
difference.tables = difference.tables || {};
|
22930
22648
|
difference.enums = difference.enums || {};
|
22931
22649
|
difference.sequences = difference.sequences || {};
|
22932
|
-
difference.roles = difference.roles || {};
|
22933
22650
|
const schemaKeys = Object.keys(difference.schemas);
|
22934
22651
|
for (let key of schemaKeys) {
|
22935
22652
|
if (key.endsWith("__added") || key.endsWith("__deleted")) {
|
@@ -22985,10 +22702,6 @@ function applyJsonDiff(json1, json2) {
|
|
22985
22702
|
const alteredSequences = sequencesEntries.filter((it) => !(it[0].includes("__added") || it[0].includes("__deleted")) && "values" in it[1]).map((it) => {
|
22986
22703
|
return json2.sequences[it[0]];
|
22987
22704
|
});
|
22988
|
-
const rolesEntries = Object.entries(difference.roles);
|
22989
|
-
const alteredRoles = rolesEntries.filter((it) => !(it[0].includes("__added") || it[0].includes("__deleted"))).map((it) => {
|
22990
|
-
return json2.roles[it[0]];
|
22991
|
-
});
|
22992
22705
|
const alteredTablesWithColumns = Object.values(difference.tables).map(
|
22993
22706
|
(table4) => {
|
22994
22707
|
return findAlternationsInTable(table4);
|
@@ -22997,8 +22710,7 @@ function applyJsonDiff(json1, json2) {
|
|
22997
22710
|
return {
|
22998
22711
|
alteredTablesWithColumns,
|
22999
22712
|
alteredEnums,
|
23000
|
-
alteredSequences
|
23001
|
-
alteredRoles
|
22713
|
+
alteredSequences
|
23002
22714
|
};
|
23003
22715
|
}
|
23004
22716
|
var import_json_diff, mapArraysDiff, findAlternationsInTable, alternationsInColumn;
|
@@ -23058,21 +22770,6 @@ var init_jsonDiffer = __esm({
|
|
23058
22770
|
return !it[0].endsWith("__deleted") && !it[0].endsWith("__added");
|
23059
22771
|
})
|
23060
22772
|
);
|
23061
|
-
const deletedPolicies = Object.fromEntries(
|
23062
|
-
Object.entries(table4.policies__deleted || {}).concat(
|
23063
|
-
Object.entries(table4.policies || {}).filter((it) => it[0].includes("__deleted"))
|
23064
|
-
).map((entry) => [entry[0].replace("__deleted", ""), entry[1]])
|
23065
|
-
);
|
23066
|
-
const addedPolicies = Object.fromEntries(
|
23067
|
-
Object.entries(table4.policies__added || {}).concat(
|
23068
|
-
Object.entries(table4.policies || {}).filter((it) => it[0].includes("__added"))
|
23069
|
-
).map((entry) => [entry[0].replace("__added", ""), entry[1]])
|
23070
|
-
);
|
23071
|
-
const alteredPolicies = Object.fromEntries(
|
23072
|
-
Object.entries(table4.policies || {}).filter((it) => {
|
23073
|
-
return !it[0].endsWith("__deleted") && !it[0].endsWith("__added");
|
23074
|
-
})
|
23075
|
-
);
|
23076
22773
|
const deletedForeignKeys = Object.fromEntries(
|
23077
22774
|
Object.entries(table4.foreignKeys__deleted || {}).concat(
|
23078
22775
|
Object.entries(table4.foreignKeys || {}).filter((it) => it[0].includes("__deleted"))
|
@@ -23134,10 +22831,7 @@ var init_jsonDiffer = __esm({
|
|
23134
22831
|
alteredCompositePKs,
|
23135
22832
|
addedUniqueConstraints,
|
23136
22833
|
deletedUniqueConstraints,
|
23137
|
-
alteredUniqueConstraints
|
23138
|
-
deletedPolicies,
|
23139
|
-
addedPolicies,
|
23140
|
-
alteredPolicies
|
22834
|
+
alteredUniqueConstraints
|
23141
22835
|
};
|
23142
22836
|
};
|
23143
22837
|
alternationsInColumn = (column7) => {
|
@@ -23411,7 +23105,7 @@ function fromJson(statements, dialect4, action, json2) {
|
|
23411
23105
|
}).filter((it) => it !== "");
|
23412
23106
|
return result;
|
23413
23107
|
}
|
23414
|
-
var pgNativeTypes, isPgNativeType, Convertor,
|
23108
|
+
var pgNativeTypes, isPgNativeType, Convertor, PgCreateTableConvertor, MySqlCreateTableConvertor, SQLiteCreateTableConvertor, PgAlterTableAlterColumnSetGenerated, PgAlterTableAlterColumnDropGenerated, PgAlterTableAlterColumnAlterGenerated, PgAlterTableAddUniqueConstraintConvertor, PgAlterTableDropUniqueConstraintConvertor, MySQLAlterTableAddUniqueConstraintConvertor, MySQLAlterTableDropUniqueConstraintConvertor, 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;
|
23415
23109
|
var init_sqlgenerator = __esm({
|
23416
23110
|
"src/sqlgenerator.ts"() {
|
23417
23111
|
"use strict";
|
@@ -23468,110 +23162,12 @@ var init_sqlgenerator = __esm({
|
|
23468
23162
|
};
|
23469
23163
|
Convertor = class {
|
23470
23164
|
};
|
23471
|
-
PgCreateRoleConvertor = class extends Convertor {
|
23472
|
-
can(statement, dialect4) {
|
23473
|
-
return statement.type === "create_role" && dialect4 === "postgresql";
|
23474
|
-
}
|
23475
|
-
convert(statement) {
|
23476
|
-
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"}` : ""};`;
|
23477
|
-
}
|
23478
|
-
};
|
23479
|
-
PgDropRoleConvertor = class extends Convertor {
|
23480
|
-
can(statement, dialect4) {
|
23481
|
-
return statement.type === "drop_role" && dialect4 === "postgresql";
|
23482
|
-
}
|
23483
|
-
convert(statement) {
|
23484
|
-
return `DROP ROLE "${statement.name}";`;
|
23485
|
-
}
|
23486
|
-
};
|
23487
|
-
PgRenameRoleConvertor = class extends Convertor {
|
23488
|
-
can(statement, dialect4) {
|
23489
|
-
return statement.type === "rename_role" && dialect4 === "postgresql";
|
23490
|
-
}
|
23491
|
-
convert(statement) {
|
23492
|
-
return `ALTER ROLE "${statement.nameFrom}" RENAME TO "${statement.nameTo}";`;
|
23493
|
-
}
|
23494
|
-
};
|
23495
|
-
PgAlterRoleConvertor = class extends Convertor {
|
23496
|
-
can(statement, dialect4) {
|
23497
|
-
return statement.type === "alter_role" && dialect4 === "postgresql";
|
23498
|
-
}
|
23499
|
-
convert(statement) {
|
23500
|
-
return `ALTER ROLE "${statement.name}"${` WITH${statement.values.createDb ? " CREATEDB" : " NOCREATEDB"}${statement.values.createRole ? " CREATEROLE" : " NOCREATEROLE"}${statement.values.inherit ? " INHERIT" : " NOINHERIT"}`};`;
|
23501
|
-
}
|
23502
|
-
};
|
23503
|
-
PgCreatePolicyConvertor = class extends Convertor {
|
23504
|
-
can(statement, dialect4) {
|
23505
|
-
return statement.type === "create_policy" && dialect4 === "postgresql";
|
23506
|
-
}
|
23507
|
-
convert(statement) {
|
23508
|
-
var _a, _b, _c;
|
23509
|
-
const policy2 = statement.data;
|
23510
|
-
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
23511
|
-
const usingPart = policy2.using ? ` USING (${policy2.using})` : "";
|
23512
|
-
const withCheckPart = policy2.withCheck ? ` WITH CHECK (${policy2.withCheck})` : "";
|
23513
|
-
const policyToPart = (_a = policy2.to) == null ? void 0 : _a.map(
|
23514
|
-
(v) => ["current_user", "current_role", "session_user", "public"].includes(v) ? v : `"${v}"`
|
23515
|
-
).join(", ");
|
23516
|
-
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};`;
|
23517
|
-
}
|
23518
|
-
};
|
23519
|
-
PgDropPolicyConvertor = class extends Convertor {
|
23520
|
-
can(statement, dialect4) {
|
23521
|
-
return statement.type === "drop_policy" && dialect4 === "postgresql";
|
23522
|
-
}
|
23523
|
-
convert(statement) {
|
23524
|
-
const policy2 = statement.data;
|
23525
|
-
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
23526
|
-
return `DROP POLICY "${policy2.name}" ON ${tableNameWithSchema} CASCADE;`;
|
23527
|
-
}
|
23528
|
-
};
|
23529
|
-
PgRenamePolicyConvertor = class extends Convertor {
|
23530
|
-
can(statement, dialect4) {
|
23531
|
-
return statement.type === "rename_policy" && dialect4 === "postgresql";
|
23532
|
-
}
|
23533
|
-
convert(statement) {
|
23534
|
-
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
23535
|
-
return `ALTER POLICY "${statement.oldName}" ON ${tableNameWithSchema} RENAME TO "${statement.newName}";`;
|
23536
|
-
}
|
23537
|
-
};
|
23538
|
-
PgAlterPolicyConvertor = class extends Convertor {
|
23539
|
-
can(statement, dialect4) {
|
23540
|
-
return statement.type === "alter_policy" && dialect4 === "postgresql";
|
23541
|
-
}
|
23542
|
-
convert(statement) {
|
23543
|
-
const newPolicy = PgSquasher.unsquashPolicy(statement.newData);
|
23544
|
-
const oldPolicy = PgSquasher.unsquashPolicy(statement.oldData);
|
23545
|
-
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
23546
|
-
const usingPart = newPolicy.using ? ` USING (${newPolicy.using})` : oldPolicy.using ? ` USING (${oldPolicy.using})` : "";
|
23547
|
-
const withCheckPart = newPolicy.withCheck ? ` WITH CHECK (${newPolicy.withCheck})` : oldPolicy.withCheck ? ` WITH CHECK (${oldPolicy.withCheck})` : "";
|
23548
|
-
return `ALTER POLICY "${oldPolicy.name}" ON ${tableNameWithSchema} TO ${newPolicy.to}${usingPart}${withCheckPart};`;
|
23549
|
-
}
|
23550
|
-
};
|
23551
|
-
PgEnableRlsConvertor = class extends Convertor {
|
23552
|
-
can(statement, dialect4) {
|
23553
|
-
return statement.type === "enable_rls" && dialect4 === "postgresql";
|
23554
|
-
}
|
23555
|
-
convert(statement) {
|
23556
|
-
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
23557
|
-
return `ALTER TABLE ${tableNameWithSchema} ENABLE ROW LEVEL SECURITY;`;
|
23558
|
-
}
|
23559
|
-
};
|
23560
|
-
PgDisableRlsConvertor = class extends Convertor {
|
23561
|
-
can(statement, dialect4) {
|
23562
|
-
return statement.type === "disable_rls" && dialect4 === "postgresql";
|
23563
|
-
}
|
23564
|
-
convert(statement) {
|
23565
|
-
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
23566
|
-
return `ALTER TABLE ${tableNameWithSchema} DISABLE ROW LEVEL SECURITY;`;
|
23567
|
-
}
|
23568
|
-
};
|
23569
23165
|
PgCreateTableConvertor = class extends Convertor {
|
23570
23166
|
can(statement, dialect4) {
|
23571
23167
|
return statement.type === "create_table" && dialect4 === "postgresql";
|
23572
23168
|
}
|
23573
23169
|
convert(st) {
|
23574
|
-
const { tableName, schema: schema5, columns, compositePKs, uniqueConstraints
|
23170
|
+
const { tableName, schema: schema5, columns, compositePKs, uniqueConstraints } = st;
|
23575
23171
|
let statement = "";
|
23576
23172
|
const name = schema5 ? `"${schema5}"."${tableName}"` : `"${tableName}"`;
|
23577
23173
|
statement += `CREATE TABLE IF NOT EXISTS ${name} (
|
@@ -23608,12 +23204,7 @@ var init_sqlgenerator = __esm({
|
|
23608
23204
|
);`;
|
23609
23205
|
statement += `
|
23610
23206
|
`;
|
23611
|
-
|
23612
|
-
type: "enable_rls",
|
23613
|
-
tableName,
|
23614
|
-
schema: schema5
|
23615
|
-
});
|
23616
|
-
return [statement, ...policies && policies.length > 0 ? [enableRls] : []];
|
23207
|
+
return statement;
|
23617
23208
|
}
|
23618
23209
|
};
|
23619
23210
|
MySqlCreateTableConvertor = class extends Convertor {
|
@@ -23898,20 +23489,22 @@ var init_sqlgenerator = __esm({
|
|
23898
23489
|
}
|
23899
23490
|
convert(st) {
|
23900
23491
|
const { name, values, schema: schema5 } = st;
|
23901
|
-
const
|
23492
|
+
const enumNameWithSchema = schema5 ? `"${schema5}"."${name}"` : `"${name}"`;
|
23902
23493
|
let valuesStatement = "(";
|
23903
23494
|
valuesStatement += values.map((it) => `'${it}'`).join(", ");
|
23904
23495
|
valuesStatement += ")";
|
23905
|
-
let statement =
|
23906
|
-
statement
|
23907
|
-
|
23908
|
-
|
23909
|
-
|
23910
|
-
|
23911
|
-
statement
|
23912
|
-
|
23913
|
-
|
23914
|
-
|
23496
|
+
let statement = `CREATE TYPE ${enumNameWithSchema} AS ENUM${valuesStatement};`;
|
23497
|
+
return statement;
|
23498
|
+
}
|
23499
|
+
};
|
23500
|
+
DropTypeEnumConvertor = class extends Convertor {
|
23501
|
+
can(statement) {
|
23502
|
+
return statement.type === "drop_type_enum";
|
23503
|
+
}
|
23504
|
+
convert(st) {
|
23505
|
+
const { name, schema: schema5 } = st;
|
23506
|
+
const enumNameWithSchema = schema5 ? `"${schema5}"."${name}"` : `"${name}"`;
|
23507
|
+
let statement = `DROP TYPE ${enumNameWithSchema};`;
|
23915
23508
|
return statement;
|
23916
23509
|
}
|
23917
23510
|
};
|
@@ -23920,9 +23513,56 @@ var init_sqlgenerator = __esm({
|
|
23920
23513
|
return statement.type === "alter_type_add_value";
|
23921
23514
|
}
|
23922
23515
|
convert(st) {
|
23923
|
-
const { name, schema: schema5, value } = st;
|
23924
|
-
const
|
23925
|
-
return `ALTER TYPE ${
|
23516
|
+
const { name, schema: schema5, value, before } = st;
|
23517
|
+
const enumNameWithSchema = schema5 ? `"${schema5}"."${name}"` : `"${name}"`;
|
23518
|
+
return `ALTER TYPE ${enumNameWithSchema} ADD VALUE '${value}'${before.length ? ` BEFORE '${before}'` : ""};`;
|
23519
|
+
}
|
23520
|
+
};
|
23521
|
+
AlterTypeSetSchemaConvertor = class extends Convertor {
|
23522
|
+
can(statement) {
|
23523
|
+
return statement.type === "move_type_enum";
|
23524
|
+
}
|
23525
|
+
convert(st) {
|
23526
|
+
const { name, schemaFrom, schemaTo } = st;
|
23527
|
+
const enumNameWithSchema = schemaFrom ? `"${schemaFrom}"."${name}"` : `"${name}"`;
|
23528
|
+
return `ALTER TYPE ${enumNameWithSchema} SET SCHEMA "${schemaTo}";`;
|
23529
|
+
}
|
23530
|
+
};
|
23531
|
+
AlterRenameTypeConvertor = class extends Convertor {
|
23532
|
+
can(statement) {
|
23533
|
+
return statement.type === "rename_type_enum";
|
23534
|
+
}
|
23535
|
+
convert(st) {
|
23536
|
+
const { nameTo, nameFrom, schema: schema5 } = st;
|
23537
|
+
const enumNameWithSchema = schema5 ? `"${schema5}"."${nameFrom}"` : `"${nameFrom}"`;
|
23538
|
+
return `ALTER TYPE ${enumNameWithSchema} RENAME TO "${nameTo}";`;
|
23539
|
+
}
|
23540
|
+
};
|
23541
|
+
AlterTypeDropValueConvertor = class extends Convertor {
|
23542
|
+
can(statement) {
|
23543
|
+
return statement.type === "alter_type_drop_value";
|
23544
|
+
}
|
23545
|
+
convert(st) {
|
23546
|
+
const { columnsWithEnum, name, newValues, schema: schema5 } = st;
|
23547
|
+
const statements = [];
|
23548
|
+
for (const withEnum of columnsWithEnum) {
|
23549
|
+
statements.push(
|
23550
|
+
`ALTER TABLE "${withEnum.schema}"."${withEnum.table}" ALTER COLUMN "${withEnum.column}" SET DATA TYPE text;`
|
23551
|
+
);
|
23552
|
+
}
|
23553
|
+
statements.push(new DropTypeEnumConvertor().convert({ name, schema: schema5, type: "drop_type_enum" }));
|
23554
|
+
statements.push(new CreateTypeEnumConvertor().convert({
|
23555
|
+
name,
|
23556
|
+
schema: schema5,
|
23557
|
+
values: newValues,
|
23558
|
+
type: "create_type_enum"
|
23559
|
+
}));
|
23560
|
+
for (const withEnum of columnsWithEnum) {
|
23561
|
+
statements.push(
|
23562
|
+
`ALTER TABLE "${withEnum.schema}"."${withEnum.table}" ALTER COLUMN "${withEnum.column}" SET DATA TYPE "${schema5}"."${name}" USING "${withEnum.column}"::"${schema5}"."${name}";`
|
23563
|
+
);
|
23564
|
+
}
|
23565
|
+
return statements;
|
23926
23566
|
}
|
23927
23567
|
};
|
23928
23568
|
PgDropTableConvertor = class extends Convertor {
|
@@ -23930,21 +23570,9 @@ var init_sqlgenerator = __esm({
|
|
23930
23570
|
return statement.type === "drop_table" && dialect4 === "postgresql";
|
23931
23571
|
}
|
23932
23572
|
convert(statement) {
|
23933
|
-
const { tableName, schema: schema5
|
23573
|
+
const { tableName, schema: schema5 } = statement;
|
23934
23574
|
const tableNameWithSchema = schema5 ? `"${schema5}"."${tableName}"` : `"${tableName}"`;
|
23935
|
-
|
23936
|
-
const droppedPolicies = (policies == null ? void 0 : policies.map((p2) => {
|
23937
|
-
return dropPolicyConvertor.convert({
|
23938
|
-
type: "drop_policy",
|
23939
|
-
tableName,
|
23940
|
-
data: PgSquasher.unsquashPolicy(p2),
|
23941
|
-
schema: schema5
|
23942
|
-
});
|
23943
|
-
})) ?? [];
|
23944
|
-
return [
|
23945
|
-
...droppedPolicies,
|
23946
|
-
`DROP TABLE ${tableNameWithSchema};`
|
23947
|
-
];
|
23575
|
+
return `DROP TABLE ${tableNameWithSchema};`;
|
23948
23576
|
}
|
23949
23577
|
};
|
23950
23578
|
MySQLDropTableConvertor = class extends Convertor {
|
@@ -25081,6 +24709,11 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
25081
24709
|
convertors.push(new SQLiteRecreateTableConvertor());
|
25082
24710
|
convertors.push(new LibSQLRecreateTableConvertor());
|
25083
24711
|
convertors.push(new CreateTypeEnumConvertor());
|
24712
|
+
convertors.push(new DropTypeEnumConvertor());
|
24713
|
+
convertors.push(new AlterTypeAddValueConvertor());
|
24714
|
+
convertors.push(new AlterTypeSetSchemaConvertor());
|
24715
|
+
convertors.push(new AlterRenameTypeConvertor());
|
24716
|
+
convertors.push(new AlterTypeDropValueConvertor());
|
25084
24717
|
convertors.push(new CreatePgSequenceConvertor());
|
25085
24718
|
convertors.push(new DropPgSequenceConvertor());
|
25086
24719
|
convertors.push(new RenamePgSequenceConvertor());
|
@@ -25112,23 +24745,12 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
25112
24745
|
convertors.push(new PgDropIndexConvertor());
|
25113
24746
|
convertors.push(new SqliteDropIndexConvertor());
|
25114
24747
|
convertors.push(new MySqlDropIndexConvertor());
|
25115
|
-
convertors.push(new AlterTypeAddValueConvertor());
|
25116
24748
|
convertors.push(new PgAlterTableAlterColumnSetPrimaryKeyConvertor());
|
25117
24749
|
convertors.push(new PgAlterTableAlterColumnDropPrimaryKeyConvertor());
|
25118
24750
|
convertors.push(new PgAlterTableAlterColumnSetNotNullConvertor());
|
25119
24751
|
convertors.push(new PgAlterTableAlterColumnDropNotNullConvertor());
|
25120
24752
|
convertors.push(new PgAlterTableAlterColumnSetDefaultConvertor());
|
25121
24753
|
convertors.push(new PgAlterTableAlterColumnDropDefaultConvertor());
|
25122
|
-
convertors.push(new PgAlterPolicyConvertor());
|
25123
|
-
convertors.push(new PgCreatePolicyConvertor());
|
25124
|
-
convertors.push(new PgDropPolicyConvertor());
|
25125
|
-
convertors.push(new PgRenamePolicyConvertor());
|
25126
|
-
convertors.push(new PgEnableRlsConvertor());
|
25127
|
-
convertors.push(new PgDisableRlsConvertor());
|
25128
|
-
convertors.push(new PgDropRoleConvertor());
|
25129
|
-
convertors.push(new PgAlterRoleConvertor());
|
25130
|
-
convertors.push(new PgCreateRoleConvertor());
|
25131
|
-
convertors.push(new PgRenameRoleConvertor());
|
25132
24754
|
convertors.push(new PgAlterTableAlterColumnSetExpressionConvertor());
|
25133
24755
|
convertors.push(new PgAlterTableAlterColumnDropGeneratedConvertor());
|
25134
24756
|
convertors.push(new PgAlterTableAlterColumnAlterrGeneratedConvertor());
|
@@ -25424,7 +25046,7 @@ var init_sqlitePushUtils = __esm({
|
|
25424
25046
|
});
|
25425
25047
|
|
25426
25048
|
// src/jsonStatements.ts
|
25427
|
-
var preparePgCreateTableJson, prepareMySqlCreateTableJson, prepareSQLiteCreateTable, prepareDropTableJson, prepareRenameTableJson, prepareCreateEnumJson, prepareAddValuesToEnumJson, prepareDropEnumJson, prepareMoveEnumJson, prepareRenameEnumJson, prepareCreateSequenceJson, prepareAlterSequenceJson, prepareDropSequenceJson, prepareMoveSequenceJson, prepareRenameSequenceJson,
|
25049
|
+
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, prepareAddCompositePrimaryKeyMySql, prepareDeleteCompositePrimaryKeyMySql, prepareAlterCompositePrimaryKeyMySql;
|
25428
25050
|
var init_jsonStatements = __esm({
|
25429
25051
|
"src/jsonStatements.ts"() {
|
25430
25052
|
"use strict";
|
@@ -25435,7 +25057,7 @@ var init_jsonStatements = __esm({
|
|
25435
25057
|
init_pgSchema();
|
25436
25058
|
init_sqliteSchema();
|
25437
25059
|
preparePgCreateTableJson = (table4, json2) => {
|
25438
|
-
const { name, schema: schema5, columns, compositePrimaryKeys, uniqueConstraints
|
25060
|
+
const { name, schema: schema5, columns, compositePrimaryKeys, uniqueConstraints } = table4;
|
25439
25061
|
const tableKey2 = `${schema5 || "public"}.${name}`;
|
25440
25062
|
const compositePkName = Object.values(compositePrimaryKeys).length > 0 ? json2.tables[tableKey2].compositePrimaryKeys[`${PgSquasher.unsquashPK(Object.values(compositePrimaryKeys)[0]).name}`].name : "";
|
25441
25063
|
return {
|
@@ -25445,8 +25067,7 @@ var init_jsonStatements = __esm({
|
|
25445
25067
|
columns: Object.values(columns),
|
25446
25068
|
compositePKs: Object.values(compositePrimaryKeys),
|
25447
25069
|
compositePkName,
|
25448
|
-
uniqueConstraints: Object.values(uniqueConstraints)
|
25449
|
-
policies: Object.values(policies)
|
25070
|
+
uniqueConstraints: Object.values(uniqueConstraints)
|
25450
25071
|
};
|
25451
25072
|
};
|
25452
25073
|
prepareMySqlCreateTableJson = (table4, json2, internals) => {
|
@@ -25484,8 +25105,7 @@ var init_jsonStatements = __esm({
|
|
25484
25105
|
return {
|
25485
25106
|
type: "drop_table",
|
25486
25107
|
tableName: table4.name,
|
25487
|
-
schema: table4.schema
|
25488
|
-
policies: table4.policies ? Object.values(table4.policies) : []
|
25108
|
+
schema: table4.schema
|
25489
25109
|
};
|
25490
25110
|
};
|
25491
25111
|
prepareRenameTableJson = (tableFrom, tableTo) => {
|
@@ -25516,6 +25136,28 @@ var init_jsonStatements = __esm({
|
|
25516
25136
|
};
|
25517
25137
|
});
|
25518
25138
|
};
|
25139
|
+
prepareDropEnumValues = (name, schema5, removedValues, json2) => {
|
25140
|
+
if (!removedValues.length)
|
25141
|
+
return [];
|
25142
|
+
const affectedColumns = [];
|
25143
|
+
for (const tableKey2 in json2.tables) {
|
25144
|
+
const table4 = json2.tables[tableKey2];
|
25145
|
+
for (const columnKey in table4.columns) {
|
25146
|
+
const column7 = table4.columns[columnKey];
|
25147
|
+
if (column7.type === name && column7.typeSchema === schema5) {
|
25148
|
+
affectedColumns.push({ schema: table4.schema || "public", table: table4.name, column: column7.name });
|
25149
|
+
}
|
25150
|
+
}
|
25151
|
+
}
|
25152
|
+
return [{
|
25153
|
+
type: "alter_type_drop_value",
|
25154
|
+
name,
|
25155
|
+
schema: schema5,
|
25156
|
+
deletedValues: removedValues,
|
25157
|
+
newValues: json2.enums[`${schema5}.${name}`].values,
|
25158
|
+
columnsWithEnum: affectedColumns
|
25159
|
+
}];
|
25160
|
+
};
|
25519
25161
|
prepareDropEnumJson = (name, schema5) => {
|
25520
25162
|
return {
|
25521
25163
|
type: "drop_type_enum",
|
@@ -25582,41 +25224,6 @@ var init_jsonStatements = __esm({
|
|
25582
25224
|
schema: schema5
|
25583
25225
|
};
|
25584
25226
|
};
|
25585
|
-
prepareCreateRoleJson = (role) => {
|
25586
|
-
return {
|
25587
|
-
type: "create_role",
|
25588
|
-
name: role.name,
|
25589
|
-
values: {
|
25590
|
-
createDb: role.createDb,
|
25591
|
-
createRole: role.createRole,
|
25592
|
-
inherit: role.inherit
|
25593
|
-
}
|
25594
|
-
};
|
25595
|
-
};
|
25596
|
-
prepareAlterRoleJson = (role) => {
|
25597
|
-
return {
|
25598
|
-
type: "alter_role",
|
25599
|
-
name: role.name,
|
25600
|
-
values: {
|
25601
|
-
createDb: role.createDb,
|
25602
|
-
createRole: role.createRole,
|
25603
|
-
inherit: role.inherit
|
25604
|
-
}
|
25605
|
-
};
|
25606
|
-
};
|
25607
|
-
prepareDropRoleJson = (name) => {
|
25608
|
-
return {
|
25609
|
-
type: "drop_role",
|
25610
|
-
name
|
25611
|
-
};
|
25612
|
-
};
|
25613
|
-
prepareRenameRoleJson = (nameFrom, nameTo) => {
|
25614
|
-
return {
|
25615
|
-
type: "rename_role",
|
25616
|
-
nameFrom,
|
25617
|
-
nameTo
|
25618
|
-
};
|
25619
|
-
};
|
25620
25227
|
prepareCreateSchemasJson = (values) => {
|
25621
25228
|
return values.map((it) => {
|
25622
25229
|
return {
|
@@ -26517,46 +26124,6 @@ var init_jsonStatements = __esm({
|
|
26517
26124
|
}
|
26518
26125
|
return [...dropPkStatements, ...setPkStatements, ...statements];
|
26519
26126
|
};
|
26520
|
-
prepareRenamePolicyJsons = (tableName, schema5, renames) => {
|
26521
|
-
return renames.map((it) => {
|
26522
|
-
return {
|
26523
|
-
type: "rename_policy",
|
26524
|
-
tableName,
|
26525
|
-
oldName: it.from.name,
|
26526
|
-
newName: it.to.name,
|
26527
|
-
schema: schema5
|
26528
|
-
};
|
26529
|
-
});
|
26530
|
-
};
|
26531
|
-
prepareCreatePolicyJsons = (tableName, schema5, policies) => {
|
26532
|
-
return policies.map((it) => {
|
26533
|
-
return {
|
26534
|
-
type: "create_policy",
|
26535
|
-
tableName,
|
26536
|
-
data: it,
|
26537
|
-
schema: schema5
|
26538
|
-
};
|
26539
|
-
});
|
26540
|
-
};
|
26541
|
-
prepareDropPolicyJsons = (tableName, schema5, policies) => {
|
26542
|
-
return policies.map((it) => {
|
26543
|
-
return {
|
26544
|
-
type: "drop_policy",
|
26545
|
-
tableName,
|
26546
|
-
data: it,
|
26547
|
-
schema: schema5
|
26548
|
-
};
|
26549
|
-
});
|
26550
|
-
};
|
26551
|
-
prepareAlterPolicyJson = (tableName, schema5, oldPolicy, newPolicy) => {
|
26552
|
-
return {
|
26553
|
-
type: "alter_policy",
|
26554
|
-
tableName,
|
26555
|
-
oldData: oldPolicy,
|
26556
|
-
newData: newPolicy,
|
26557
|
-
schema: schema5
|
26558
|
-
};
|
26559
|
-
};
|
26560
26127
|
preparePgCreateIndexesJson = (tableName, schema5, indexes, fullSchema, action) => {
|
26561
26128
|
if (action === "push") {
|
26562
26129
|
return Object.values(indexes).map((indexData) => {
|
@@ -27230,8 +26797,7 @@ var init_snapshotsDiffer = __esm({
|
|
27230
26797
|
indexes: recordType(stringType(), stringType()),
|
27231
26798
|
foreignKeys: recordType(stringType(), stringType()),
|
27232
26799
|
compositePrimaryKeys: recordType(stringType(), stringType()).default({}),
|
27233
|
-
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
27234
|
-
policies: recordType(stringType(), stringType()).default({})
|
26800
|
+
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
27235
26801
|
}).strict();
|
27236
26802
|
alteredTableScheme = objectType({
|
27237
26803
|
name: stringType(),
|
@@ -27272,22 +26838,12 @@ var init_snapshotsDiffer = __esm({
|
|
27272
26838
|
__new: stringType(),
|
27273
26839
|
__old: stringType()
|
27274
26840
|
})
|
27275
|
-
),
|
27276
|
-
addedPolicies: recordType(stringType(), stringType()),
|
27277
|
-
deletedPolicies: recordType(stringType(), stringType()),
|
27278
|
-
alteredPolicies: recordType(
|
27279
|
-
stringType(),
|
27280
|
-
objectType({
|
27281
|
-
__new: stringType(),
|
27282
|
-
__old: stringType()
|
27283
|
-
})
|
27284
26841
|
)
|
27285
26842
|
}).strict();
|
27286
26843
|
diffResultScheme = objectType({
|
27287
26844
|
alteredTablesWithColumns: alteredTableScheme.array(),
|
27288
26845
|
alteredEnums: changedEnumSchema.array(),
|
27289
|
-
alteredSequences: sequenceSquashed.array()
|
27290
|
-
alteredRoles: roleSchema.array()
|
26846
|
+
alteredSequences: sequenceSquashed.array()
|
27291
26847
|
}).strict();
|
27292
26848
|
diffResultSchemeMysql = objectType({
|
27293
26849
|
alteredTablesWithColumns: alteredTableScheme.array(),
|
@@ -27342,7 +26898,7 @@ var init_snapshotsDiffer = __esm({
|
|
27342
26898
|
}
|
27343
26899
|
return column7;
|
27344
26900
|
};
|
27345
|
-
applyPgSnapshotsDiff = async (json1, json2, schemasResolver2, enumsResolver2, sequencesResolver2,
|
26901
|
+
applyPgSnapshotsDiff = async (json1, json2, schemasResolver2, enumsResolver2, sequencesResolver2, tablesResolver2, columnsResolver2, prevFull, curFull, action) => {
|
27346
26902
|
const schemasDiff = diffSchemasOrTables(json1.schemas, json2.schemas);
|
27347
26903
|
const {
|
27348
26904
|
created: createdSchemas,
|
@@ -27492,47 +27048,6 @@ var init_snapshotsDiffer = __esm({
|
|
27492
27048
|
return [tableKey2, tableValue];
|
27493
27049
|
}
|
27494
27050
|
);
|
27495
|
-
const rolesDiff = diffSchemasOrTables(
|
27496
|
-
schemasPatchedSnap1.roles,
|
27497
|
-
json2.roles
|
27498
|
-
);
|
27499
|
-
const {
|
27500
|
-
created: createdRoles,
|
27501
|
-
deleted: deletedRoles,
|
27502
|
-
renamed: renamedRoles
|
27503
|
-
} = await roleResolver2({
|
27504
|
-
created: rolesDiff.added,
|
27505
|
-
deleted: rolesDiff.deleted
|
27506
|
-
});
|
27507
|
-
schemasPatchedSnap1.roles = mapEntries(
|
27508
|
-
schemasPatchedSnap1.roles,
|
27509
|
-
(_2, it) => {
|
27510
|
-
const { name } = nameChangeFor(it, renamedRoles);
|
27511
|
-
it.name = name;
|
27512
|
-
return [name, it];
|
27513
|
-
}
|
27514
|
-
);
|
27515
|
-
const rolesChangeMap = renamedRoles.reduce(
|
27516
|
-
(acc, it) => {
|
27517
|
-
acc[it.from.name] = {
|
27518
|
-
nameFrom: it.from.name,
|
27519
|
-
nameTo: it.to.name
|
27520
|
-
};
|
27521
|
-
return acc;
|
27522
|
-
},
|
27523
|
-
{}
|
27524
|
-
);
|
27525
|
-
schemasPatchedSnap1.roles = mapEntries(
|
27526
|
-
schemasPatchedSnap1.roles,
|
27527
|
-
(roleKey, roleValue) => {
|
27528
|
-
const key = roleKey;
|
27529
|
-
const change = rolesChangeMap[key];
|
27530
|
-
if (change) {
|
27531
|
-
roleValue.name = change.nameTo;
|
27532
|
-
}
|
27533
|
-
return [roleKey, roleValue];
|
27534
|
-
}
|
27535
|
-
);
|
27536
27051
|
const tablesDiff = diffSchemasOrTables(
|
27537
27052
|
schemasPatchedSnap1.tables,
|
27538
27053
|
json2.tables
|
@@ -27611,65 +27126,6 @@ var init_snapshotsDiffer = __esm({
|
|
27611
27126
|
return [tableKey2, tableValue];
|
27612
27127
|
}
|
27613
27128
|
);
|
27614
|
-
const policyRes = diffPolicies(tablesPatchedSnap1.tables, json2.tables);
|
27615
|
-
const policyRenames = [];
|
27616
|
-
const policyCreates = [];
|
27617
|
-
const policyDeletes = [];
|
27618
|
-
for (let entry of Object.values(policyRes)) {
|
27619
|
-
const { renamed, created, deleted } = await policyResolver2({
|
27620
|
-
tableName: entry.name,
|
27621
|
-
schema: entry.schema,
|
27622
|
-
deleted: entry.policies.deleted.map(PgSquasher.unsquashPolicy),
|
27623
|
-
created: entry.policies.added.map(PgSquasher.unsquashPolicy)
|
27624
|
-
});
|
27625
|
-
if (created.length > 0) {
|
27626
|
-
policyCreates.push({
|
27627
|
-
table: entry.name,
|
27628
|
-
schema: entry.schema,
|
27629
|
-
columns: created
|
27630
|
-
});
|
27631
|
-
}
|
27632
|
-
if (deleted.length > 0) {
|
27633
|
-
policyDeletes.push({
|
27634
|
-
table: entry.name,
|
27635
|
-
schema: entry.schema,
|
27636
|
-
columns: deleted
|
27637
|
-
});
|
27638
|
-
}
|
27639
|
-
if (renamed.length > 0) {
|
27640
|
-
policyRenames.push({
|
27641
|
-
table: entry.name,
|
27642
|
-
schema: entry.schema,
|
27643
|
-
renames: renamed
|
27644
|
-
});
|
27645
|
-
}
|
27646
|
-
}
|
27647
|
-
const policyRenamesDict = columnRenames.reduce(
|
27648
|
-
(acc, it) => {
|
27649
|
-
acc[`${it.schema || "public"}.${it.table}`] = it.renames;
|
27650
|
-
return acc;
|
27651
|
-
},
|
27652
|
-
{}
|
27653
|
-
);
|
27654
|
-
const policyPatchedSnap1 = copy(tablesPatchedSnap1);
|
27655
|
-
policyPatchedSnap1.tables = mapEntries(
|
27656
|
-
policyPatchedSnap1.tables,
|
27657
|
-
(tableKey2, tableValue) => {
|
27658
|
-
const patchedPolicies = mapKeys(
|
27659
|
-
tableValue.policies,
|
27660
|
-
(policyKey, policy2) => {
|
27661
|
-
const rens = policyRenamesDict[`${tableValue.schema || "public"}.${tableValue.name}`] || [];
|
27662
|
-
const newName = columnChangeFor(policyKey, rens);
|
27663
|
-
const unsquashedPolicy = PgSquasher.unsquashPolicy(policy2);
|
27664
|
-
unsquashedPolicy.name = newName;
|
27665
|
-
policy2 = PgSquasher.squashPolicy(unsquashedPolicy);
|
27666
|
-
return newName;
|
27667
|
-
}
|
27668
|
-
);
|
27669
|
-
tableValue.policies = patchedPolicies;
|
27670
|
-
return [tableKey2, tableValue];
|
27671
|
-
}
|
27672
|
-
);
|
27673
27129
|
const diffResult = applyJsonDiff(columnsPatchedSnap1, json2);
|
27674
27130
|
const typedResult = diffResultScheme.parse(diffResult);
|
27675
27131
|
const jsonStatements = [];
|
@@ -27714,15 +27170,13 @@ var init_snapshotsDiffer = __esm({
|
|
27714
27170
|
const jsonDeletedUniqueConstraints = [];
|
27715
27171
|
const jsonAlteredUniqueConstraints = [];
|
27716
27172
|
const jsonSetTableSchemas = [];
|
27717
|
-
|
27718
|
-
|
27719
|
-
|
27720
|
-
|
27721
|
-
|
27722
|
-
|
27723
|
-
|
27724
|
-
});
|
27725
|
-
}
|
27173
|
+
for (let it of movedTables) {
|
27174
|
+
jsonSetTableSchemas.push({
|
27175
|
+
type: "alter_table_set_schema",
|
27176
|
+
tableName: it.name,
|
27177
|
+
schemaFrom: it.schemaFrom || "public",
|
27178
|
+
schemaTo: it.schemaTo || "public"
|
27179
|
+
});
|
27726
27180
|
}
|
27727
27181
|
for (let it of alteredTables) {
|
27728
27182
|
let addedColumns = [];
|
@@ -27827,99 +27281,7 @@ var init_snapshotsDiffer = __esm({
|
|
27827
27281
|
it.deletedIndexes || {}
|
27828
27282
|
);
|
27829
27283
|
}).flat();
|
27830
|
-
const jsonCreatePoliciesStatements = [];
|
27831
|
-
const jsonDropPoliciesStatements = [];
|
27832
|
-
const jsonAlterPoliciesStatements = [];
|
27833
|
-
const jsonRenamePoliciesStatements = [];
|
27834
|
-
const jsonEnableRLSStatements = [];
|
27835
|
-
const jsonDisableRLSStatements = [];
|
27836
|
-
for (let it of policyRenames) {
|
27837
|
-
jsonRenamePoliciesStatements.push(
|
27838
|
-
...prepareRenamePolicyJsons(it.table, it.schema, it.renames)
|
27839
|
-
);
|
27840
|
-
}
|
27841
|
-
for (const it of policyCreates) {
|
27842
|
-
jsonCreatePoliciesStatements.push(
|
27843
|
-
...prepareCreatePolicyJsons(
|
27844
|
-
it.table,
|
27845
|
-
it.schema,
|
27846
|
-
it.columns
|
27847
|
-
)
|
27848
|
-
);
|
27849
|
-
}
|
27850
|
-
for (const it of policyDeletes) {
|
27851
|
-
jsonDropPoliciesStatements.push(
|
27852
|
-
...prepareDropPolicyJsons(
|
27853
|
-
it.table,
|
27854
|
-
it.schema,
|
27855
|
-
it.columns
|
27856
|
-
)
|
27857
|
-
);
|
27858
|
-
}
|
27859
27284
|
alteredTables.forEach((it) => {
|
27860
|
-
Object.keys(it.alteredPolicies).forEach((policyName) => {
|
27861
|
-
const newPolicy = PgSquasher.unsquashPolicy(it.alteredPolicies[policyName].__new);
|
27862
|
-
const oldPolicy = PgSquasher.unsquashPolicy(it.alteredPolicies[policyName].__old);
|
27863
|
-
if (newPolicy.as !== oldPolicy.as) {
|
27864
|
-
jsonDropPoliciesStatements.push(
|
27865
|
-
...prepareDropPolicyJsons(
|
27866
|
-
it.name,
|
27867
|
-
it.schema,
|
27868
|
-
[oldPolicy]
|
27869
|
-
)
|
27870
|
-
);
|
27871
|
-
jsonCreatePoliciesStatements.push(
|
27872
|
-
...prepareCreatePolicyJsons(
|
27873
|
-
it.name,
|
27874
|
-
it.schema,
|
27875
|
-
[newPolicy]
|
27876
|
-
)
|
27877
|
-
);
|
27878
|
-
return;
|
27879
|
-
}
|
27880
|
-
if (newPolicy.for !== oldPolicy.for) {
|
27881
|
-
jsonDropPoliciesStatements.push(
|
27882
|
-
...prepareDropPolicyJsons(
|
27883
|
-
it.name,
|
27884
|
-
it.schema,
|
27885
|
-
[oldPolicy]
|
27886
|
-
)
|
27887
|
-
);
|
27888
|
-
jsonCreatePoliciesStatements.push(
|
27889
|
-
...prepareCreatePolicyJsons(
|
27890
|
-
it.name,
|
27891
|
-
it.schema,
|
27892
|
-
[newPolicy]
|
27893
|
-
)
|
27894
|
-
);
|
27895
|
-
return;
|
27896
|
-
}
|
27897
|
-
jsonAlterPoliciesStatements.push(
|
27898
|
-
prepareAlterPolicyJson(
|
27899
|
-
it.name,
|
27900
|
-
it.schema,
|
27901
|
-
it.alteredPolicies[policyName].__old,
|
27902
|
-
it.alteredPolicies[policyName].__new
|
27903
|
-
)
|
27904
|
-
);
|
27905
|
-
});
|
27906
|
-
for (const table4 of Object.values(json2.tables)) {
|
27907
|
-
const policiesInCurrentState = Object.keys(table4.policies);
|
27908
|
-
const tableInPreviousState = columnsPatchedSnap1.tables[`${table4.schema === "" ? "public" : table4.schema}.${table4.name}`];
|
27909
|
-
const policiesInPreviousState = tableInPreviousState ? Object.keys(tableInPreviousState.policies) : [];
|
27910
|
-
if (policiesInPreviousState.length === 0 && policiesInCurrentState.length > 0) {
|
27911
|
-
jsonEnableRLSStatements.push({ type: "enable_rls", tableName: table4.name, schema: table4.schema });
|
27912
|
-
}
|
27913
|
-
if (policiesInPreviousState.length > 0 && policiesInCurrentState.length === 0) {
|
27914
|
-
jsonDisableRLSStatements.push({ type: "disable_rls", tableName: table4.name, schema: table4.schema });
|
27915
|
-
}
|
27916
|
-
}
|
27917
|
-
for (const table4 of Object.values(columnsPatchedSnap1.tables)) {
|
27918
|
-
const tableInCurrentState = json2.tables[`${table4.schema === "" ? "public" : table4.schema}.${table4.name}`];
|
27919
|
-
if (tableInCurrentState === void 0) {
|
27920
|
-
jsonDisableRLSStatements.push({ type: "disable_rls", tableName: table4.name, schema: table4.schema });
|
27921
|
-
}
|
27922
|
-
}
|
27923
27285
|
const droppedIndexes = Object.keys(it.alteredIndexes).reduce(
|
27924
27286
|
(current, item) => {
|
27925
27287
|
current[item] = it.alteredIndexes[item].__old;
|
@@ -27989,6 +27351,9 @@ var init_snapshotsDiffer = __esm({
|
|
27989
27351
|
const jsonAlterEnumsWithAddedValues = typedResult.alteredEnums.map((it) => {
|
27990
27352
|
return prepareAddValuesToEnumJson(it.name, it.schema, it.addedValues);
|
27991
27353
|
}).flat() ?? [];
|
27354
|
+
const jsonAlterEnumsWithDroppedValues = typedResult.alteredEnums.map((it) => {
|
27355
|
+
return prepareDropEnumValues(it.name, it.schema, it.deletedValues, curFull);
|
27356
|
+
}).flat() ?? [];
|
27992
27357
|
const createSequences = createdSequences.map((it) => {
|
27993
27358
|
return prepareCreateSequenceJson(it);
|
27994
27359
|
}) ?? [];
|
@@ -28004,18 +27369,6 @@ var init_snapshotsDiffer = __esm({
|
|
28004
27369
|
const jsonAlterSequences = typedResult.alteredSequences.map((it) => {
|
28005
27370
|
return prepareAlterSequenceJson(it);
|
28006
27371
|
}).flat() ?? [];
|
28007
|
-
const createRoles = createdRoles.map((it) => {
|
28008
|
-
return prepareCreateRoleJson(it);
|
28009
|
-
}) ?? [];
|
28010
|
-
const dropRoles = deletedRoles.map((it) => {
|
28011
|
-
return prepareDropRoleJson(it.name);
|
28012
|
-
});
|
28013
|
-
const renameRoles = renamedRoles.map((it) => {
|
28014
|
-
return prepareRenameRoleJson(it.from.name, it.to.name);
|
28015
|
-
});
|
28016
|
-
const jsonAlterRoles = typedResult.alteredRoles.map((it) => {
|
28017
|
-
return prepareAlterRoleJson(it);
|
28018
|
-
}).flat() ?? [];
|
28019
27372
|
const createSchemas = prepareCreateSchemasJson(
|
28020
27373
|
createdSchemas.map((it) => it.name)
|
28021
27374
|
);
|
@@ -28028,11 +27381,6 @@ var init_snapshotsDiffer = __esm({
|
|
28028
27381
|
const createTables = createdTables.map((it) => {
|
28029
27382
|
return preparePgCreateTableJson(it, curFull);
|
28030
27383
|
});
|
28031
|
-
jsonCreatePoliciesStatements.push(...[].concat(
|
28032
|
-
...createdTables.map(
|
28033
|
-
(it) => prepareCreatePolicyJsons(it.name, it.schema, Object.values(it.policies).map(PgSquasher.unsquashPolicy))
|
28034
|
-
)
|
28035
|
-
));
|
28036
27384
|
jsonStatements.push(...createSchemas);
|
28037
27385
|
jsonStatements.push(...renameSchemas);
|
28038
27386
|
jsonStatements.push(...createEnums);
|
@@ -28043,13 +27391,7 @@ var init_snapshotsDiffer = __esm({
|
|
28043
27391
|
jsonStatements.push(...moveSequences);
|
28044
27392
|
jsonStatements.push(...renameSequences);
|
28045
27393
|
jsonStatements.push(...jsonAlterSequences);
|
28046
|
-
jsonStatements.push(...renameRoles);
|
28047
|
-
jsonStatements.push(...dropRoles);
|
28048
|
-
jsonStatements.push(...createRoles);
|
28049
|
-
jsonStatements.push(...jsonAlterRoles);
|
28050
27394
|
jsonStatements.push(...createTables);
|
28051
|
-
jsonStatements.push(...jsonEnableRLSStatements);
|
28052
|
-
jsonStatements.push(...jsonDisableRLSStatements);
|
28053
27395
|
jsonStatements.push(...jsonDropTables);
|
28054
27396
|
jsonStatements.push(...jsonSetTableSchemas);
|
28055
27397
|
jsonStatements.push(...jsonRenameTables);
|
@@ -28069,10 +27411,7 @@ var init_snapshotsDiffer = __esm({
|
|
28069
27411
|
jsonStatements.push(...jsonAlteredCompositePKs);
|
28070
27412
|
jsonStatements.push(...jsonAddedUniqueConstraints);
|
28071
27413
|
jsonStatements.push(...jsonAlteredUniqueConstraints);
|
28072
|
-
jsonStatements.push(...
|
28073
|
-
jsonStatements.push(...jsonDropPoliciesStatements);
|
28074
|
-
jsonStatements.push(...jsonCreatePoliciesStatements);
|
28075
|
-
jsonStatements.push(...jsonAlterPoliciesStatements);
|
27414
|
+
jsonStatements.push(...jsonAlterEnumsWithDroppedValues);
|
28076
27415
|
jsonStatements.push(...dropEnums);
|
28077
27416
|
jsonStatements.push(...dropSequences);
|
28078
27417
|
jsonStatements.push(...dropSchemas);
|
@@ -28093,7 +27432,17 @@ var init_snapshotsDiffer = __esm({
|
|
28093
27432
|
}
|
28094
27433
|
return true;
|
28095
27434
|
});
|
28096
|
-
const
|
27435
|
+
const filteredEnumsJsonStatements = filteredJsonStatements.filter((st) => {
|
27436
|
+
if (st.type === "alter_type_add_value") {
|
27437
|
+
if (jsonStatements.find(
|
27438
|
+
(it) => it.type === "alter_type_drop_value" && it.name === st.name && it.schema === st.schema
|
27439
|
+
)) {
|
27440
|
+
return false;
|
27441
|
+
}
|
27442
|
+
}
|
27443
|
+
return true;
|
27444
|
+
});
|
27445
|
+
const sqlStatements = fromJson(filteredEnumsJsonStatements, "postgresql");
|
28097
27446
|
const uniqueSqlStatements = [];
|
28098
27447
|
sqlStatements.forEach((ss) => {
|
28099
27448
|
if (!uniqueSqlStatements.includes(ss)) {
|
@@ -28109,7 +27458,7 @@ var init_snapshotsDiffer = __esm({
|
|
28109
27458
|
});
|
28110
27459
|
const _meta = prepareMigrationMeta(rSchemas, rTables, rColumns);
|
28111
27460
|
return {
|
28112
|
-
statements:
|
27461
|
+
statements: filteredEnumsJsonStatements,
|
28113
27462
|
sqlStatements: uniqueSqlStatements,
|
28114
27463
|
_meta
|
28115
27464
|
};
|
@@ -30336,7 +29685,6 @@ __export(migrate_exports, {
|
|
30336
29685
|
columnsResolver: () => columnsResolver,
|
30337
29686
|
embeddedMigrations: () => embeddedMigrations,
|
30338
29687
|
enumsResolver: () => enumsResolver,
|
30339
|
-
policyResolver: () => policyResolver,
|
30340
29688
|
prepareAndMigrateLibSQL: () => prepareAndMigrateLibSQL,
|
30341
29689
|
prepareAndMigrateMysql: () => prepareAndMigrateMysql,
|
30342
29690
|
prepareAndMigratePg: () => prepareAndMigratePg,
|
@@ -30347,16 +29695,14 @@ __export(migrate_exports, {
|
|
30347
29695
|
prepareSQLitePush: () => prepareSQLitePush,
|
30348
29696
|
prepareSnapshotFolderName: () => prepareSnapshotFolderName,
|
30349
29697
|
promptColumnsConflicts: () => promptColumnsConflicts,
|
30350
|
-
promptNamedConflict: () => promptNamedConflict,
|
30351
29698
|
promptNamedWithSchemasConflict: () => promptNamedWithSchemasConflict,
|
30352
29699
|
promptSchemasConflict: () => promptSchemasConflict,
|
30353
|
-
roleResolver: () => roleResolver,
|
30354
29700
|
schemasResolver: () => schemasResolver,
|
30355
29701
|
sequencesResolver: () => sequencesResolver,
|
30356
29702
|
tablesResolver: () => tablesResolver,
|
30357
29703
|
writeResult: () => writeResult
|
30358
29704
|
});
|
30359
|
-
var import_fs5, import_hanji3, import_path4, schemasResolver, tablesResolver, sequencesResolver,
|
29705
|
+
var import_fs5, import_hanji3, import_path4, schemasResolver, tablesResolver, sequencesResolver, enumsResolver, columnsResolver, prepareAndMigratePg, preparePgPush, prepareMySQLPush, prepareAndMigrateMysql, prepareAndMigrateSqlite, prepareAndMigrateLibSQL, prepareSQLitePush, prepareLibSQLPush, promptColumnsConflicts, promptNamedWithSchemasConflict, promptSchemasConflict, BREAKPOINT, writeResult, embeddedMigrations, prepareSnapshotFolderName, two;
|
30360
29706
|
var init_migrate = __esm({
|
30361
29707
|
"src/cli/commands/migrate.ts"() {
|
30362
29708
|
"use strict";
|
@@ -30421,32 +29767,6 @@ var init_migrate = __esm({
|
|
30421
29767
|
throw e2;
|
30422
29768
|
}
|
30423
29769
|
};
|
30424
|
-
roleResolver = async (input) => {
|
30425
|
-
const result = await promptNamedConflict(
|
30426
|
-
input.created,
|
30427
|
-
input.deleted,
|
30428
|
-
"role"
|
30429
|
-
);
|
30430
|
-
return {
|
30431
|
-
created: result.created,
|
30432
|
-
deleted: result.deleted,
|
30433
|
-
renamed: result.renamed
|
30434
|
-
};
|
30435
|
-
};
|
30436
|
-
policyResolver = async (input) => {
|
30437
|
-
const result = await promptColumnsConflicts(
|
30438
|
-
input.tableName,
|
30439
|
-
input.created,
|
30440
|
-
input.deleted
|
30441
|
-
);
|
30442
|
-
return {
|
30443
|
-
tableName: input.tableName,
|
30444
|
-
schema: input.schema,
|
30445
|
-
created: result.created,
|
30446
|
-
deleted: result.deleted,
|
30447
|
-
renamed: result.renamed
|
30448
|
-
};
|
30449
|
-
};
|
30450
29770
|
enumsResolver = async (input) => {
|
30451
29771
|
try {
|
30452
29772
|
const { created, deleted, moved, renamed } = await promptNamedWithSchemasConflict(
|
@@ -30517,8 +29837,6 @@ var init_migrate = __esm({
|
|
30517
29837
|
schemasResolver,
|
30518
29838
|
enumsResolver,
|
30519
29839
|
sequencesResolver,
|
30520
|
-
policyResolver,
|
30521
|
-
roleResolver,
|
30522
29840
|
tablesResolver,
|
30523
29841
|
columnsResolver,
|
30524
29842
|
validatedPrev,
|
@@ -30554,8 +29872,6 @@ var init_migrate = __esm({
|
|
30554
29872
|
schemasResolver,
|
30555
29873
|
enumsResolver,
|
30556
29874
|
sequencesResolver,
|
30557
|
-
policyResolver,
|
30558
|
-
roleResolver,
|
30559
29875
|
tablesResolver,
|
30560
29876
|
columnsResolver,
|
30561
29877
|
validatedPrev,
|
@@ -30843,56 +30159,6 @@ var init_migrate = __esm({
|
|
30843
30159
|
result.deleted.push(...leftMissing);
|
30844
30160
|
return result;
|
30845
30161
|
};
|
30846
|
-
promptNamedConflict = async (newItems, missingItems, entity) => {
|
30847
|
-
if (missingItems.length === 0 || newItems.length === 0) {
|
30848
|
-
return {
|
30849
|
-
created: newItems,
|
30850
|
-
renamed: [],
|
30851
|
-
deleted: missingItems
|
30852
|
-
};
|
30853
|
-
}
|
30854
|
-
const result = { created: [], renamed: [], deleted: [] };
|
30855
|
-
let index4 = 0;
|
30856
|
-
let leftMissing = [...missingItems];
|
30857
|
-
do {
|
30858
|
-
const created = newItems[index4];
|
30859
|
-
const renames = leftMissing.map((it) => {
|
30860
|
-
return { from: it, to: created };
|
30861
|
-
});
|
30862
|
-
const promptData = [created, ...renames];
|
30863
|
-
const { status, data } = await (0, import_hanji3.render)(
|
30864
|
-
new ResolveSelectNamed(created, promptData, entity)
|
30865
|
-
);
|
30866
|
-
if (status === "aborted") {
|
30867
|
-
console.error("ERROR");
|
30868
|
-
process.exit(1);
|
30869
|
-
}
|
30870
|
-
if (isRenamePromptItem(data)) {
|
30871
|
-
console.log(
|
30872
|
-
`${source_default.yellow("~")} ${data.from.name} \u203A ${data.to.name} ${source_default.gray(
|
30873
|
-
`${entity} will be renamed/moved`
|
30874
|
-
)}`
|
30875
|
-
);
|
30876
|
-
if (data.from.name !== data.to.name) {
|
30877
|
-
result.renamed.push(data);
|
30878
|
-
}
|
30879
|
-
delete leftMissing[leftMissing.indexOf(data.from)];
|
30880
|
-
leftMissing = leftMissing.filter(Boolean);
|
30881
|
-
} else {
|
30882
|
-
console.log(
|
30883
|
-
`${source_default.green("+")} ${data.name} ${source_default.gray(
|
30884
|
-
`${entity} will be created`
|
30885
|
-
)}`
|
30886
|
-
);
|
30887
|
-
result.created.push(created);
|
30888
|
-
}
|
30889
|
-
index4 += 1;
|
30890
|
-
} while (index4 < newItems.length);
|
30891
|
-
console.log(source_default.gray(`--- all ${entity} conflicts resolved ---
|
30892
|
-
`));
|
30893
|
-
result.deleted.push(...leftMissing);
|
30894
|
-
return result;
|
30895
|
-
};
|
30896
30162
|
promptNamedWithSchemasConflict = async (newItems, missingItems, entity) => {
|
30897
30163
|
if (missingItems.length === 0 || newItems.length === 0) {
|
30898
30164
|
return {
|
@@ -39721,9 +38987,9 @@ var init_body2 = __esm({
|
|
39721
38987
|
// ../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/headers.js
|
39722
38988
|
function fromRawHeaders(headers = []) {
|
39723
38989
|
return new Headers2(
|
39724
|
-
headers.reduce((result, value, index4,
|
38990
|
+
headers.reduce((result, value, index4, array) => {
|
39725
38991
|
if (index4 % 2 === 0) {
|
39726
|
-
result.push(
|
38992
|
+
result.push(array.slice(index4, index4 + 2));
|
39727
38993
|
}
|
39728
38994
|
return result;
|
39729
38995
|
}, []).filter(([name, value]) => {
|
@@ -40121,7 +39387,7 @@ function determineRequestsReferrer(request, { referrerURLCallback, referrerOrigi
|
|
40121
39387
|
if (request.referrer === "no-referrer" || request.referrerPolicy === "") {
|
40122
39388
|
return null;
|
40123
39389
|
}
|
40124
|
-
const
|
39390
|
+
const policy = request.referrerPolicy;
|
40125
39391
|
if (request.referrer === "about:client") {
|
40126
39392
|
return "no-referrer";
|
40127
39393
|
}
|
@@ -40138,7 +39404,7 @@ function determineRequestsReferrer(request, { referrerURLCallback, referrerOrigi
|
|
40138
39404
|
referrerOrigin = referrerOriginCallback(referrerOrigin);
|
40139
39405
|
}
|
40140
39406
|
const currentURL = new URL(request.url);
|
40141
|
-
switch (
|
39407
|
+
switch (policy) {
|
40142
39408
|
case "no-referrer":
|
40143
39409
|
return "no-referrer";
|
40144
39410
|
case "origin":
|
@@ -40174,18 +39440,18 @@ function determineRequestsReferrer(request, { referrerURLCallback, referrerOrigi
|
|
40174
39440
|
}
|
40175
39441
|
return referrerURL;
|
40176
39442
|
default:
|
40177
|
-
throw new TypeError(`Invalid referrerPolicy: ${
|
39443
|
+
throw new TypeError(`Invalid referrerPolicy: ${policy}`);
|
40178
39444
|
}
|
40179
39445
|
}
|
40180
39446
|
function parseReferrerPolicyFromHeader(headers) {
|
40181
39447
|
const policyTokens = (headers.get("referrer-policy") || "").split(/[,\s]+/);
|
40182
|
-
let
|
39448
|
+
let policy = "";
|
40183
39449
|
for (const token of policyTokens) {
|
40184
39450
|
if (token && ReferrerPolicy.has(token)) {
|
40185
|
-
|
39451
|
+
policy = token;
|
40186
39452
|
}
|
40187
39453
|
}
|
40188
|
-
return
|
39454
|
+
return policy;
|
40189
39455
|
}
|
40190
39456
|
var import_node_net, ReferrerPolicy, DEFAULT_REFERRER_POLICY;
|
40191
39457
|
var init_referrer = __esm({
|
@@ -60832,7 +60098,7 @@ var require_fromWebToken = __commonJS({
|
|
60832
60098
|
var fromWebToken2 = (init2) => async () => {
|
60833
60099
|
var _a;
|
60834
60100
|
(_a = init2.logger) == null ? void 0 : _a.debug("@aws-sdk/credential-provider-web-identity", "fromWebToken");
|
60835
|
-
const { roleArn, roleSessionName, webIdentityToken, providerId, policyArns, policy
|
60101
|
+
const { roleArn, roleSessionName, webIdentityToken, providerId, policyArns, policy, durationSeconds } = init2;
|
60836
60102
|
let { roleAssumerWithWebIdentity } = init2;
|
60837
60103
|
if (!roleAssumerWithWebIdentity) {
|
60838
60104
|
const { getDefaultRoleAssumerWithWebIdentity } = await Promise.resolve().then(() => __importStar2(require_dist_cjs50()));
|
@@ -60848,7 +60114,7 @@ var require_fromWebToken = __commonJS({
|
|
60848
60114
|
WebIdentityToken: webIdentityToken,
|
60849
60115
|
ProviderId: providerId,
|
60850
60116
|
PolicyArns: policyArns,
|
60851
|
-
Policy:
|
60117
|
+
Policy: policy,
|
60852
60118
|
DurationSeconds: durationSeconds
|
60853
60119
|
});
|
60854
60120
|
};
|
@@ -64312,13 +63578,13 @@ var require_event_stream = __commonJS({
|
|
64312
63578
|
es.writeArray = function(done) {
|
64313
63579
|
if ("function" !== typeof done)
|
64314
63580
|
throw new Error("function writeArray (done): done must be function");
|
64315
|
-
var a = new Stream3(),
|
63581
|
+
var a = new Stream3(), array = [], isDone = false;
|
64316
63582
|
a.write = function(l) {
|
64317
|
-
|
63583
|
+
array.push(l);
|
64318
63584
|
};
|
64319
63585
|
a.end = function() {
|
64320
63586
|
isDone = true;
|
64321
|
-
done(null,
|
63587
|
+
done(null, array);
|
64322
63588
|
};
|
64323
63589
|
a.writable = true;
|
64324
63590
|
a.readable = false;
|
@@ -64326,23 +63592,23 @@ var require_event_stream = __commonJS({
|
|
64326
63592
|
a.writable = a.readable = false;
|
64327
63593
|
if (isDone)
|
64328
63594
|
return;
|
64329
|
-
done(new Error("destroyed before end"),
|
63595
|
+
done(new Error("destroyed before end"), array);
|
64330
63596
|
};
|
64331
63597
|
return a;
|
64332
63598
|
};
|
64333
|
-
es.readArray = function(
|
63599
|
+
es.readArray = function(array) {
|
64334
63600
|
var stream = new Stream3(), i2 = 0, paused = false, ended = false;
|
64335
63601
|
stream.readable = true;
|
64336
63602
|
stream.writable = false;
|
64337
|
-
if (!Array.isArray(
|
63603
|
+
if (!Array.isArray(array))
|
64338
63604
|
throw new Error("event-stream.read expects an array");
|
64339
63605
|
stream.resume = function() {
|
64340
63606
|
if (ended)
|
64341
63607
|
return;
|
64342
63608
|
paused = false;
|
64343
|
-
var l =
|
63609
|
+
var l = array.length;
|
64344
63610
|
while (i2 < l && !paused && !ended) {
|
64345
|
-
stream.emit("data",
|
63611
|
+
stream.emit("data", array[i2++]);
|
64346
63612
|
}
|
64347
63613
|
if (i2 == l && !ended)
|
64348
63614
|
ended = true, stream.readable = false, stream.emit("end");
|
@@ -67967,8 +67233,8 @@ var require_utils4 = __commonJS({
|
|
67967
67233
|
"use strict";
|
67968
67234
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
67969
67235
|
exports2.string = exports2.stream = exports2.pattern = exports2.path = exports2.fs = exports2.errno = exports2.array = void 0;
|
67970
|
-
var
|
67971
|
-
exports2.array =
|
67236
|
+
var array = require_array();
|
67237
|
+
exports2.array = array;
|
67972
67238
|
var errno = require_errno();
|
67973
67239
|
exports2.errno = errno;
|
67974
67240
|
var fs9 = require_fs2();
|
@@ -79826,7 +79092,7 @@ var init_pgIntrospect = __esm({
|
|
79826
79092
|
init_global();
|
79827
79093
|
init_pgSerializer();
|
79828
79094
|
init_views();
|
79829
|
-
pgPushIntrospect = async (db, filters, schemaFilters
|
79095
|
+
pgPushIntrospect = async (db, filters, schemaFilters) => {
|
79830
79096
|
const matchers = filters.map((it) => {
|
79831
79097
|
return new Minimatch(it);
|
79832
79098
|
});
|
@@ -79855,7 +79121,7 @@ var init_pgIntrospect = __esm({
|
|
79855
79121
|
);
|
79856
79122
|
const res = await (0, import_hanji9.renderWithTask)(
|
79857
79123
|
progress,
|
79858
|
-
fromDatabase2(db, filter2, schemaFilters
|
79124
|
+
fromDatabase2(db, filter2, schemaFilters)
|
79859
79125
|
);
|
79860
79126
|
const schema5 = { id: originUUID, prevId: "", ...res };
|
79861
79127
|
const { internal, ...schemaWithoutInternals } = schema5;
|
@@ -80390,11 +79656,11 @@ var init_push = __esm({
|
|
80390
79656
|
console.log(e2);
|
80391
79657
|
}
|
80392
79658
|
};
|
80393
|
-
pgPush = async (schemaPath, verbose, strict, credentials2, tablesFilter, schemasFilter,
|
79659
|
+
pgPush = async (schemaPath, verbose, strict, credentials2, tablesFilter, schemasFilter, force, casing2) => {
|
80394
79660
|
const { preparePostgresDB: preparePostgresDB2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
|
80395
79661
|
const { pgPushIntrospect: pgPushIntrospect2 } = await Promise.resolve().then(() => (init_pgIntrospect(), pgIntrospect_exports));
|
80396
79662
|
const db = await preparePostgresDB2(credentials2);
|
80397
|
-
const { schema: schema5 } = await pgPushIntrospect2(db, tablesFilter, schemasFilter
|
79663
|
+
const { schema: schema5 } = await pgPushIntrospect2(db, tablesFilter, schemasFilter);
|
80398
79664
|
const { preparePgPush: preparePgPush2 } = await Promise.resolve().then(() => (init_migrate(), migrate_exports));
|
80399
79665
|
const statements = await preparePgPush2(schemaPath, schema5, schemasFilter, casing2);
|
80400
79666
|
try {
|
@@ -81579,7 +80845,7 @@ function generateIdentityParams(identity) {
|
|
81579
80845
|
}
|
81580
80846
|
return `.generatedByDefaultAsIdentity(${paramsObj})`;
|
81581
80847
|
}
|
81582
|
-
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,
|
80848
|
+
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, createTableFKs3;
|
81583
80849
|
var init_introspect_pg = __esm({
|
81584
80850
|
"src/introspect-pg.ts"() {
|
81585
80851
|
"use strict";
|
@@ -81757,9 +81023,6 @@ var init_introspect_pg = __esm({
|
|
81757
81023
|
const uniqueImports = Object.values(it.uniqueConstraints).map(
|
81758
81024
|
(it2) => "unique"
|
81759
81025
|
);
|
81760
|
-
const policiesImports = Object.values(it.policies).map(
|
81761
|
-
(it2) => "pgPolicy"
|
81762
|
-
);
|
81763
81026
|
if (it.schema && it.schema !== "public" && it.schema !== "") {
|
81764
81027
|
res.pg.push("pgSchema");
|
81765
81028
|
}
|
@@ -81767,7 +81030,6 @@ var init_introspect_pg = __esm({
|
|
81767
81030
|
res.pg.push(...fkImpots);
|
81768
81031
|
res.pg.push(...pkImports);
|
81769
81032
|
res.pg.push(...uniqueImports);
|
81770
|
-
res.pg.push(...policiesImports);
|
81771
81033
|
const columnImports = Object.values(it.columns).map((col) => {
|
81772
81034
|
let patched = (importsPatch2[col.type] || col.type).replace("[]", "");
|
81773
81035
|
patched = patched === "double precision" ? "doublePrecision" : patched;
|
@@ -81801,9 +81063,6 @@ var init_introspect_pg = __esm({
|
|
81801
81063
|
imports.pg.push("pgEnum");
|
81802
81064
|
}
|
81803
81065
|
});
|
81804
|
-
if (Object.keys(schema5.roles).length > 0) {
|
81805
|
-
imports.pg.push("pgRole");
|
81806
|
-
}
|
81807
81066
|
const enumStatements = Object.values(schema5.enums).map((it) => {
|
81808
81067
|
const enumSchema3 = schemas[it.schema];
|
81809
81068
|
const paramName = paramNameFor(it.name, enumSchema3);
|
@@ -81839,16 +81098,9 @@ var init_introspect_pg = __esm({
|
|
81839
81098
|
}
|
81840
81099
|
return `export const ${withCasing2(paramName, casing2)} = ${func}("${it.name}"${params ? `, { ${params.trimChar(",")} }` : ""})
|
81841
81100
|
`;
|
81842
|
-
}).join("").concat("");
|
81101
|
+
}).join("").concat("\n");
|
81843
81102
|
const schemaStatements = Object.entries(schemas).map((it) => {
|
81844
81103
|
return `export const ${it[1]} = pgSchema("${it[0]}");
|
81845
|
-
`;
|
81846
|
-
}).join("");
|
81847
|
-
const rolesNameToTsKey = {};
|
81848
|
-
const rolesStatements = Object.entries(schema5.roles).map((it) => {
|
81849
|
-
const fields = it[1];
|
81850
|
-
rolesNameToTsKey[fields.name] = it[0];
|
81851
|
-
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(",")}}`} );
|
81852
81104
|
`;
|
81853
81105
|
}).join("");
|
81854
81106
|
const tableStatements = Object.values(schema5.tables).map((table4) => {
|
@@ -81867,8 +81119,8 @@ var init_introspect_pg = __esm({
|
|
81867
81119
|
schema5.internal
|
81868
81120
|
);
|
81869
81121
|
statement += "}";
|
81870
|
-
if (Object.keys(table4.indexes).length > 0 || Object.values(table4.foreignKeys).length > 0 || Object.
|
81871
|
-
statement += "
|
81122
|
+
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) {
|
81123
|
+
statement += ",\n";
|
81872
81124
|
statement += "(table) => {\n";
|
81873
81125
|
statement += " return {\n";
|
81874
81126
|
statement += createTableIndexes3(
|
@@ -81885,11 +81137,6 @@ var init_introspect_pg = __esm({
|
|
81885
81137
|
Object.values(table4.uniqueConstraints),
|
81886
81138
|
casing2
|
81887
81139
|
);
|
81888
|
-
statement += createTablePolicies(
|
81889
|
-
Object.values(table4.policies),
|
81890
|
-
casing2,
|
81891
|
-
rolesNameToTsKey
|
81892
|
-
);
|
81893
81140
|
statement += " }\n";
|
81894
81141
|
statement += "}";
|
81895
81142
|
}
|
@@ -81900,14 +81147,14 @@ var init_introspect_pg = __esm({
|
|
81900
81147
|
const importsTs = `import { ${uniquePgImports.join(
|
81901
81148
|
", "
|
81902
81149
|
)} } from "drizzle-orm/pg-core"
|
81903
|
-
import { sql } from "drizzle-orm"
|
81150
|
+
import { sql } from "drizzle-orm"
|
81904
81151
|
|
81905
81152
|
`;
|
81906
81153
|
let decalrations = schemaStatements;
|
81907
|
-
decalrations += rolesStatements;
|
81908
81154
|
decalrations += enumStatements;
|
81909
81155
|
decalrations += sequencesStatements;
|
81910
|
-
decalrations +=
|
81156
|
+
decalrations += "\n";
|
81157
|
+
decalrations += tableStatements.join("\n\n");
|
81911
81158
|
const file = importsTs + decalrations;
|
81912
81159
|
const schemaEntry = `
|
81913
81160
|
{
|
@@ -82338,23 +81585,6 @@ import { sql } from "drizzle-orm"
|
|
82338
81585
|
}).join(", ")}]${it.name ? `, name: "${it.name}"` : ""}}`;
|
82339
81586
|
statement += ")";
|
82340
81587
|
statement += `,
|
82341
|
-
`;
|
82342
|
-
});
|
82343
|
-
return statement;
|
82344
|
-
};
|
82345
|
-
createTablePolicies = (policies, casing2, rolesNameToTsKey = {}) => {
|
82346
|
-
let statement = "";
|
82347
|
-
policies.forEach((it) => {
|
82348
|
-
var _a, _b, _c;
|
82349
|
-
const idxKey = withCasing2(it.name, casing2);
|
82350
|
-
const mappedItTo = (_a = it.to) == null ? void 0 : _a.map((v) => {
|
82351
|
-
return rolesNameToTsKey[v] ? withCasing2(rolesNameToTsKey[v], casing2) : `"${v}"`;
|
82352
|
-
});
|
82353
|
-
statement += ` ${idxKey}: `;
|
82354
|
-
statement += "pgPolicy(";
|
82355
|
-
statement += `"${it.name}", { `;
|
82356
|
-
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}\` ` : ""}`;
|
82357
|
-
statement += ` }),
|
82358
81588
|
`;
|
82359
81589
|
});
|
82360
81590
|
return statement;
|
@@ -82432,7 +81662,7 @@ var init_introspect = __esm({
|
|
82432
81662
|
init_utils();
|
82433
81663
|
init_views();
|
82434
81664
|
init_migrate();
|
82435
|
-
introspectPostgres = async (casing2, out, breakpoints, credentials2, tablesFilter, schemasFilter, prefix2
|
81665
|
+
introspectPostgres = async (casing2, out, breakpoints, credentials2, tablesFilter, schemasFilter, prefix2) => {
|
82436
81666
|
const { preparePostgresDB: preparePostgresDB2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
|
82437
81667
|
const db = await preparePostgresDB2(credentials2);
|
82438
81668
|
const matchers = tablesFilter.map((it) => {
|
@@ -82460,15 +81690,9 @@ var init_introspect = __esm({
|
|
82460
81690
|
const progress = new IntrospectProgress(true);
|
82461
81691
|
const res = await (0, import_hanji12.renderWithTask)(
|
82462
81692
|
progress,
|
82463
|
-
fromDatabase2(
|
82464
|
-
|
82465
|
-
|
82466
|
-
schemasFilter,
|
82467
|
-
entities,
|
82468
|
-
(stage, count, status) => {
|
82469
|
-
progress.update(stage, count, status);
|
82470
|
-
}
|
82471
|
-
)
|
81693
|
+
fromDatabase2(db, filter2, schemasFilter, (stage, count, status) => {
|
81694
|
+
progress.update(stage, count, status);
|
81695
|
+
})
|
82472
81696
|
);
|
82473
81697
|
const schema5 = { id: originUUID, prevId: "", ...res };
|
82474
81698
|
const ts = schemaToTypeScript3(schema5, casing2);
|
@@ -82487,7 +81711,6 @@ var init_introspect = __esm({
|
|
82487
81711
|
schemasResolver,
|
82488
81712
|
enumsResolver,
|
82489
81713
|
sequencesResolver,
|
82490
|
-
policyResolver,
|
82491
81714
|
tablesResolver,
|
82492
81715
|
columnsResolver,
|
82493
81716
|
dryPg,
|
@@ -86010,8 +85233,7 @@ var pull = command({
|
|
86010
85233
|
breakpoints,
|
86011
85234
|
tablesFilter,
|
86012
85235
|
schemasFilter,
|
86013
|
-
prefix: prefix2
|
86014
|
-
entities
|
85236
|
+
prefix: prefix2
|
86015
85237
|
} = config;
|
86016
85238
|
(0, import_fs13.mkdirSync)(out, { recursive: true });
|
86017
85239
|
console.log(
|
@@ -86050,8 +85272,7 @@ var pull = command({
|
|
86050
85272
|
credentials2,
|
86051
85273
|
tablesFilter,
|
86052
85274
|
schemasFilter,
|
86053
|
-
prefix2
|
86054
|
-
entities
|
85275
|
+
prefix2
|
86055
85276
|
);
|
86056
85277
|
} else if (dialect4 === "mysql") {
|
86057
85278
|
const { introspectMysql: introspectMysql2 } = await Promise.resolve().then(() => (init_introspect(), introspect_exports));
|
@@ -86222,7 +85443,7 @@ init_utils2();
|
|
86222
85443
|
var version2 = async () => {
|
86223
85444
|
const { npmVersion } = await ormCoreVersions();
|
86224
85445
|
const ormVersion = npmVersion ? `drizzle-orm: v${npmVersion}` : "";
|
86225
|
-
const envVersion = "0.25.0-
|
85446
|
+
const envVersion = "0.25.0-22c3e40";
|
86226
85447
|
const kitVersion = envVersion ? `v${envVersion}` : "--";
|
86227
85448
|
const versions = `drizzle-kit: ${kitVersion}
|
86228
85449
|
${ormVersion}`;
|