drizzle-kit 0.31.1-9811cd4 → 0.31.1-a4825a4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api.d.mts +11112 -1
- package/api.d.ts +11112 -1
- package/api.js +23141 -0
- package/api.mjs +23138 -0
- package/bin.cjs +696 -581
- package/index-DpBv6e_M.d.mts +321 -0
- package/index-DpBv6e_M.d.ts +321 -0
- package/index.d.mts +2 -319
- package/index.d.ts +2 -319
- package/package.json +1 -1
package/bin.cjs
CHANGED
@@ -1369,7 +1369,7 @@ var require_hanji = __commonJS({
|
|
1369
1369
|
}
|
1370
1370
|
};
|
1371
1371
|
exports2.Terminal = Terminal;
|
1372
|
-
var
|
1372
|
+
var TaskView5 = class {
|
1373
1373
|
constructor() {
|
1374
1374
|
this.attachCallbacks = [];
|
1375
1375
|
this.detachCallbacks = [];
|
@@ -1393,7 +1393,7 @@ var require_hanji = __commonJS({
|
|
1393
1393
|
}
|
1394
1394
|
}
|
1395
1395
|
};
|
1396
|
-
exports2.TaskView =
|
1396
|
+
exports2.TaskView = TaskView5;
|
1397
1397
|
var TaskTerminal = class {
|
1398
1398
|
constructor(view5, stdout) {
|
1399
1399
|
this.view = view5;
|
@@ -5887,6 +5887,7 @@ You can check the "pg_vector" docs for more info: https://github.com/pgvector/pg
|
|
5887
5887
|
this.state.bind(this);
|
5888
5888
|
this.base = base;
|
5889
5889
|
}
|
5890
|
+
state;
|
5890
5891
|
render(status) {
|
5891
5892
|
if (status === "submitted" || status === "aborted") {
|
5892
5893
|
return "";
|
@@ -5927,93 +5928,95 @@ Is ${source_default.bold.blue(key)} ${this.entityType} created or renamed from a
|
|
5927
5928
|
Spinner = class {
|
5928
5929
|
constructor(frames) {
|
5929
5930
|
this.frames = frames;
|
5930
|
-
this.offset = 0;
|
5931
|
-
this.tick = () => {
|
5932
|
-
this.iterator();
|
5933
|
-
};
|
5934
|
-
this.value = () => {
|
5935
|
-
return this.frames[this.offset];
|
5936
|
-
};
|
5937
5931
|
this.iterator = () => {
|
5938
5932
|
this.offset += 1;
|
5939
5933
|
this.offset %= frames.length - 1;
|
5940
5934
|
};
|
5941
5935
|
}
|
5936
|
+
offset = 0;
|
5937
|
+
iterator;
|
5938
|
+
tick = () => {
|
5939
|
+
this.iterator();
|
5940
|
+
};
|
5941
|
+
value = () => {
|
5942
|
+
return this.frames[this.offset];
|
5943
|
+
};
|
5942
5944
|
};
|
5943
5945
|
IntrospectProgress = class extends import_hanji.TaskView {
|
5944
5946
|
constructor(hasEnums = false) {
|
5945
5947
|
super();
|
5946
5948
|
this.hasEnums = hasEnums;
|
5947
|
-
this.spinner = new Spinner("\u28F7\u28EF\u28DF\u287F\u28BF\u28FB\u28FD\u28FE".split(""));
|
5948
|
-
this.state = {
|
5949
|
-
tables: {
|
5950
|
-
count: 0,
|
5951
|
-
name: "tables",
|
5952
|
-
status: "fetching"
|
5953
|
-
},
|
5954
|
-
columns: {
|
5955
|
-
count: 0,
|
5956
|
-
name: "columns",
|
5957
|
-
status: "fetching"
|
5958
|
-
},
|
5959
|
-
enums: {
|
5960
|
-
count: 0,
|
5961
|
-
name: "enums",
|
5962
|
-
status: "fetching"
|
5963
|
-
},
|
5964
|
-
indexes: {
|
5965
|
-
count: 0,
|
5966
|
-
name: "indexes",
|
5967
|
-
status: "fetching"
|
5968
|
-
},
|
5969
|
-
fks: {
|
5970
|
-
count: 0,
|
5971
|
-
name: "foreign keys",
|
5972
|
-
status: "fetching"
|
5973
|
-
},
|
5974
|
-
policies: {
|
5975
|
-
count: 0,
|
5976
|
-
name: "policies",
|
5977
|
-
status: "fetching"
|
5978
|
-
},
|
5979
|
-
checks: {
|
5980
|
-
count: 0,
|
5981
|
-
name: "check constraints",
|
5982
|
-
status: "fetching"
|
5983
|
-
},
|
5984
|
-
views: {
|
5985
|
-
count: 0,
|
5986
|
-
name: "views",
|
5987
|
-
status: "fetching"
|
5988
|
-
}
|
5989
|
-
};
|
5990
|
-
this.formatCount = (count2) => {
|
5991
|
-
const width = Math.max.apply(
|
5992
|
-
null,
|
5993
|
-
Object.values(this.state).map((it) => it.count.toFixed(0).length)
|
5994
|
-
);
|
5995
|
-
return count2.toFixed(0).padEnd(width, " ");
|
5996
|
-
};
|
5997
|
-
this.statusText = (spinner, stage) => {
|
5998
|
-
const { name, count: count2 } = stage;
|
5999
|
-
const isDone = stage.status === "done";
|
6000
|
-
const prefix2 = isDone ? `[${source_default.green("\u2713")}]` : `[${spinner}]`;
|
6001
|
-
const formattedCount = this.formatCount(count2);
|
6002
|
-
const suffix = isDone ? `${formattedCount} ${name} fetched` : `${formattedCount} ${name} fetching`;
|
6003
|
-
return `${prefix2} ${suffix}
|
6004
|
-
`;
|
6005
|
-
};
|
6006
5949
|
this.timeout = setInterval(() => {
|
6007
5950
|
this.spinner.tick();
|
6008
5951
|
this.requestLayout();
|
6009
5952
|
}, 128);
|
6010
5953
|
this.on("detach", () => clearInterval(this.timeout));
|
6011
5954
|
}
|
5955
|
+
spinner = new Spinner("\u28F7\u28EF\u28DF\u287F\u28BF\u28FB\u28FD\u28FE".split(""));
|
5956
|
+
timeout;
|
5957
|
+
state = {
|
5958
|
+
tables: {
|
5959
|
+
count: 0,
|
5960
|
+
name: "tables",
|
5961
|
+
status: "fetching"
|
5962
|
+
},
|
5963
|
+
columns: {
|
5964
|
+
count: 0,
|
5965
|
+
name: "columns",
|
5966
|
+
status: "fetching"
|
5967
|
+
},
|
5968
|
+
enums: {
|
5969
|
+
count: 0,
|
5970
|
+
name: "enums",
|
5971
|
+
status: "fetching"
|
5972
|
+
},
|
5973
|
+
indexes: {
|
5974
|
+
count: 0,
|
5975
|
+
name: "indexes",
|
5976
|
+
status: "fetching"
|
5977
|
+
},
|
5978
|
+
fks: {
|
5979
|
+
count: 0,
|
5980
|
+
name: "foreign keys",
|
5981
|
+
status: "fetching"
|
5982
|
+
},
|
5983
|
+
policies: {
|
5984
|
+
count: 0,
|
5985
|
+
name: "policies",
|
5986
|
+
status: "fetching"
|
5987
|
+
},
|
5988
|
+
checks: {
|
5989
|
+
count: 0,
|
5990
|
+
name: "check constraints",
|
5991
|
+
status: "fetching"
|
5992
|
+
},
|
5993
|
+
views: {
|
5994
|
+
count: 0,
|
5995
|
+
name: "views",
|
5996
|
+
status: "fetching"
|
5997
|
+
}
|
5998
|
+
};
|
6012
5999
|
update(stage, count2, status) {
|
6013
6000
|
this.state[stage].count = count2;
|
6014
6001
|
this.state[stage].status = status;
|
6015
6002
|
this.requestLayout();
|
6016
6003
|
}
|
6004
|
+
formatCount = (count2) => {
|
6005
|
+
const width = Math.max.apply(
|
6006
|
+
null,
|
6007
|
+
Object.values(this.state).map((it) => it.count.toFixed(0).length)
|
6008
|
+
);
|
6009
|
+
return count2.toFixed(0).padEnd(width, " ");
|
6010
|
+
};
|
6011
|
+
statusText = (spinner, stage) => {
|
6012
|
+
const { name, count: count2 } = stage;
|
6013
|
+
const isDone = stage.status === "done";
|
6014
|
+
const prefix2 = isDone ? `[${source_default.green("\u2713")}]` : `[${spinner}]`;
|
6015
|
+
const formattedCount = this.formatCount(count2);
|
6016
|
+
const suffix = isDone ? `${formattedCount} ${name} fetched` : `${formattedCount} ${name} fetching`;
|
6017
|
+
return `${prefix2} ${suffix}
|
6018
|
+
`;
|
6019
|
+
};
|
6017
6020
|
render() {
|
6018
6021
|
let info2 = "";
|
6019
6022
|
const spin = this.spinner.value();
|
@@ -6029,9 +6032,10 @@ Is ${source_default.bold.blue(key)} ${this.entityType} created or renamed from a
|
|
6029
6032
|
}
|
6030
6033
|
};
|
6031
6034
|
MigrateProgress = class extends import_hanji.TaskView {
|
6035
|
+
spinner = new Spinner("\u28F7\u28EF\u28DF\u287F\u28BF\u28FB\u28FD\u28FE".split(""));
|
6036
|
+
timeout;
|
6032
6037
|
constructor() {
|
6033
6038
|
super();
|
6034
|
-
this.spinner = new Spinner("\u28F7\u28EF\u28DF\u287F\u28BF\u28FB\u28FD\u28FE".split(""));
|
6035
6039
|
this.timeout = setInterval(() => {
|
6036
6040
|
this.spinner.tick();
|
6037
6041
|
this.requestLayout();
|
@@ -6051,13 +6055,14 @@ Is ${source_default.bold.blue(key)} ${this.entityType} created or renamed from a
|
|
6051
6055
|
super();
|
6052
6056
|
this.progressText = progressText;
|
6053
6057
|
this.successText = successText;
|
6054
|
-
this.spinner = new Spinner("\u28F7\u28EF\u28DF\u287F\u28BF\u28FB\u28FD\u28FE".split(""));
|
6055
6058
|
this.timeout = setInterval(() => {
|
6056
6059
|
this.spinner.tick();
|
6057
6060
|
this.requestLayout();
|
6058
6061
|
}, 128);
|
6059
6062
|
this.on("detach", () => clearInterval(this.timeout));
|
6060
6063
|
}
|
6064
|
+
spinner = new Spinner("\u28F7\u28EF\u28DF\u287F\u28BF\u28FB\u28FD\u28FE".split(""));
|
6065
|
+
timeout;
|
6061
6066
|
render(status) {
|
6062
6067
|
if (status === "pending") {
|
6063
6068
|
const spin = this.spinner.value();
|
@@ -6069,6 +6074,7 @@ Is ${source_default.bold.blue(key)} ${this.entityType} created or renamed from a
|
|
6069
6074
|
}
|
6070
6075
|
};
|
6071
6076
|
DropMigrationView = class extends import_hanji.Prompt {
|
6077
|
+
data;
|
6072
6078
|
constructor(data) {
|
6073
6079
|
super();
|
6074
6080
|
this.on("attach", (terminal) => terminal.toggleCursor("hide"));
|
@@ -6234,7 +6240,7 @@ function matchesFilters(item, filter2) {
|
|
6234
6240
|
for (const [k, v] of Object.entries(filter2)) {
|
6235
6241
|
if (v === void 0) continue;
|
6236
6242
|
const target = item[k];
|
6237
|
-
if (typeof v === "object" && v.CONTAINS !== void 0) {
|
6243
|
+
if (v && typeof v === "object" && v.CONTAINS !== void 0) {
|
6238
6244
|
if (!Array.isArray(target)) return false;
|
6239
6245
|
if (!target.find((e2) => isEqual(e2, v.CONTAINS))) return false;
|
6240
6246
|
} else {
|
@@ -6254,6 +6260,11 @@ function findCompositeKey(dataSource, target) {
|
|
6254
6260
|
const match2 = dataSource.find((e2) => getCompositeKey(e2) === targetKey);
|
6255
6261
|
return match2;
|
6256
6262
|
}
|
6263
|
+
function findCompositeKeys(dataSource, target) {
|
6264
|
+
const targetKey = getCompositeKey(target);
|
6265
|
+
const match2 = dataSource.filter((e2) => getCompositeKey(e2) === targetKey);
|
6266
|
+
return match2;
|
6267
|
+
}
|
6257
6268
|
function validate(data, schema4, deep = false) {
|
6258
6269
|
if (typeof data !== "object" || data === null) return false;
|
6259
6270
|
for (const k of Array.from(/* @__PURE__ */ new Set([...Object.keys(data), ...Object.keys(schema4)]))) {
|
@@ -6284,6 +6295,13 @@ function validate(data, schema4, deep = false) {
|
|
6284
6295
|
}
|
6285
6296
|
function initSchemaProcessors({ entities }, store, common, extraConfigs) {
|
6286
6297
|
const entries = Object.entries(entities);
|
6298
|
+
const extraKeys = 4;
|
6299
|
+
const lengths = Object.fromEntries(
|
6300
|
+
Object.entries(common ? extraConfigs : entities).map(([k, v]) => {
|
6301
|
+
const commonCount = Object.keys(v).filter((e2) => e2 in commonConfig).length;
|
6302
|
+
return [k, commonCount + extraKeys];
|
6303
|
+
})
|
6304
|
+
);
|
6287
6305
|
return Object.fromEntries(entries.map(([k, v]) => {
|
6288
6306
|
return [k, {
|
6289
6307
|
push: generateInsert(common ? extraConfigs : entities, store, common ? void 0 : k),
|
@@ -6291,7 +6309,8 @@ function initSchemaProcessors({ entities }, store, common, extraConfigs) {
|
|
6291
6309
|
one: generateOne(store, common ? void 0 : k),
|
6292
6310
|
update: generateUpdate(store, common ? void 0 : k),
|
6293
6311
|
delete: generateDelete(store, common ? void 0 : k),
|
6294
|
-
validate: generateValidate(common ? extraConfigs : entities, common ? void 0 : k)
|
6312
|
+
validate: generateValidate(common ? extraConfigs : entities, common ? void 0 : k),
|
6313
|
+
hasDiff: generateHasDiff(lengths)
|
6295
6314
|
}];
|
6296
6315
|
}));
|
6297
6316
|
}
|
@@ -6374,7 +6393,9 @@ function _diff(dbOld, dbNew, collection, mode) {
|
|
6374
6393
|
$diffType: "alter",
|
6375
6394
|
entityType: newRow.entityType,
|
6376
6395
|
...getRowCommons(newRow),
|
6377
|
-
...changes
|
6396
|
+
...changes,
|
6397
|
+
$left: oldRow,
|
6398
|
+
$right: newRow
|
6378
6399
|
});
|
6379
6400
|
}
|
6380
6401
|
}
|
@@ -6407,7 +6428,7 @@ function create(definition) {
|
|
6407
6428
|
}
|
6408
6429
|
return db2;
|
6409
6430
|
}
|
6410
|
-
var commonConfig, generateInsert, generateList, generateOne, generateUpdate, generateDelete, generateValidate, ignoreChanges, SimpleDb;
|
6431
|
+
var commonConfig, generateInsert, generateList, generateOne, generateUpdate, generateDelete, generateHasDiff, generateValidate, ignoreChanges, SimpleDb;
|
6411
6432
|
var init_dialect = __esm({
|
6412
6433
|
"src/dialects/dialect.ts"() {
|
6413
6434
|
"use strict";
|
@@ -6471,14 +6492,37 @@ var init_dialect = __esm({
|
|
6471
6492
|
} : where;
|
6472
6493
|
const targets = filter2 ? filterCollection(store.collection, filter2) : store.collection;
|
6473
6494
|
const entries = Object.entries(set);
|
6495
|
+
const newItems = [];
|
6496
|
+
let i2 = 0;
|
6497
|
+
const dupes = [];
|
6474
6498
|
for (const item of targets) {
|
6499
|
+
const newItem = { ...item };
|
6475
6500
|
for (const [k, v] of entries) {
|
6476
6501
|
if (!(k in item)) continue;
|
6477
6502
|
const target = item[k];
|
6478
|
-
|
6503
|
+
newItem[k] = typeof v === "function" ? Array.isArray(target) ? target.map(v) : v(target) : v;
|
6504
|
+
}
|
6505
|
+
const dupe = findCompositeKeys(store.collection, newItem).filter(
|
6506
|
+
(e2) => e2 !== item
|
6507
|
+
);
|
6508
|
+
dupes.push(...dupe.filter((e2) => !dupes.find((d) => d === e2)));
|
6509
|
+
if (!dupe.length) {
|
6510
|
+
newItems.push({
|
6511
|
+
item: newItem,
|
6512
|
+
index: i2++
|
6513
|
+
});
|
6479
6514
|
}
|
6480
6515
|
}
|
6481
|
-
|
6516
|
+
if (dupes.length) {
|
6517
|
+
return {
|
6518
|
+
status: "CONFLICT",
|
6519
|
+
data: dupes
|
6520
|
+
};
|
6521
|
+
}
|
6522
|
+
for (const { index: index5, item } of newItems) {
|
6523
|
+
Object.assign(targets[index5], item);
|
6524
|
+
}
|
6525
|
+
return { status: "OK", data: targets };
|
6482
6526
|
};
|
6483
6527
|
};
|
6484
6528
|
generateDelete = (store, type) => {
|
@@ -6501,6 +6545,13 @@ var init_dialect = __esm({
|
|
6501
6545
|
return deleted;
|
6502
6546
|
};
|
6503
6547
|
};
|
6548
|
+
generateHasDiff = (lengths) => {
|
6549
|
+
return (input) => {
|
6550
|
+
const type = input.entityType;
|
6551
|
+
const length = lengths[type];
|
6552
|
+
return Object.keys(input).length > length;
|
6553
|
+
};
|
6554
|
+
};
|
6504
6555
|
generateValidate = (configs, type) => {
|
6505
6556
|
return (data) => {
|
6506
6557
|
if (typeof data !== "object" || data === null) return false;
|
@@ -6536,13 +6587,14 @@ var init_dialect = __esm({
|
|
6536
6587
|
diff2.alters = alters;
|
6537
6588
|
})(diff || (diff = {}));
|
6538
6589
|
SimpleDb = class {
|
6590
|
+
_ = {
|
6591
|
+
diffs: {},
|
6592
|
+
store: {
|
6593
|
+
collection: []
|
6594
|
+
}
|
6595
|
+
};
|
6596
|
+
entities;
|
6539
6597
|
constructor(definition) {
|
6540
|
-
this._ = {
|
6541
|
-
diffs: {},
|
6542
|
-
store: {
|
6543
|
-
collection: []
|
6544
|
-
}
|
6545
|
-
};
|
6546
6598
|
const entries = Object.entries(definition);
|
6547
6599
|
const configs = Object.fromEntries(entries.map(([type, def]) => {
|
6548
6600
|
if (type === "entities" || type === "_") throw new Error(`Illegal entity type name: "${type}"`);
|
@@ -6615,7 +6667,7 @@ var init_utils2 = __esm({
|
|
6615
6667
|
});
|
6616
6668
|
|
6617
6669
|
// src/dialects/mssql/grammar.ts
|
6618
|
-
var defaultNameForPK, defaultNameForUnique, defaultNameForFK, defaultToSQL;
|
6670
|
+
var defaultNameForPK, defaultNameForUnique, defaultNameForFK, defaultNameForDefault, defaultToSQL;
|
6619
6671
|
var init_grammar = __esm({
|
6620
6672
|
"src/dialects/mssql/grammar.ts"() {
|
6621
6673
|
"use strict";
|
@@ -6630,6 +6682,9 @@ var init_grammar = __esm({
|
|
6630
6682
|
defaultNameForFK = (table5, columns, tableTo, columnsTo) => {
|
6631
6683
|
return `${table5}_${columns.join("_")}_${tableTo}_${columnsTo.join("_")}_fk`;
|
6632
6684
|
};
|
6685
|
+
defaultNameForDefault = (table5, column8) => {
|
6686
|
+
return `${table5}_${column8}_default`;
|
6687
|
+
};
|
6633
6688
|
defaultToSQL = (it) => {
|
6634
6689
|
if (!it) return "";
|
6635
6690
|
const { value, type } = it;
|
@@ -6663,10 +6718,6 @@ var init_ddl = __esm({
|
|
6663
6718
|
table: "required",
|
6664
6719
|
type: "string",
|
6665
6720
|
notNull: "boolean",
|
6666
|
-
default: {
|
6667
|
-
value: "string",
|
6668
|
-
type: ["string", "number", "boolean", "bigint", "text", "unknown"]
|
6669
|
-
},
|
6670
6721
|
generated: {
|
6671
6722
|
type: ["persisted", "virtual"],
|
6672
6723
|
as: "string"
|
@@ -6718,6 +6769,16 @@ var init_ddl = __esm({
|
|
6718
6769
|
// TODO why?
|
6719
6770
|
value: "string"
|
6720
6771
|
},
|
6772
|
+
defaults: {
|
6773
|
+
schema: "required",
|
6774
|
+
table: "required",
|
6775
|
+
column: "string",
|
6776
|
+
nameExplicit: "boolean",
|
6777
|
+
default: {
|
6778
|
+
value: "string",
|
6779
|
+
type: ["string", "number", "boolean", "bigint", "text", "unknown"]
|
6780
|
+
}
|
6781
|
+
},
|
6721
6782
|
views: {
|
6722
6783
|
schema: "required",
|
6723
6784
|
definition: "string",
|
@@ -6736,6 +6797,7 @@ var init_ddl = __esm({
|
|
6736
6797
|
const uniques = ddl5.uniques.list(filter2);
|
6737
6798
|
const checks = ddl5.checks.list(filter2);
|
6738
6799
|
const indexes = ddl5.indexes.list(filter2);
|
6800
|
+
const defaults4 = ddl5.defaults.list(filter2);
|
6739
6801
|
return {
|
6740
6802
|
...table5,
|
6741
6803
|
columns,
|
@@ -6743,7 +6805,8 @@ var init_ddl = __esm({
|
|
6743
6805
|
fks,
|
6744
6806
|
uniques,
|
6745
6807
|
checks,
|
6746
|
-
indexes
|
6808
|
+
indexes,
|
6809
|
+
defaults: defaults4
|
6747
6810
|
};
|
6748
6811
|
};
|
6749
6812
|
interimToDDL = (interim) => {
|
@@ -6826,6 +6889,17 @@ var init_ddl = __esm({
|
|
6826
6889
|
columns: [column8.name]
|
6827
6890
|
});
|
6828
6891
|
}
|
6892
|
+
for (const columnDefault of interim.defaults) {
|
6893
|
+
const res = ddl5.defaults.push(columnDefault);
|
6894
|
+
if (res.status === "CONFLICT") {
|
6895
|
+
errors.push({
|
6896
|
+
type: "constraint_name_conflict",
|
6897
|
+
schema: columnDefault.schema,
|
6898
|
+
table: columnDefault.table,
|
6899
|
+
name: columnDefault.name
|
6900
|
+
});
|
6901
|
+
}
|
6902
|
+
}
|
6829
6903
|
for (const check2 of interim.checks) {
|
6830
6904
|
const res = ddl5.checks.push(check2);
|
6831
6905
|
if (res.status === "CONFLICT") {
|
@@ -7339,6 +7413,31 @@ var init_snapshot2 = __esm({
|
|
7339
7413
|
}
|
7340
7414
|
});
|
7341
7415
|
|
7416
|
+
// src/dialects/common.ts
|
7417
|
+
var dictionary, hash;
|
7418
|
+
var init_common2 = __esm({
|
7419
|
+
"src/dialects/common.ts"() {
|
7420
|
+
"use strict";
|
7421
|
+
dictionary = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");
|
7422
|
+
hash = (input, len = 12) => {
|
7423
|
+
const combinationsCount = Math.pow(dictionary.length, len);
|
7424
|
+
const p = 53;
|
7425
|
+
let hash2 = 0;
|
7426
|
+
for (let i2 = 0; i2 < input.length; i2++) {
|
7427
|
+
hash2 += (input.codePointAt(i2) || 0) * Math.pow(p, i2) % combinationsCount;
|
7428
|
+
}
|
7429
|
+
const result = [];
|
7430
|
+
let index5 = hash2 % combinationsCount;
|
7431
|
+
for (let i2 = len - 1; i2 >= 0; i2--) {
|
7432
|
+
const element = dictionary[index5 % dictionary.length];
|
7433
|
+
result.unshift(element);
|
7434
|
+
index5 = Math.floor(index5 / dictionary.length);
|
7435
|
+
}
|
7436
|
+
return result.join("");
|
7437
|
+
};
|
7438
|
+
}
|
7439
|
+
});
|
7440
|
+
|
7342
7441
|
// src/dialects/postgres/grammar.ts
|
7343
7442
|
function stringFromIdentityProperty(field) {
|
7344
7443
|
return typeof field === "string" ? field : typeof field === "undefined" ? void 0 : String(field);
|
@@ -7375,12 +7474,13 @@ function buildArrayString(array3, sqlType) {
|
|
7375
7474
|
}).join(",");
|
7376
7475
|
return `{${values}}`;
|
7377
7476
|
}
|
7378
|
-
var trimChar, NativeTypes, parseType, indexName,
|
7477
|
+
var trimChar, NativeTypes, parseType, indexName, isSerialExpression, parseOnType, systemNamespaceNames, isSystemNamespace, splitExpressions, wrapRecord, parseViewDefinition, defaultNameForIdentitySequence, defaultNameForPK2, defaultNameForFK2, defaultNameForUnique2, defaultNameForIndex, trimDefaultValueSuffix, defaultForColumn, defaultToSQL2, isDefaultAction, defaults;
|
7379
7478
|
var init_grammar2 = __esm({
|
7380
7479
|
"src/dialects/postgres/grammar.ts"() {
|
7381
7480
|
"use strict";
|
7382
7481
|
init_global();
|
7383
7482
|
init_utils2();
|
7483
|
+
init_common2();
|
7384
7484
|
trimChar = (str, char) => {
|
7385
7485
|
let start = 0;
|
7386
7486
|
let end = str.length;
|
@@ -7442,9 +7542,9 @@ var init_grammar2 = __esm({
|
|
7442
7542
|
indexName = (tableName, columns) => {
|
7443
7543
|
return `${tableName}_${columns.join("_")}_index`;
|
7444
7544
|
};
|
7445
|
-
|
7545
|
+
isSerialExpression = (expr, schema4) => {
|
7446
7546
|
const schemaPrefix = schema4 === "public" ? "" : `${schema4}.`;
|
7447
|
-
return `nextval('${schemaPrefix}
|
7547
|
+
return expr.startsWith(`nextval('${schemaPrefix}`) && expr.endsWith(`_seq'::regclass)`);
|
7448
7548
|
};
|
7449
7549
|
parseOnType = (type) => {
|
7450
7550
|
switch (type) {
|
@@ -7562,7 +7662,9 @@ var init_grammar2 = __esm({
|
|
7562
7662
|
return `${table5}_pkey`;
|
7563
7663
|
};
|
7564
7664
|
defaultNameForFK2 = (table5, columns, tableTo, columnsTo) => {
|
7565
|
-
|
7665
|
+
const desired = `${table5}_${columns.join("_")}_${tableTo}_${columnsTo.join("_")}_fkey`;
|
7666
|
+
const res = desired.length > 63 ? table5.length < 63 - 18 ? `${table5}_${hash(desired)}_fkey` : `${hash(desired)}_fkey` : desired;
|
7667
|
+
return res;
|
7566
7668
|
};
|
7567
7669
|
defaultNameForUnique2 = (table5, ...columns) => {
|
7568
7670
|
return `${table5}_${columns.join("_")}_key`;
|
@@ -7684,6 +7786,9 @@ var init_grammar2 = __esm({
|
|
7684
7786
|
},
|
7685
7787
|
cache: 1,
|
7686
7788
|
cycle: false
|
7789
|
+
},
|
7790
|
+
index: {
|
7791
|
+
method: "btree"
|
7687
7792
|
}
|
7688
7793
|
};
|
7689
7794
|
}
|
@@ -7750,9 +7855,7 @@ var init_ddl3 = __esm({
|
|
7750
7855
|
where: "string?",
|
7751
7856
|
with: "string",
|
7752
7857
|
method: "string",
|
7753
|
-
concurrently: "boolean"
|
7754
|
-
isPrimary: "boolean"
|
7755
|
-
// is index for primaryKey, introspect only
|
7858
|
+
concurrently: "boolean"
|
7756
7859
|
},
|
7757
7860
|
fks: {
|
7758
7861
|
schema: "required",
|
@@ -7906,7 +8009,8 @@ var init_ddl3 = __esm({
|
|
7906
8009
|
}
|
7907
8010
|
}
|
7908
8011
|
for (const it of schema4.indexes) {
|
7909
|
-
const
|
8012
|
+
const { forPK, forUnique, ...rest } = it;
|
8013
|
+
const res = ddl5.indexes.push(rest);
|
7910
8014
|
if (res.status === "CONFLICT") {
|
7911
8015
|
errors.push({
|
7912
8016
|
type: "index_duplicate",
|
@@ -8025,7 +8129,7 @@ var init_ddl3 = __esm({
|
|
8025
8129
|
for (const it of ddl5.entities.list()) {
|
8026
8130
|
let err2 = false;
|
8027
8131
|
if (!ddl5.entities.validate(it)) {
|
8028
|
-
console.log(it);
|
8132
|
+
console.log("invalid entity:", it);
|
8029
8133
|
err2 = true;
|
8030
8134
|
}
|
8031
8135
|
if (err2) throw new Error();
|
@@ -8672,12 +8776,12 @@ var require_common = __commonJS({
|
|
8672
8776
|
createDebug.skips = [];
|
8673
8777
|
createDebug.formatters = {};
|
8674
8778
|
function selectColor(namespace) {
|
8675
|
-
let
|
8779
|
+
let hash2 = 0;
|
8676
8780
|
for (let i2 = 0; i2 < namespace.length; i2++) {
|
8677
|
-
|
8678
|
-
|
8781
|
+
hash2 = (hash2 << 5) - hash2 + namespace.charCodeAt(i2);
|
8782
|
+
hash2 |= 0;
|
8679
8783
|
}
|
8680
|
-
return createDebug.colors[Math.abs(
|
8784
|
+
return createDebug.colors[Math.abs(hash2) % createDebug.colors.length];
|
8681
8785
|
}
|
8682
8786
|
createDebug.selectColor = selectColor;
|
8683
8787
|
function createDebug(namespace) {
|
@@ -13602,7 +13706,7 @@ var require_node2 = __commonJS({
|
|
13602
13706
|
});
|
13603
13707
|
}
|
13604
13708
|
});
|
13605
|
-
var
|
13709
|
+
var defaults4 = opts.default || {};
|
13606
13710
|
var argv = { _: [] };
|
13607
13711
|
function argDefined(key2, arg2) {
|
13608
13712
|
return flags.allBools && /^--[^=]+$/.test(arg2) || flags.strings[key2] || flags.bools[key2] || aliases[key2];
|
@@ -13656,7 +13760,7 @@ var require_node2 = __commonJS({
|
|
13656
13760
|
});
|
13657
13761
|
}
|
13658
13762
|
Object.keys(flags.bools).forEach(function(key2) {
|
13659
|
-
setArg(key2,
|
13763
|
+
setArg(key2, defaults4[key2] === void 0 ? false : defaults4[key2]);
|
13660
13764
|
});
|
13661
13765
|
var notFlags = [];
|
13662
13766
|
if (args.indexOf("--") !== -1) {
|
@@ -13739,11 +13843,11 @@ var require_node2 = __commonJS({
|
|
13739
13843
|
}
|
13740
13844
|
}
|
13741
13845
|
}
|
13742
|
-
Object.keys(
|
13846
|
+
Object.keys(defaults4).forEach(function(k) {
|
13743
13847
|
if (!hasKey(argv, k.split("."))) {
|
13744
|
-
setKey(argv, k.split("."),
|
13848
|
+
setKey(argv, k.split("."), defaults4[k]);
|
13745
13849
|
(aliases[k] || []).forEach(function(x2) {
|
13746
|
-
setKey(argv, x2.split("."),
|
13850
|
+
setKey(argv, x2.split("."), defaults4[k]);
|
13747
13851
|
});
|
13748
13852
|
}
|
13749
13853
|
});
|
@@ -20565,7 +20669,7 @@ var init_utils5 = __esm({
|
|
20565
20669
|
});
|
20566
20670
|
|
20567
20671
|
// src/dialects/postgres/drizzle.ts
|
20568
|
-
var import_drizzle_orm, import_pg_core, policyFrom, unwrapArray, transformOnUpdateDelete, defaultFromColumn, fromDrizzleSchema,
|
20672
|
+
var import_drizzle_orm, import_pg_core, policyFrom, unwrapArray, transformOnUpdateDelete, defaultFromColumn, fromDrizzleSchema, fromExports, prepareFromSchemaFiles;
|
20569
20673
|
var init_drizzle = __esm({
|
20570
20674
|
"src/dialects/postgres/drizzle.ts"() {
|
20571
20675
|
"use strict";
|
@@ -20683,7 +20787,23 @@ var init_drizzle = __esm({
|
|
20683
20787
|
const dialect5 = new import_pg_core.PgDialect({ casing: casing2 });
|
20684
20788
|
const errors = [];
|
20685
20789
|
const warnings = [];
|
20686
|
-
const
|
20790
|
+
const res = {
|
20791
|
+
indexes: [],
|
20792
|
+
pks: [],
|
20793
|
+
fks: [],
|
20794
|
+
uniques: [],
|
20795
|
+
checks: [],
|
20796
|
+
columns: [],
|
20797
|
+
policies: [],
|
20798
|
+
enums: [],
|
20799
|
+
roles: [],
|
20800
|
+
schemas: [],
|
20801
|
+
sequences: [],
|
20802
|
+
tables: [],
|
20803
|
+
viewColumns: [],
|
20804
|
+
views: []
|
20805
|
+
};
|
20806
|
+
res.schemas = schema4.schemas.map((it) => ({
|
20687
20807
|
entityType: "schemas",
|
20688
20808
|
name: it.schemaName
|
20689
20809
|
})).filter((it) => {
|
@@ -20696,22 +20816,36 @@ var init_drizzle = __esm({
|
|
20696
20816
|
const tableConfigPairs = schema4.tables.map((it) => {
|
20697
20817
|
return { config: (0, import_pg_core.getTableConfig)(it), table: it };
|
20698
20818
|
});
|
20699
|
-
const
|
20819
|
+
for (const policy2 of schema4.policies) {
|
20820
|
+
if (!("_linkedTable" in policy2) || typeof policy2._linkedTable === "undefined") {
|
20821
|
+
warnings.push({ type: "policy_not_linked", policy: policy2.name });
|
20822
|
+
continue;
|
20823
|
+
}
|
20824
|
+
const { schema: configSchema, name: tableName } = (0, import_pg_core.getTableConfig)(policy2._linkedTable);
|
20825
|
+
const p = policyFrom(policy2, dialect5);
|
20826
|
+
res.policies.push({
|
20827
|
+
entityType: "policies",
|
20828
|
+
schema: configSchema ?? "public",
|
20829
|
+
table: tableName,
|
20830
|
+
name: p.name,
|
20831
|
+
as: p.as,
|
20832
|
+
for: p.for,
|
20833
|
+
roles: p.roles,
|
20834
|
+
using: p.using,
|
20835
|
+
withCheck: p.withCheck
|
20836
|
+
});
|
20837
|
+
}
|
20838
|
+
res.tables = tableConfigPairs.map((it) => {
|
20700
20839
|
const config = it.config;
|
20840
|
+
const schema5 = config.schema ?? "public";
|
20841
|
+
const isRlsEnabled = config.enableRLS || config.policies.length > 0 || res.policies.some((x2) => x2.schema === schema5 && x2.table === config.name);
|
20701
20842
|
return {
|
20702
20843
|
entityType: "tables",
|
20703
|
-
schema:
|
20844
|
+
schema: schema5,
|
20704
20845
|
name: config.name,
|
20705
|
-
isRlsEnabled
|
20846
|
+
isRlsEnabled
|
20706
20847
|
};
|
20707
20848
|
});
|
20708
|
-
const indexes = [];
|
20709
|
-
const pks = [];
|
20710
|
-
const fks = [];
|
20711
|
-
const uniques = [];
|
20712
|
-
const checks = [];
|
20713
|
-
const columns = [];
|
20714
|
-
const policies = [];
|
20715
20849
|
for (const { table: table5, config } of tableConfigPairs) {
|
20716
20850
|
const {
|
20717
20851
|
name: tableName,
|
@@ -20729,7 +20863,7 @@ var init_drizzle = __esm({
|
|
20729
20863
|
if (schemaFilter && !schemaFilter.includes(schema5)) {
|
20730
20864
|
continue;
|
20731
20865
|
}
|
20732
|
-
columns.push(
|
20866
|
+
res.columns.push(
|
20733
20867
|
...drizzleColumns.map((column8) => {
|
20734
20868
|
var _a2, _b2, _c2, _d2, _e2, _f2;
|
20735
20869
|
const name = getColumnCasing(column8, casing2);
|
@@ -20773,7 +20907,7 @@ var init_drizzle = __esm({
|
|
20773
20907
|
dimensions,
|
20774
20908
|
pk: column8.primary,
|
20775
20909
|
pkName: null,
|
20776
|
-
notNull
|
20910
|
+
notNull,
|
20777
20911
|
default: columnDefault,
|
20778
20912
|
generated: generatedValue,
|
20779
20913
|
unique: column8.isUnique,
|
@@ -20783,7 +20917,7 @@ var init_drizzle = __esm({
|
|
20783
20917
|
};
|
20784
20918
|
})
|
20785
20919
|
);
|
20786
|
-
pks.push(
|
20920
|
+
res.pks.push(
|
20787
20921
|
...drizzlePKs.map((pk) => {
|
20788
20922
|
const columnNames = pk.columns.map((c) => getColumnCasing(c, casing2));
|
20789
20923
|
const name = pk.name || defaultNameForPK2(tableName);
|
@@ -20798,7 +20932,7 @@ var init_drizzle = __esm({
|
|
20798
20932
|
};
|
20799
20933
|
})
|
20800
20934
|
);
|
20801
|
-
uniques.push(
|
20935
|
+
res.uniques.push(
|
20802
20936
|
...drizzleUniques.map((unq) => {
|
20803
20937
|
const columnNames = unq.columns.map((c) => getColumnCasing(c, casing2));
|
20804
20938
|
const name = unq.name || (0, import_pg_core.uniqueKeyName)(table5, columnNames);
|
@@ -20807,39 +20941,28 @@ var init_drizzle = __esm({
|
|
20807
20941
|
schema: schema5,
|
20808
20942
|
table: tableName,
|
20809
20943
|
name,
|
20810
|
-
nameExplicit: !!unq.
|
20944
|
+
nameExplicit: !!unq.isNameExplicit(),
|
20811
20945
|
nullsNotDistinct: unq.nullsNotDistinct,
|
20812
20946
|
columns: columnNames
|
20813
20947
|
};
|
20814
20948
|
})
|
20815
20949
|
);
|
20816
|
-
fks.push(
|
20950
|
+
res.fks.push(
|
20817
20951
|
...drizzleFKs.map((fk5) => {
|
20818
20952
|
const onDelete = fk5.onDelete;
|
20819
20953
|
const onUpdate = fk5.onUpdate;
|
20820
20954
|
const reference = fk5.reference();
|
20821
20955
|
const tableTo = (0, import_drizzle_orm.getTableName)(reference.foreignTable);
|
20822
20956
|
const schemaTo = (0, import_pg_core.getTableConfig)(reference.foreignTable).schema || "public";
|
20823
|
-
const originalColumnsFrom = reference.columns.map((it) => it.name);
|
20824
20957
|
const columnsFrom = reference.columns.map((it) => getColumnCasing(it, casing2));
|
20825
|
-
const originalColumnsTo = reference.foreignColumns.map((it) => it.name);
|
20826
20958
|
const columnsTo = reference.foreignColumns.map((it) => getColumnCasing(it, casing2));
|
20827
|
-
|
20828
|
-
const nameExplicit = !!fk5.reference.name;
|
20829
|
-
if (casing2 !== void 0 && !nameExplicit) {
|
20830
|
-
for (let i2 = 0; i2 < originalColumnsFrom.length; i2++) {
|
20831
|
-
name = name.replace(originalColumnsFrom[i2], columnsFrom[i2]);
|
20832
|
-
}
|
20833
|
-
for (let i2 = 0; i2 < originalColumnsTo.length; i2++) {
|
20834
|
-
name = name.replace(originalColumnsTo[i2], columnsTo[i2]);
|
20835
|
-
}
|
20836
|
-
}
|
20959
|
+
const name = fk5.isNameExplicit() ? fk5.getName() : defaultNameForFK2(tableName, columnsFrom, tableTo, columnsTo);
|
20837
20960
|
return {
|
20838
20961
|
entityType: "fks",
|
20839
20962
|
schema: schema5,
|
20840
20963
|
table: tableName,
|
20841
20964
|
name,
|
20842
|
-
nameExplicit,
|
20965
|
+
nameExplicit: fk5.isNameExplicit(),
|
20843
20966
|
tableTo,
|
20844
20967
|
schemaTo,
|
20845
20968
|
columns: columnsFrom,
|
@@ -20850,8 +20973,8 @@ var init_drizzle = __esm({
|
|
20850
20973
|
})
|
20851
20974
|
);
|
20852
20975
|
for (const index5 of drizzleIndexes) {
|
20853
|
-
const
|
20854
|
-
for (const column8 of
|
20976
|
+
const columns = index5.config.columns;
|
20977
|
+
for (const column8 of columns) {
|
20855
20978
|
if ((0, import_drizzle_orm.is)(column8, import_pg_core.IndexedColumn) && column8.type !== "PgVector") continue;
|
20856
20979
|
if ((0, import_drizzle_orm.is)(column8, import_drizzle_orm.SQL) && !index5.config.name) {
|
20857
20980
|
errors.push({
|
@@ -20874,16 +20997,16 @@ var init_drizzle = __esm({
|
|
20874
20997
|
}
|
20875
20998
|
}
|
20876
20999
|
}
|
20877
|
-
indexes.push(
|
21000
|
+
res.indexes.push(
|
20878
21001
|
...drizzleIndexes.map((value) => {
|
20879
|
-
const
|
20880
|
-
let indexColumnNames =
|
21002
|
+
const columns = value.config.columns;
|
21003
|
+
let indexColumnNames = columns.map((it) => {
|
20881
21004
|
const name2 = getColumnCasing(it, casing2);
|
20882
21005
|
return name2;
|
20883
21006
|
});
|
20884
21007
|
const name = value.config.name ? value.config.name : indexName(tableName, indexColumnNames);
|
20885
21008
|
const nameExplicit = !!value.config.name;
|
20886
|
-
let indexColumns =
|
21009
|
+
let indexColumns = columns.map((it) => {
|
20887
21010
|
var _a2, _b2, _c2, _d2;
|
20888
21011
|
if ((0, import_drizzle_orm.is)(it, import_drizzle_orm.SQL)) {
|
20889
21012
|
return {
|
@@ -20922,11 +21045,12 @@ var init_drizzle = __esm({
|
|
20922
21045
|
concurrently: value.config.concurrently ?? false,
|
20923
21046
|
method: value.config.method ?? "btree",
|
20924
21047
|
with: withOpt,
|
20925
|
-
|
21048
|
+
forPK: false,
|
21049
|
+
forUnique: false
|
20926
21050
|
};
|
20927
21051
|
})
|
20928
21052
|
);
|
20929
|
-
policies.push(
|
21053
|
+
res.policies.push(
|
20930
21054
|
...drizzlePolicies.map((policy2) => {
|
20931
21055
|
const p = policyFrom(policy2, dialect5);
|
20932
21056
|
return {
|
@@ -20942,7 +21066,7 @@ var init_drizzle = __esm({
|
|
20942
21066
|
};
|
20943
21067
|
})
|
20944
21068
|
);
|
20945
|
-
checks.push(
|
21069
|
+
res.checks.push(
|
20946
21070
|
...drizzleChecks.map((check2) => {
|
20947
21071
|
const checkName = check2.name;
|
20948
21072
|
return {
|
@@ -20955,26 +21079,6 @@ var init_drizzle = __esm({
|
|
20955
21079
|
})
|
20956
21080
|
);
|
20957
21081
|
}
|
20958
|
-
for (const policy2 of schema4.policies) {
|
20959
|
-
if (!("_linkedTable" in policy2) || typeof policy2._linkedTable === "undefined") {
|
20960
|
-
warnings.push({ type: "policy_not_linked", policy: policy2.name });
|
20961
|
-
continue;
|
20962
|
-
}
|
20963
|
-
const { schema: configSchema, name: tableName } = (0, import_pg_core.getTableConfig)(policy2._linkedTable);
|
20964
|
-
const p = policyFrom(policy2, dialect5);
|
20965
|
-
policies.push({
|
20966
|
-
entityType: "policies",
|
20967
|
-
schema: configSchema ?? "public",
|
20968
|
-
table: tableName,
|
20969
|
-
name: p.name,
|
20970
|
-
as: p.as,
|
20971
|
-
for: p.for,
|
20972
|
-
roles: p.roles,
|
20973
|
-
using: p.using,
|
20974
|
-
withCheck: p.withCheck
|
20975
|
-
});
|
20976
|
-
}
|
20977
|
-
const sequences = [];
|
20978
21082
|
for (const sequence of schema4.sequences) {
|
20979
21083
|
const name = sequence.seqName;
|
20980
21084
|
const increment = stringFromIdentityProperty((_a = sequence.seqOptions) == null ? void 0 : _a.increment) ?? "1";
|
@@ -20982,7 +21086,7 @@ var init_drizzle = __esm({
|
|
20982
21086
|
const maxValue = stringFromIdentityProperty((_c = sequence.seqOptions) == null ? void 0 : _c.maxValue) ?? (parseFloat(increment) < 0 ? "-1" : "9223372036854775807");
|
20983
21087
|
const startWith = stringFromIdentityProperty((_d = sequence.seqOptions) == null ? void 0 : _d.startWith) ?? (parseFloat(increment) < 0 ? maxValue : minValue);
|
20984
21088
|
const cache = Number(stringFromIdentityProperty((_e = sequence.seqOptions) == null ? void 0 : _e.cache) ?? 1);
|
20985
|
-
sequences.push({
|
21089
|
+
res.sequences.push({
|
20986
21090
|
entityType: "sequences",
|
20987
21091
|
name,
|
20988
21092
|
schema: sequence.schema ?? "public",
|
@@ -20994,11 +21098,10 @@ var init_drizzle = __esm({
|
|
20994
21098
|
cycle: ((_f = sequence.seqOptions) == null ? void 0 : _f.cycle) ?? false
|
20995
21099
|
});
|
20996
21100
|
}
|
20997
|
-
const roles = [];
|
20998
21101
|
for (const _role of schema4.roles) {
|
20999
21102
|
const role = _role;
|
21000
21103
|
if (role._existing) continue;
|
21001
|
-
roles.push({
|
21104
|
+
res.roles.push({
|
21002
21105
|
entityType: "roles",
|
21003
21106
|
name: role.name,
|
21004
21107
|
createDb: role.createDb ?? false,
|
@@ -21006,7 +21109,6 @@ var init_drizzle = __esm({
|
|
21006
21109
|
inherit: role.inherit ?? true
|
21007
21110
|
});
|
21008
21111
|
}
|
21009
|
-
const views = [];
|
21010
21112
|
const combinedViews = [...schema4.views, ...schema4.matViews].map((it) => {
|
21011
21113
|
if ((0, import_drizzle_orm.is)(it, import_pg_core.PgView)) {
|
21012
21114
|
return {
|
@@ -21084,7 +21186,7 @@ var init_drizzle = __esm({
|
|
21084
21186
|
vacuumTruncate: getOrNull(opt, "vacuumTruncate")
|
21085
21187
|
} : null;
|
21086
21188
|
const hasNonNullOpts = Object.values(withOpt ?? {}).filter((x2) => x2 !== null).length > 0;
|
21087
|
-
views.push({
|
21189
|
+
res.views.push({
|
21088
21190
|
entityType: "views",
|
21089
21191
|
definition: isExisting ? null : dialect5.sqlToQuery(query).sql,
|
21090
21192
|
name: viewName,
|
@@ -21100,7 +21202,7 @@ var init_drizzle = __esm({
|
|
21100
21202
|
} : null
|
21101
21203
|
});
|
21102
21204
|
}
|
21103
|
-
|
21205
|
+
res.enums = schema4.enums.map((e2) => {
|
21104
21206
|
return {
|
21105
21207
|
entityType: "enums",
|
21106
21208
|
name: e2.enumName,
|
@@ -21109,27 +21211,12 @@ var init_drizzle = __esm({
|
|
21109
21211
|
};
|
21110
21212
|
});
|
21111
21213
|
return {
|
21112
|
-
schema:
|
21113
|
-
schemas,
|
21114
|
-
tables,
|
21115
|
-
enums,
|
21116
|
-
columns,
|
21117
|
-
indexes,
|
21118
|
-
fks,
|
21119
|
-
pks,
|
21120
|
-
uniques,
|
21121
|
-
checks,
|
21122
|
-
sequences,
|
21123
|
-
roles,
|
21124
|
-
policies,
|
21125
|
-
views,
|
21126
|
-
viewColumns: []
|
21127
|
-
},
|
21214
|
+
schema: res,
|
21128
21215
|
errors,
|
21129
21216
|
warnings
|
21130
21217
|
};
|
21131
21218
|
};
|
21132
|
-
|
21219
|
+
fromExports = (exports2) => {
|
21133
21220
|
const tables = [];
|
21134
21221
|
const enums = [];
|
21135
21222
|
const schemas = [];
|
@@ -21190,7 +21277,7 @@ var init_drizzle = __esm({
|
|
21190
21277
|
for (let i2 = 0; i2 < imports.length; i2++) {
|
21191
21278
|
const it = imports[i2];
|
21192
21279
|
const i0 = require(`${it}`);
|
21193
|
-
const prepared =
|
21280
|
+
const prepared = fromExports(i0);
|
21194
21281
|
tables.push(...prepared.tables);
|
21195
21282
|
enums.push(...prepared.enums);
|
21196
21283
|
schemas.push(...prepared.schemas);
|
@@ -21425,7 +21512,7 @@ function fromJson(statements) {
|
|
21425
21512
|
};
|
21426
21513
|
return result;
|
21427
21514
|
}
|
21428
|
-
var convertor, createSchemaConvertor, dropSchemaConvertor, renameSchemaConvertor, createViewConvertor, dropViewConvertor, renameViewConvertor, moveViewConvertor, alterViewConvertor, recreateViewConvertor, createTableConvertor, dropTableConvertor, renameTableConvertor, moveTableConvertor, addColumnConvertor, dropColumnConvertor, renameColumnConvertor, recreateColumnConvertor, alterColumnConvertor, createIndexConvertor, dropIndexConvertor, addPrimaryKeyConvertor, dropPrimaryKeyConvertor, recreatePrimaryKeyConvertor, renameConstraintConvertor, createForeignKeyConvertor,
|
21515
|
+
var convertor, createSchemaConvertor, dropSchemaConvertor, renameSchemaConvertor, createViewConvertor, dropViewConvertor, renameViewConvertor, moveViewConvertor, alterViewConvertor, recreateViewConvertor, createTableConvertor, dropTableConvertor, renameTableConvertor, moveTableConvertor, addColumnConvertor, dropColumnConvertor, renameColumnConvertor, recreateColumnConvertor, alterColumnConvertor, createIndexConvertor, dropIndexConvertor, renameIndexConvertor, addPrimaryKeyConvertor, dropPrimaryKeyConvertor, recreatePrimaryKeyConvertor, renameConstraintConvertor, createForeignKeyConvertor, recreateFKConvertor, dropForeignKeyConvertor, addCheckConvertor, dropCheckConvertor, recreateCheckConvertor, addUniqueConvertor, dropUniqueConvertor, createEnumConvertor, dropEnumConvertor, renameEnumConvertor, moveEnumConvertor, alterEnumConvertor, recreateEnumConvertor, createSequenceConvertor, dropSequenceConvertor, renameSequenceConvertor, moveSequenceConvertor, alterSequenceConvertor, createRoleConvertor, dropRoleConvertor, renameRoleConvertor, alterRoleConvertor, createPolicyConvertor, dropPolicyConvertor, renamePolicyConvertor, alterPolicyConvertor, recreatePolicy, toggleRlsConvertor, convertors;
|
21429
21516
|
var init_convertor = __esm({
|
21430
21517
|
"src/dialects/postgres/convertor.ts"() {
|
21431
21518
|
"use strict";
|
@@ -21536,7 +21623,7 @@ var init_convertor = __esm({
|
|
21536
21623
|
const notNullStatement = isPK ? "" : column8.notNull && !column8.identity ? " NOT NULL" : "";
|
21537
21624
|
const defaultStatement = column8.default ? ` DEFAULT ${defaultToSQL2(column8.default)}` : "";
|
21538
21625
|
const unique = uniques.find((u) => u.columns.length === 1 && u.columns[0] === column8.name);
|
21539
|
-
const unqiueConstraintPrefix = unique ? unique.nameExplicit ? `
|
21626
|
+
const unqiueConstraintPrefix = unique ? unique.nameExplicit ? `CONSTRAINT "${unique.name}" UNIQUE` : "UNIQUE" : "";
|
21540
21627
|
const uniqueConstraintStatement = unique ? ` ${unqiueConstraintPrefix}${unique.nullsNotDistinct ? " NULLS NOT DISTINCT" : ""}` : "";
|
21541
21628
|
const schemaPrefix = column8.typeSchema && column8.typeSchema !== "public" ? `"${column8.typeSchema}".` : "";
|
21542
21629
|
const arr = column8.dimensions > 0 ? "[]" : "";
|
@@ -21580,7 +21667,7 @@ var init_convertor = __esm({
|
|
21580
21667
|
const droppedPolicies = policies.map((policy2) => dropPolicyConvertor.convert({ policy: policy2 }));
|
21581
21668
|
return [
|
21582
21669
|
...droppedPolicies,
|
21583
|
-
`DROP TABLE ${tableNameWithSchema}
|
21670
|
+
`DROP TABLE ${tableNameWithSchema};`
|
21584
21671
|
];
|
21585
21672
|
});
|
21586
21673
|
renameTableConvertor = convertor("rename_table", (st) => {
|
@@ -21593,7 +21680,7 @@ var init_convertor = __esm({
|
|
21593
21680
|
`;
|
21594
21681
|
});
|
21595
21682
|
addColumnConvertor = convertor("add_column", (st) => {
|
21596
|
-
const { schema: schema4, table: table5, name } = st.column;
|
21683
|
+
const { schema: schema4, table: table5, name, identity, generated } = st.column;
|
21597
21684
|
const column8 = st.column;
|
21598
21685
|
const primaryKeyStatement = st.isPK ? " PRIMARY KEY" : "";
|
21599
21686
|
const tableNameWithSchema = schema4 !== "public" ? `"${schema4}"."${table5}"` : `"${table5}"`;
|
@@ -21601,10 +21688,9 @@ var init_convertor = __esm({
|
|
21601
21688
|
const schemaPrefix = column8.typeSchema && column8.typeSchema !== "public" ? `"${column8.typeSchema}".` : "";
|
21602
21689
|
let fixedType = parseType(schemaPrefix, column8.type);
|
21603
21690
|
fixedType += column8.dimensions > 0 ? "[]" : "";
|
21604
|
-
const notNullStatement = column8.notNull ? " NOT NULL" : "";
|
21605
|
-
const
|
21606
|
-
const
|
21607
|
-
const identityStatement = unsquashedIdentity ? ` GENERATED ${unsquashedIdentity.type === "always" ? "ALWAYS" : "BY DEFAULT"} AS IDENTITY (sequence name ${identityWithSchema}${unsquashedIdentity.increment ? ` INCREMENT BY ${unsquashedIdentity.increment}` : ""}${unsquashedIdentity.minValue ? ` MINVALUE ${unsquashedIdentity.minValue}` : ""}${unsquashedIdentity.maxValue ? ` MAXVALUE ${unsquashedIdentity.maxValue}` : ""}${unsquashedIdentity.startWith ? ` START WITH ${unsquashedIdentity.startWith}` : ""}${unsquashedIdentity.cache ? ` CACHE ${unsquashedIdentity.cache}` : ""}${unsquashedIdentity.cycle ? ` CYCLE` : ""})` : "";
|
21691
|
+
const notNullStatement = column8.notNull && !identity && !generated ? " NOT NULL" : "";
|
21692
|
+
const identityWithSchema = schema4 !== "public" ? `"${schema4}"."${identity == null ? void 0 : identity.name}"` : `"${identity == null ? void 0 : identity.name}"`;
|
21693
|
+
const identityStatement = identity ? ` GENERATED ${identity.type === "always" ? "ALWAYS" : "BY DEFAULT"} AS IDENTITY (sequence name ${identityWithSchema}${identity.increment ? ` INCREMENT BY ${identity.increment}` : ""}${identity.minValue ? ` MINVALUE ${identity.minValue}` : ""}${identity.maxValue ? ` MAXVALUE ${identity.maxValue}` : ""}${identity.startWith ? ` START WITH ${identity.startWith}` : ""}${identity.cache ? ` CACHE ${identity.cache}` : ""}${identity.cycle ? ` CYCLE` : ""})` : "";
|
21608
21694
|
const generatedStatement = column8.generated ? ` GENERATED ALWAYS AS (${column8.generated.as}) STORED` : "";
|
21609
21695
|
return `ALTER TABLE ${tableNameWithSchema} ADD COLUMN "${name}" ${fixedType}${primaryKeyStatement}${defaultStatement}${generatedStatement}${notNullStatement}${identityStatement};`;
|
21610
21696
|
});
|
@@ -21733,11 +21819,16 @@ var init_convertor = __esm({
|
|
21733
21819
|
const concur = concurrently ? " CONCURRENTLY" : "";
|
21734
21820
|
const withClause = w ? ` WITH (${w})` : "";
|
21735
21821
|
const whereClause = where ? ` WHERE ${where}` : "";
|
21736
|
-
|
21822
|
+
const using = method !== defaults.index.method ? ` USING ${method}` : "";
|
21823
|
+
return `CREATE ${indexPart}${concur} "${name}" ON ${key}${using} (${value})${withClause}${whereClause};`;
|
21737
21824
|
});
|
21738
21825
|
dropIndexConvertor = convertor("drop_index", (st) => {
|
21739
21826
|
return `DROP INDEX "${st.index.name}";`;
|
21740
21827
|
});
|
21828
|
+
renameIndexConvertor = convertor("rename_index", (st) => {
|
21829
|
+
const key = st.schema !== "public" ? `"${st.schema}"."${st.from}"` : `"${st.from}"`;
|
21830
|
+
return `ALTER INDEX ${key} RENAME TO "${st.to}";`;
|
21831
|
+
});
|
21741
21832
|
addPrimaryKeyConvertor = convertor("add_pk", (st) => {
|
21742
21833
|
const { pk } = st;
|
21743
21834
|
const key = pk.schema !== "public" ? `"${pk.schema}"."${pk.table}"` : `"${pk.table}"`;
|
@@ -21749,25 +21840,7 @@ var init_convertor = __esm({
|
|
21749
21840
|
dropPrimaryKeyConvertor = convertor("drop_pk", (st) => {
|
21750
21841
|
const pk = st.pk;
|
21751
21842
|
const key = pk.schema !== "public" ? `"${pk.schema}"."${pk.table}"` : `"${pk.table}"`;
|
21752
|
-
|
21753
|
-
return `ALTER TABLE ${key} DROP CONSTRAINT "${pk.name}";`;
|
21754
|
-
}
|
21755
|
-
return `/*
|
21756
|
-
Unfortunately in current drizzle-kit version we can't automatically get name for primary key.
|
21757
|
-
We are working on making it available!
|
21758
|
-
|
21759
|
-
Meanwhile you can:
|
21760
|
-
1. Check pk name in your database, by running
|
21761
|
-
SELECT constraint_name FROM information_schema.table_constraints
|
21762
|
-
WHERE table_schema = '${pk.schema}'
|
21763
|
-
AND table_name = '${pk.table}'
|
21764
|
-
AND constraint_type = 'PRIMARY KEY';
|
21765
|
-
2. Uncomment code below and paste pk name manually
|
21766
|
-
|
21767
|
-
Hope to release this update as soon as possible
|
21768
|
-
*/
|
21769
|
-
|
21770
|
-
-- ALTER TABLE "${key}" DROP CONSTRAINT "<constraint_name>";`;
|
21843
|
+
return `ALTER TABLE ${key} DROP CONSTRAINT "${pk.name}";`;
|
21771
21844
|
});
|
21772
21845
|
recreatePrimaryKeyConvertor = convertor("alter_pk", (it) => {
|
21773
21846
|
const drop2 = dropPrimaryKeyConvertor.convert({ pk: it.pk });
|
@@ -21788,29 +21861,23 @@ var init_convertor = __esm({
|
|
21788
21861
|
const tableToNameWithSchema = schemaTo !== "public" ? `"${schemaTo}"."${tableTo}"` : `"${tableTo}"`;
|
21789
21862
|
return `ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${name}" FOREIGN KEY (${fromColumnsString}) REFERENCES ${tableToNameWithSchema}(${toColumnsString})${onDeleteStatement}${onUpdateStatement};`;
|
21790
21863
|
});
|
21791
|
-
|
21792
|
-
const {
|
21793
|
-
const key =
|
21794
|
-
|
21795
|
-
|
21796
|
-
const
|
21797
|
-
const
|
21798
|
-
const
|
21799
|
-
|
21800
|
-
|
21801
|
-
|
21802
|
-
sql += "DO $$ BEGIN\n";
|
21803
|
-
sql += " " + alterStatement + ";\n";
|
21804
|
-
sql += "EXCEPTION\n";
|
21805
|
-
sql += " WHEN duplicate_object THEN null;\n";
|
21806
|
-
sql += "END $$;\n";
|
21864
|
+
recreateFKConvertor = convertor("recreate_fk", (st) => {
|
21865
|
+
const { fk: fk5 } = st;
|
21866
|
+
const key = fk5.schema !== "public" ? `"${fk5.schema}"."${fk5.table}"` : `"${fk5.table}"`;
|
21867
|
+
const onDeleteStatement = fk5.onDelete !== "NO ACTION" ? ` ON DELETE ${fk5.onDelete}` : "";
|
21868
|
+
const onUpdateStatement = fk5.onUpdate !== "NO ACTION" ? ` ON UPDATE ${fk5.onUpdate}` : "";
|
21869
|
+
const fromColumnsString = fk5.columns.map((it) => `"${it}"`).join(",");
|
21870
|
+
const toColumnsString = fk5.columnsTo.map((it) => `"${it}"`).join(",");
|
21871
|
+
const tableToNameWithSchema = fk5.schemaTo !== "public" ? `"${fk5.schemaTo}"."${fk5.tableTo}"` : `"${fk5.tableTo}"`;
|
21872
|
+
let sql = `ALTER TABLE ${key} DROP CONSTRAINT "${fk5.name}", `;
|
21873
|
+
sql += `ADD CONSTRAINT "${fk5.name}" FOREIGN KEY (${fromColumnsString}) `;
|
21874
|
+
sql += `REFERENCES ${tableToNameWithSchema}(${toColumnsString})${onDeleteStatement}${onUpdateStatement};`;
|
21807
21875
|
return sql;
|
21808
21876
|
});
|
21809
21877
|
dropForeignKeyConvertor = convertor("drop_fk", (st) => {
|
21810
21878
|
const { schema: schema4, table: table5, name } = st.fk;
|
21811
|
-
const tableNameWithSchema = schema4 ? `"${schema4}"."${table5}"` : `"${table5}"`;
|
21812
|
-
return `ALTER TABLE ${tableNameWithSchema} DROP CONSTRAINT "${name}"
|
21813
|
-
`;
|
21879
|
+
const tableNameWithSchema = schema4 !== "public" ? `"${schema4}"."${table5}"` : `"${table5}"`;
|
21880
|
+
return `ALTER TABLE ${tableNameWithSchema} DROP CONSTRAINT "${name}";`;
|
21814
21881
|
});
|
21815
21882
|
addCheckConvertor = convertor("add_check", (st) => {
|
21816
21883
|
const { check: check2 } = st;
|
@@ -21822,6 +21889,13 @@ var init_convertor = __esm({
|
|
21822
21889
|
const tableNameWithSchema = check2.schema !== "public" ? `"${check2.schema}"."${check2.table}"` : `"${check2.table}"`;
|
21823
21890
|
return `ALTER TABLE ${tableNameWithSchema} DROP CONSTRAINT "${check2.name}";`;
|
21824
21891
|
});
|
21892
|
+
recreateCheckConvertor = convertor("alter_check", (st) => {
|
21893
|
+
const { check: check2 } = st;
|
21894
|
+
const key = check2.schema !== "public" ? `"${check2.schema}"."${check2.table}"` : `"${check2.table}"`;
|
21895
|
+
let sql = `ALTER TABLE ${key} DROP CONSTRAINT "${check2.name}", `;
|
21896
|
+
sql += `ADD CONSTRAINT "${check2.name}" CHECK (${check2.value});`;
|
21897
|
+
return sql;
|
21898
|
+
});
|
21825
21899
|
addUniqueConvertor = convertor("add_unique", (st) => {
|
21826
21900
|
const { unique } = st;
|
21827
21901
|
const tableNameWithSchema = unique.schema !== "public" ? `"${unique.schema}"."${unique.table}"` : `"${unique.table}"`;
|
@@ -21945,7 +22019,7 @@ var init_convertor = __esm({
|
|
21945
22019
|
dropPolicyConvertor = convertor("drop_policy", (st) => {
|
21946
22020
|
const policy2 = st.policy;
|
21947
22021
|
const tableNameWithSchema = policy2.schema !== "public" ? `"${policy2.schema}"."${policy2.table}"` : `"${policy2.table}"`;
|
21948
|
-
return `DROP POLICY "${policy2.name}" ON ${tableNameWithSchema}
|
22022
|
+
return `DROP POLICY "${policy2.name}" ON ${tableNameWithSchema};`;
|
21949
22023
|
});
|
21950
22024
|
renamePolicyConvertor = convertor("rename_policy", (st) => {
|
21951
22025
|
const { from, to } = st;
|
@@ -21995,14 +22069,16 @@ var init_convertor = __esm({
|
|
21995
22069
|
alterColumnConvertor,
|
21996
22070
|
createIndexConvertor,
|
21997
22071
|
dropIndexConvertor,
|
22072
|
+
renameIndexConvertor,
|
21998
22073
|
addPrimaryKeyConvertor,
|
21999
22074
|
dropPrimaryKeyConvertor,
|
22000
22075
|
recreatePrimaryKeyConvertor,
|
22001
22076
|
createForeignKeyConvertor,
|
22002
|
-
|
22077
|
+
recreateFKConvertor,
|
22003
22078
|
dropForeignKeyConvertor,
|
22004
22079
|
addCheckConvertor,
|
22005
22080
|
dropCheckConvertor,
|
22081
|
+
recreateCheckConvertor,
|
22006
22082
|
addUniqueConvertor,
|
22007
22083
|
dropUniqueConvertor,
|
22008
22084
|
renameConstraintConvertor,
|
@@ -22069,7 +22145,7 @@ var init_statements = __esm({
|
|
22069
22145
|
});
|
22070
22146
|
|
22071
22147
|
// src/dialects/postgres/diff.ts
|
22072
|
-
var ddlDiffDry, ddlDiff;
|
22148
|
+
var ddlDiffDry, ddlDiff, preserveEntityNames;
|
22073
22149
|
var init_diff = __esm({
|
22074
22150
|
"src/dialects/postgres/diff.ts"() {
|
22075
22151
|
"use strict";
|
@@ -22080,7 +22156,6 @@ var init_diff = __esm({
|
|
22080
22156
|
init_utils3();
|
22081
22157
|
init_convertor();
|
22082
22158
|
init_ddl3();
|
22083
|
-
init_grammar2();
|
22084
22159
|
init_statements();
|
22085
22160
|
ddlDiffDry = async (ddlFrom, ddlTo, mode) => {
|
22086
22161
|
const mocks = /* @__PURE__ */ new Set();
|
@@ -22264,7 +22339,7 @@ var init_diff = __esm({
|
|
22264
22339
|
schema: rename.from.schema
|
22265
22340
|
}
|
22266
22341
|
});
|
22267
|
-
|
22342
|
+
ddl1.fks.update({
|
22268
22343
|
set: {
|
22269
22344
|
schemaTo: rename.to.schema,
|
22270
22345
|
tableTo: rename.to.name
|
@@ -22274,7 +22349,7 @@ var init_diff = __esm({
|
|
22274
22349
|
tableTo: rename.from.name
|
22275
22350
|
}
|
22276
22351
|
});
|
22277
|
-
|
22352
|
+
ddl1.fks.update({
|
22278
22353
|
set: {
|
22279
22354
|
schema: rename.to.schema,
|
22280
22355
|
table: rename.to.name
|
@@ -22284,19 +22359,7 @@ var init_diff = __esm({
|
|
22284
22359
|
table: rename.from.name
|
22285
22360
|
}
|
22286
22361
|
});
|
22287
|
-
|
22288
|
-
const name = defaultNameForFK2(fk5.table, fk5.columns, fk5.tableTo, fk5.columnsTo);
|
22289
|
-
ddl22.fks.update({
|
22290
|
-
set: { name: fk5.name },
|
22291
|
-
where: {
|
22292
|
-
schema: fk5.schema,
|
22293
|
-
table: fk5.table,
|
22294
|
-
name,
|
22295
|
-
nameExplicit: false
|
22296
|
-
}
|
22297
|
-
});
|
22298
|
-
}
|
22299
|
-
const res = ddl1.entities.update({
|
22362
|
+
ddl1.entities.update({
|
22300
22363
|
set: {
|
22301
22364
|
table: rename.to.name,
|
22302
22365
|
schema: rename.to.schema
|
@@ -22306,50 +22369,6 @@ var init_diff = __esm({
|
|
22306
22369
|
schema: rename.from.schema
|
22307
22370
|
}
|
22308
22371
|
});
|
22309
|
-
for (const it of res) {
|
22310
|
-
if (it.entityType === "pks") {
|
22311
|
-
const name = defaultNameForPK2(it.table);
|
22312
|
-
ddl22.pks.update({
|
22313
|
-
set: {
|
22314
|
-
name: it.name
|
22315
|
-
},
|
22316
|
-
where: {
|
22317
|
-
schema: it.schema,
|
22318
|
-
table: it.table,
|
22319
|
-
name,
|
22320
|
-
nameExplicit: false
|
22321
|
-
}
|
22322
|
-
});
|
22323
|
-
}
|
22324
|
-
if (it.entityType === "uniques" && !it.nameExplicit && it.columns.length === 1) {
|
22325
|
-
const name = defaultNameForUnique2(it.table, it.columns[0]);
|
22326
|
-
ddl22.uniques.update({
|
22327
|
-
set: {
|
22328
|
-
name: it.name
|
22329
|
-
},
|
22330
|
-
where: {
|
22331
|
-
schema: it.schema,
|
22332
|
-
table: it.table,
|
22333
|
-
name,
|
22334
|
-
nameExplicit: false
|
22335
|
-
}
|
22336
|
-
});
|
22337
|
-
}
|
22338
|
-
if (it.entityType === "indexes" && !it.nameExplicit) {
|
22339
|
-
const name = defaultNameForIndex(it.table, it.columns.map((c) => c.value));
|
22340
|
-
ddl22.indexes.update({
|
22341
|
-
set: {
|
22342
|
-
name: it.name
|
22343
|
-
},
|
22344
|
-
where: {
|
22345
|
-
schema: it.schema,
|
22346
|
-
table: it.table,
|
22347
|
-
name,
|
22348
|
-
nameExplicit: false
|
22349
|
-
}
|
22350
|
-
});
|
22351
|
-
}
|
22352
|
-
}
|
22353
22372
|
}
|
22354
22373
|
const columnsDiff = diff(ddl1, ddl22, "columns");
|
22355
22374
|
const columnRenames = [];
|
@@ -22376,7 +22395,7 @@ var init_diff = __esm({
|
|
22376
22395
|
schema: rename.from.schema
|
22377
22396
|
}
|
22378
22397
|
});
|
22379
|
-
|
22398
|
+
ddl1.indexes.update({
|
22380
22399
|
set: {
|
22381
22400
|
columns: (it) => {
|
22382
22401
|
if (!it.isExpression && it.value === rename.from.name) {
|
@@ -22387,24 +22406,9 @@ var init_diff = __esm({
|
|
22387
22406
|
},
|
22388
22407
|
where: {
|
22389
22408
|
schema: rename.from.schema,
|
22390
|
-
table: rename.from.table
|
22391
|
-
name: rename.from.name
|
22409
|
+
table: rename.from.table
|
22392
22410
|
}
|
22393
22411
|
});
|
22394
|
-
for (const it of indexes.filter((it2) => !it2.nameExplicit)) {
|
22395
|
-
const name = defaultNameForIndex(it.table, it.columns.map((c) => c.value));
|
22396
|
-
ddl22.indexes.update({
|
22397
|
-
set: {
|
22398
|
-
name: it.name
|
22399
|
-
},
|
22400
|
-
where: {
|
22401
|
-
schema: it.schema,
|
22402
|
-
table: it.table,
|
22403
|
-
name,
|
22404
|
-
nameExplicit: false
|
22405
|
-
}
|
22406
|
-
});
|
22407
|
-
}
|
22408
22412
|
ddl1.pks.update({
|
22409
22413
|
set: {
|
22410
22414
|
columns: (it) => {
|
@@ -22416,7 +22420,7 @@ var init_diff = __esm({
|
|
22416
22420
|
table: rename.from.table
|
22417
22421
|
}
|
22418
22422
|
});
|
22419
|
-
|
22423
|
+
ddl1.fks.update({
|
22420
22424
|
set: {
|
22421
22425
|
columns: (it) => {
|
22422
22426
|
return it === rename.from.name ? rename.to.name : it;
|
@@ -22427,7 +22431,7 @@ var init_diff = __esm({
|
|
22427
22431
|
table: rename.from.table
|
22428
22432
|
}
|
22429
22433
|
});
|
22430
|
-
|
22434
|
+
ddl1.fks.update({
|
22431
22435
|
set: {
|
22432
22436
|
columnsTo: (it) => {
|
22433
22437
|
return it === rename.from.name ? rename.to.name : it;
|
@@ -22438,19 +22442,7 @@ var init_diff = __esm({
|
|
22438
22442
|
tableTo: rename.from.table
|
22439
22443
|
}
|
22440
22444
|
});
|
22441
|
-
|
22442
|
-
const name = defaultNameForFK2(fk5.table, fk5.columns, fk5.tableTo, fk5.columnsTo);
|
22443
|
-
ddl22.fks.update({
|
22444
|
-
set: { name: fk5.name },
|
22445
|
-
where: {
|
22446
|
-
schema: fk5.schema,
|
22447
|
-
table: fk5.table,
|
22448
|
-
name,
|
22449
|
-
nameExplicit: false
|
22450
|
-
}
|
22451
|
-
});
|
22452
|
-
}
|
22453
|
-
const uniques = ddl1.uniques.update({
|
22445
|
+
ddl1.uniques.update({
|
22454
22446
|
set: {
|
22455
22447
|
columns: (it) => {
|
22456
22448
|
return it === rename.from.name ? rename.to.name : it;
|
@@ -22461,20 +22453,6 @@ var init_diff = __esm({
|
|
22461
22453
|
table: rename.from.table
|
22462
22454
|
}
|
22463
22455
|
});
|
22464
|
-
for (const it of uniques.filter((it2) => !it2.nameExplicit)) {
|
22465
|
-
const name = defaultNameForUnique2(it.table, it.columns[0]);
|
22466
|
-
ddl22.uniques.update({
|
22467
|
-
set: {
|
22468
|
-
name: it.name
|
22469
|
-
},
|
22470
|
-
where: {
|
22471
|
-
schema: it.schema,
|
22472
|
-
table: it.table,
|
22473
|
-
name,
|
22474
|
-
nameExplicit: false
|
22475
|
-
}
|
22476
|
-
});
|
22477
|
-
}
|
22478
22456
|
ddl1.checks.update({
|
22479
22457
|
set: {
|
22480
22458
|
value: rename.to.name
|
@@ -22486,8 +22464,10 @@ var init_diff = __esm({
|
|
22486
22464
|
}
|
22487
22465
|
});
|
22488
22466
|
}
|
22489
|
-
ddl1.uniques.
|
22490
|
-
ddl22.
|
22467
|
+
preserveEntityNames(ddl1.uniques, ddl22.uniques, mode);
|
22468
|
+
preserveEntityNames(ddl1.fks, ddl22.fks, mode);
|
22469
|
+
preserveEntityNames(ddl1.pks, ddl22.pks, mode);
|
22470
|
+
preserveEntityNames(ddl1.indexes, ddl22.indexes, mode);
|
22491
22471
|
const uniquesDiff = diff(ddl1, ddl22, "uniques");
|
22492
22472
|
const groupedUniquesDiff = groupDiffs(uniquesDiff);
|
22493
22473
|
const uniqueRenames = [];
|
@@ -22693,7 +22673,15 @@ var init_diff = __esm({
|
|
22693
22673
|
const jsonDropIndexes = indexesDeletes.filter(tablesFilter("deleted")).map(
|
22694
22674
|
(index5) => prepareStatement("drop_index", { index: index5 })
|
22695
22675
|
);
|
22696
|
-
|
22676
|
+
const jsonRenameIndexes = indexesRenames.map((r2) => {
|
22677
|
+
return prepareStatement("rename_index", { schema: r2.to.schema, from: r2.from.name, to: r2.to.name });
|
22678
|
+
});
|
22679
|
+
const indexesAlters = alters.filter((it) => {
|
22680
|
+
if (it.entityType !== "indexes") return false;
|
22681
|
+
delete it.concurrently;
|
22682
|
+
return ddl22.indexes.hasDiff(it);
|
22683
|
+
});
|
22684
|
+
for (const idx of indexesAlters) {
|
22697
22685
|
const forWhere = !!idx.where && (idx.where.from !== null && idx.where.to !== null ? mode !== "push" : true);
|
22698
22686
|
const forColumns = !!idx.columns && (idx.columns.from.length === idx.columns.to.length ? mode !== "push" : true);
|
22699
22687
|
if (idx.isUnique || idx.concurrently || idx.method || idx.with || forColumns || forWhere) {
|
@@ -22720,20 +22708,20 @@ var init_diff = __esm({
|
|
22720
22708
|
isPK: ddl22.pks.one({ schema: it.schema, table: it.table, columns: [it.name] }) !== null
|
22721
22709
|
})
|
22722
22710
|
);
|
22723
|
-
const columnAlters = alters.filter((it) => it.entityType === "columns").
|
22711
|
+
const columnAlters = alters.filter((it) => it.entityType === "columns").filter((it) => {
|
22724
22712
|
var _a, _b;
|
22725
22713
|
if (it.default && ((_a = it.default.from) == null ? void 0 : _a.value) === ((_b = it.default.to) == null ? void 0 : _b.value)) {
|
22726
22714
|
delete it.default;
|
22727
22715
|
}
|
22728
|
-
return it;
|
22729
|
-
})
|
22716
|
+
return ddl22.columns.hasDiff(it);
|
22717
|
+
});
|
22730
22718
|
const columnsToRecreate = columnAlters.filter((it) => it.generated && it.generated.to !== null).filter((it) => {
|
22731
22719
|
var _a;
|
22732
22720
|
return !(((_a = it.generated) == null ? void 0 : _a.to) && it.generated.from && mode === "push");
|
22733
22721
|
});
|
22734
22722
|
const jsonRecreateColumns = columnsToRecreate.map(
|
22735
22723
|
(it) => prepareStatement("recreate_column", {
|
22736
|
-
column:
|
22724
|
+
column: it.$right,
|
22737
22725
|
isPK: ddl22.pks.one({ schema: it.schema, table: it.table, columns: [it.name] }) !== null
|
22738
22726
|
})
|
22739
22727
|
);
|
@@ -22743,17 +22731,25 @@ var init_diff = __esm({
|
|
22743
22731
|
const jsonDropPrimaryKeys = pksDeletes.filter(tablesFilter("deleted")).map(
|
22744
22732
|
(it) => prepareStatement("drop_pk", { pk: it })
|
22745
22733
|
);
|
22746
|
-
const
|
22734
|
+
const jsonRenamePrimaryKey = pksRenames.map((it) => {
|
22735
|
+
return prepareStatement("rename_constraint", {
|
22736
|
+
schema: it.to.schema,
|
22737
|
+
table: it.to.table,
|
22738
|
+
from: it.from.name,
|
22739
|
+
to: it.to.name
|
22740
|
+
});
|
22741
|
+
});
|
22742
|
+
const alteredUniques = alters.filter((it) => it.entityType === "uniques").filter((it) => {
|
22747
22743
|
if (it.nameExplicit) {
|
22748
22744
|
delete it.nameExplicit;
|
22749
22745
|
}
|
22750
|
-
return it;
|
22751
|
-
})
|
22746
|
+
return ddl22.uniques.hasDiff(it);
|
22747
|
+
});
|
22752
22748
|
const jsonAlteredUniqueConstraints = alteredUniques.map((it) => prepareStatement("alter_unique", { diff: it }));
|
22753
22749
|
const jsonAddedUniqueConstraints = uniqueCreates.filter(tablesFilter("created")).map(
|
22754
22750
|
(it) => prepareStatement("add_unique", { unique: it })
|
22755
22751
|
);
|
22756
|
-
const
|
22752
|
+
const jsonDropUniqueConstraints = uniqueDeletes.filter(tablesFilter("deleted")).map(
|
22757
22753
|
(it) => prepareStatement("drop_unique", { unique: it })
|
22758
22754
|
);
|
22759
22755
|
const jsonRenamedUniqueConstraints = uniqueRenames.map(
|
@@ -22775,20 +22771,24 @@ var init_diff = __esm({
|
|
22775
22771
|
const jsonCreatedCheckConstraints = checkCreates.filter(tablesFilter("created")).map(
|
22776
22772
|
(it) => prepareStatement("add_check", { check: it })
|
22777
22773
|
);
|
22778
|
-
const
|
22774
|
+
const jsonDropCheckConstraints = checkDeletes.filter(tablesFilter("deleted")).map(
|
22779
22775
|
(it) => prepareStatement("drop_check", { check: it })
|
22780
22776
|
);
|
22781
22777
|
const alteredPKs = alters.filter((it) => it.entityType === "pks").filter((it) => {
|
22782
22778
|
return !!it.columns;
|
22783
22779
|
});
|
22784
|
-
const alteredFKs = alters.filter((it) => it.entityType === "fks");
|
22785
22780
|
const alteredChecks = alters.filter((it) => it.entityType === "checks");
|
22786
|
-
const jsonAlteredPKs = alteredPKs.map((it) => {
|
22787
|
-
|
22788
|
-
|
22789
|
-
|
22790
|
-
|
22791
|
-
|
22781
|
+
const jsonAlteredPKs = alteredPKs.map((it) => prepareStatement("alter_pk", { diff: it, pk: it.$right }));
|
22782
|
+
const jsonRecreateFKs = alters.filter((it) => it.entityType === "fks").filter((x2) => {
|
22783
|
+
if (x2.nameExplicit && (mode === "push" && x2.nameExplicit.from && !x2.nameExplicit.to || x2.nameExplicit.to && !x2.nameExplicit.from)) {
|
22784
|
+
delete x2.nameExplicit;
|
22785
|
+
}
|
22786
|
+
return ddl22.fks.hasDiff(x2);
|
22787
|
+
}).map((it) => prepareStatement("recreate_fk", { fk: it.$right }));
|
22788
|
+
const jsonCreateFKs = fksCreates.map((it) => prepareStatement("create_fk", { fk: it }));
|
22789
|
+
const jsonDropReferences = fksDeletes.filter((fk5) => {
|
22790
|
+
return !deletedTables.some((x2) => x2.schema === fk5.schema && x2.name === fk5.table);
|
22791
|
+
}).map((it) => prepareStatement("drop_fk", { fk: it }));
|
22792
22792
|
const jsonRenameReferences = fksRenames.map(
|
22793
22793
|
(it) => prepareStatement("rename_constraint", {
|
22794
22794
|
schema: it.to.schema,
|
@@ -22797,7 +22797,7 @@ var init_diff = __esm({
|
|
22797
22797
|
to: it.to.name
|
22798
22798
|
})
|
22799
22799
|
);
|
22800
|
-
const jsonAlterCheckConstraints = alteredChecks.map((it) => prepareStatement("alter_check", {
|
22800
|
+
const jsonAlterCheckConstraints = alteredChecks.map((it) => prepareStatement("alter_check", { check: it.$right }));
|
22801
22801
|
const jsonCreatePoliciesStatements = policyCreates.map((it) => prepareStatement("create_policy", { policy: it }));
|
22802
22802
|
const jsonDropPoliciesStatements = policyDeletes.map((it) => prepareStatement("drop_policy", { policy: it }));
|
22803
22803
|
const jsonRenamePoliciesStatements = policyRenames.map((it) => prepareStatement("rename_policy", it));
|
@@ -22865,10 +22865,7 @@ var init_diff = __esm({
|
|
22865
22865
|
}
|
22866
22866
|
const policiesAlters = alters.filter((it) => it.entityType === "policies");
|
22867
22867
|
const jsonPloiciesAlterStatements = policiesAlters.map(
|
22868
|
-
(it) => prepareStatement("alter_policy", {
|
22869
|
-
diff: it,
|
22870
|
-
policy: ddl22.policies.one({ schema: it.schema, table: it.name, name: it.name })
|
22871
|
-
})
|
22868
|
+
(it) => prepareStatement("alter_policy", { diff: it, policy: it.$right })
|
22872
22869
|
);
|
22873
22870
|
const jsonCreateEnums = createdEnums.map((it) => prepareStatement("create_enum", { enum: it }));
|
22874
22871
|
const jsonDropEnums = deletedEnums.map((it) => prepareStatement("drop_enum", { enum: it }));
|
@@ -22898,15 +22895,26 @@ var init_diff = __esm({
|
|
22898
22895
|
jsonAlterEnums.push(prepareStatement("alter_enum", { diff: res, enum: e2 }));
|
22899
22896
|
}
|
22900
22897
|
}
|
22901
|
-
const jsonAlterColumns = columnAlters.filter((it) => !(it.generated && it.generated.to !== null)).
|
22898
|
+
const jsonAlterColumns = columnAlters.filter((it) => !(it.generated && it.generated.to !== null)).filter((it) => {
|
22902
22899
|
if (it.default && recreateEnums.some(
|
22903
22900
|
(x2) => x2.columns.some((c) => it.schema === c.schema && it.table === c.table && it.name === c.name)
|
22904
22901
|
)) {
|
22905
22902
|
delete it.default;
|
22906
22903
|
}
|
22907
|
-
|
22908
|
-
|
22909
|
-
|
22904
|
+
if (it.notNull && it.notNull.to && (it.$right.generated || it.$right.identity)) {
|
22905
|
+
delete it.notNull;
|
22906
|
+
}
|
22907
|
+
const pkIn2 = ddl22.pks.one({ schema: it.schema, table: it.table, columns: { CONTAINS: it.name } });
|
22908
|
+
if (it.notNull && pkIn2) {
|
22909
|
+
delete it.notNull;
|
22910
|
+
}
|
22911
|
+
const pkIn1 = ddl1.pks.one({ schema: it.schema, table: it.table, columns: { CONTAINS: it.name } });
|
22912
|
+
if (it.notNull && it.notNull.from && pkIn1 && !pkIn2) {
|
22913
|
+
delete it.notNull;
|
22914
|
+
}
|
22915
|
+
return ddl22.columns.hasDiff(it);
|
22916
|
+
}).map((it) => {
|
22917
|
+
const column8 = it.$right;
|
22910
22918
|
return prepareStatement("alter_column", {
|
22911
22919
|
diff: it,
|
22912
22920
|
isEnum: ddl22.enums.one({ schema: column8.typeSchema ?? "public", name: column8.type }) !== null,
|
@@ -22920,17 +22928,13 @@ var init_diff = __esm({
|
|
22920
22928
|
const renameSequences = renamedSequences.map((it) => prepareStatement("rename_sequence", it));
|
22921
22929
|
const sequencesAlter = alters.filter((it) => it.entityType === "sequences");
|
22922
22930
|
const jsonAlterSequences = sequencesAlter.map(
|
22923
|
-
(it) => prepareStatement("alter_sequence", {
|
22924
|
-
diff: it,
|
22925
|
-
sequence: ddl22.sequences.one({ schema: it.schema, name: it.name })
|
22926
|
-
})
|
22931
|
+
(it) => prepareStatement("alter_sequence", { diff: it, sequence: it.$right })
|
22927
22932
|
);
|
22928
|
-
const
|
22929
|
-
const
|
22930
|
-
const
|
22931
|
-
const
|
22932
|
-
|
22933
|
-
(it) => prepareStatement("alter_role", { diff: it, role: ddl22.roles.one({ name: it.name }) })
|
22933
|
+
const jsonCreateRoles = createdRoles.map((it) => prepareStatement("create_role", { role: it }));
|
22934
|
+
const jsonDropRoles = deletedRoles.map((it) => prepareStatement("drop_role", { role: it }));
|
22935
|
+
const jsonRenameRoles = renamedRoles.map((it) => prepareStatement("rename_role", it));
|
22936
|
+
const jsonAlterRoles = alters.filter((it) => it.entityType === "roles").map(
|
22937
|
+
(it) => prepareStatement("alter_role", { diff: it, role: it.$right })
|
22934
22938
|
);
|
22935
22939
|
const createSchemas = createdSchemas.map((it) => prepareStatement("create_schema", it));
|
22936
22940
|
const dropSchemas = deletedSchemas.map((it) => prepareStatement("drop_schema", it));
|
@@ -22954,10 +22958,9 @@ var init_diff = __esm({
|
|
22954
22958
|
}
|
22955
22959
|
return it;
|
22956
22960
|
}).filter((it) => !(it.isExisting && it.isExisting.to));
|
22957
|
-
const viewsAlters = filteredViewAlters.map((it) => {
|
22958
|
-
|
22959
|
-
|
22960
|
-
}).filter((it) => !it.view.isExisting);
|
22961
|
+
const viewsAlters = filteredViewAlters.map((it) => ({ diff: it, view: it.$right })).filter(
|
22962
|
+
(it) => !it.view.isExisting
|
22963
|
+
);
|
22961
22964
|
const jsonAlterViews = viewsAlters.filter((it) => !it.diff.definition).map((it) => {
|
22962
22965
|
return prepareStatement("alter_view", {
|
22963
22966
|
diff: it.diff,
|
@@ -22990,9 +22993,9 @@ var init_diff = __esm({
|
|
22990
22993
|
jsonStatements.push(...moveSequences);
|
22991
22994
|
jsonStatements.push(...renameSequences);
|
22992
22995
|
jsonStatements.push(...jsonAlterSequences);
|
22993
|
-
jsonStatements.push(...
|
22994
|
-
jsonStatements.push(...
|
22995
|
-
jsonStatements.push(...
|
22996
|
+
jsonStatements.push(...jsonRenameRoles);
|
22997
|
+
jsonStatements.push(...jsonDropRoles);
|
22998
|
+
jsonStatements.push(...jsonCreateRoles);
|
22996
22999
|
jsonStatements.push(...jsonAlterRoles);
|
22997
23000
|
jsonStatements.push(...createTables);
|
22998
23001
|
jsonStatements.push(...jsonAlterRlsStatements);
|
@@ -23006,17 +23009,21 @@ var init_diff = __esm({
|
|
23006
23009
|
jsonStatements.push(...jsonRenameTables);
|
23007
23010
|
jsonStatements.push(...jsonSetTableSchemas);
|
23008
23011
|
jsonStatements.push(...jsonRenameColumnsStatements);
|
23009
|
-
jsonStatements.push(...
|
23010
|
-
jsonStatements.push(...
|
23012
|
+
jsonStatements.push(...jsonDropUniqueConstraints);
|
23013
|
+
jsonStatements.push(...jsonDropCheckConstraints);
|
23011
23014
|
jsonStatements.push(...jsonDropReferences);
|
23015
|
+
jsonStatements.push(...jsonRenameIndexes);
|
23012
23016
|
jsonStatements.push(...jsonDropIndexes);
|
23013
23017
|
jsonStatements.push(...jsonDropPrimaryKeys);
|
23014
23018
|
jsonStatements.push(...jsonAddPrimaryKeys);
|
23019
|
+
jsonStatements.push(...jsonRenamePrimaryKey);
|
23020
|
+
jsonStatements.push(...jsonRenameReferences);
|
23015
23021
|
jsonStatements.push(...jsonAddColumnsStatemets);
|
23016
23022
|
jsonStatements.push(...recreateEnums);
|
23017
23023
|
jsonStatements.push(...jsonRecreateColumns);
|
23018
23024
|
jsonStatements.push(...jsonAlterColumns);
|
23019
|
-
jsonStatements.push(...
|
23025
|
+
jsonStatements.push(...jsonCreateFKs);
|
23026
|
+
jsonStatements.push(...jsonRecreateFKs);
|
23020
23027
|
jsonStatements.push(...jsonCreateIndexes);
|
23021
23028
|
jsonStatements.push(...jsonDropColumnsStatemets);
|
23022
23029
|
jsonStatements.push(...jsonAlteredPKs);
|
@@ -23024,6 +23031,7 @@ var init_diff = __esm({
|
|
23024
23031
|
jsonStatements.push(...jsonAddedUniqueConstraints);
|
23025
23032
|
jsonStatements.push(...jsonCreatedCheckConstraints);
|
23026
23033
|
jsonStatements.push(...jsonAlteredUniqueConstraints);
|
23034
|
+
jsonStatements.push(...jsonAlterCheckConstraints);
|
23027
23035
|
jsonStatements.push(...createViews);
|
23028
23036
|
jsonStatements.push(...jsonRenamePoliciesStatements);
|
23029
23037
|
jsonStatements.push(...jsonCreatePoliciesStatements);
|
@@ -23054,6 +23062,21 @@ var init_diff = __esm({
|
|
23054
23062
|
renames
|
23055
23063
|
};
|
23056
23064
|
};
|
23065
|
+
preserveEntityNames = (collection1, collection2, mode) => {
|
23066
|
+
const items = collection1.list().filter((x2) => mode === "push" || !x2.nameExplicit);
|
23067
|
+
for (const left of items) {
|
23068
|
+
const { entityType: _2, name, nameExplicit, ...filter2 } = left;
|
23069
|
+
const match2 = collection2.list({ ...filter2, nameExplicit: false });
|
23070
|
+
if (match2.length !== 1 || match2[0].name === left.name) continue;
|
23071
|
+
collection2.update({
|
23072
|
+
set: { name: left.name },
|
23073
|
+
where: {
|
23074
|
+
...filter2,
|
23075
|
+
nameExplicit: false
|
23076
|
+
}
|
23077
|
+
});
|
23078
|
+
}
|
23079
|
+
};
|
23057
23080
|
}
|
23058
23081
|
});
|
23059
23082
|
|
@@ -23193,7 +23216,6 @@ var init_generate_postgres = __esm({
|
|
23193
23216
|
init_diff();
|
23194
23217
|
init_serializer2();
|
23195
23218
|
init_utils_node();
|
23196
|
-
init_mocks();
|
23197
23219
|
init_prompts();
|
23198
23220
|
init_generate_common();
|
23199
23221
|
handle = async (config) => {
|
@@ -23215,7 +23237,6 @@ var init_generate_postgres = __esm({
|
|
23215
23237
|
});
|
23216
23238
|
return;
|
23217
23239
|
}
|
23218
|
-
const blanks = /* @__PURE__ */ new Set();
|
23219
23240
|
const { sqlStatements, renames } = await ddlDiff(
|
23220
23241
|
ddlPrev,
|
23221
23242
|
ddlCur,
|
@@ -23227,17 +23248,11 @@ var init_generate_postgres = __esm({
|
|
23227
23248
|
resolver("table"),
|
23228
23249
|
resolver("column"),
|
23229
23250
|
resolver("view"),
|
23230
|
-
|
23231
|
-
|
23232
|
-
|
23233
|
-
|
23234
|
-
|
23235
|
-
mockResolver(blanks),
|
23236
|
-
// checks
|
23237
|
-
mockResolver(blanks),
|
23238
|
-
// pks
|
23239
|
-
mockResolver(blanks),
|
23240
|
-
// fks
|
23251
|
+
resolver("unique"),
|
23252
|
+
resolver("index"),
|
23253
|
+
resolver("check"),
|
23254
|
+
resolver("primary key"),
|
23255
|
+
resolver("foreign key"),
|
23241
23256
|
"default"
|
23242
23257
|
);
|
23243
23258
|
writeResult({
|
@@ -23358,7 +23373,7 @@ var init_drizzle2 = __esm({
|
|
23358
23373
|
const autoIncrement = typeof column8.autoIncrement === "undefined" ? false : column8.autoIncrement;
|
23359
23374
|
const generated = column8.generated ? {
|
23360
23375
|
as: (0, import_drizzle_orm2.is)(column8.generated.as, import_drizzle_orm2.SQL) ? dialect5.sqlToQuery(column8.generated.as).sql : typeof column8.generated.as === "function" ? dialect5.sqlToQuery(column8.generated.as()).sql : column8.generated.as,
|
23361
|
-
type: column8.generated.mode
|
23376
|
+
type: column8.generated.mode === "virtual" ? "virtual" : "stored"
|
23362
23377
|
} : null;
|
23363
23378
|
result.columns.push({
|
23364
23379
|
entityType: "columns",
|
@@ -23369,13 +23384,6 @@ var init_drizzle2 = __esm({
|
|
23369
23384
|
autoIncrement,
|
23370
23385
|
onUpdateNow: column8.hasOnUpdateNow ?? false,
|
23371
23386
|
// TODO: ??
|
23372
|
-
// @ts-expect-error
|
23373
|
-
// TODO update description
|
23374
|
-
// 'virtual' | 'stored' for for all dialects
|
23375
|
-
// 'virtual' | 'persisted' for mssql
|
23376
|
-
// We should remove this option from common Column and store it per dialect common
|
23377
|
-
// Was discussed with Andrew
|
23378
|
-
// Type erorr because of common in drizzle orm for all dialects (includes virtual' | 'stored' | 'persisted')
|
23379
23387
|
generated,
|
23380
23388
|
isPK: column8.primary,
|
23381
23389
|
isUnique: column8.isUnique,
|
@@ -23976,7 +23984,7 @@ var init_diff2 = __esm({
|
|
23976
23984
|
tableTo: renamed.from.name
|
23977
23985
|
}
|
23978
23986
|
});
|
23979
|
-
const renamedFKs = [...selfRefs, ...froms, ...tos];
|
23987
|
+
const renamedFKs = [...selfRefs.data, ...froms.data, ...tos.data];
|
23980
23988
|
for (const fk5 of renamedFKs) {
|
23981
23989
|
const name = nameForForeignKey2(fk5);
|
23982
23990
|
ddl22.fks.update({
|
@@ -24566,7 +24574,7 @@ var init_diff3 = __esm({
|
|
24566
24574
|
tableTo: renamed.from.name
|
24567
24575
|
}
|
24568
24576
|
});
|
24569
|
-
const renamedFKs = [...selfRefs, ...froms, ...tos];
|
24577
|
+
const renamedFKs = [...selfRefs.data, ...froms.data, ...tos.data];
|
24570
24578
|
for (const fk5 of renamedFKs) {
|
24571
24579
|
const name = nameForForeignKey(fk5);
|
24572
24580
|
ddl22.fks.update({
|
@@ -24802,7 +24810,7 @@ var init_diff3 = __esm({
|
|
24802
24810
|
});
|
24803
24811
|
|
24804
24812
|
// src/dialects/sqlite/drizzle.ts
|
24805
|
-
var import_drizzle_orm3, import_sqlite_core, fromDrizzleSchema3,
|
24813
|
+
var import_drizzle_orm3, import_sqlite_core, fromDrizzleSchema3, fromExports2, prepareFromSchemaFiles3;
|
24806
24814
|
var init_drizzle3 = __esm({
|
24807
24815
|
"src/dialects/sqlite/drizzle.ts"() {
|
24808
24816
|
"use strict";
|
@@ -24953,7 +24961,7 @@ var init_drizzle3 = __esm({
|
|
24953
24961
|
});
|
24954
24962
|
return { tables, columns, indexes, uniques, fks, pks, checks, views };
|
24955
24963
|
};
|
24956
|
-
|
24964
|
+
fromExports2 = (exports2) => {
|
24957
24965
|
const tables = [];
|
24958
24966
|
const views = [];
|
24959
24967
|
const i0values = Object.values(exports2);
|
@@ -24974,7 +24982,7 @@ var init_drizzle3 = __esm({
|
|
24974
24982
|
for (let i2 = 0; i2 < imports.length; i2++) {
|
24975
24983
|
const it = imports[i2];
|
24976
24984
|
const i0 = require(`${it}`);
|
24977
|
-
const prepared =
|
24985
|
+
const prepared = fromExports2(i0);
|
24978
24986
|
tables.push(...prepared.tables);
|
24979
24987
|
views.push(...prepared.views);
|
24980
24988
|
}
|
@@ -25499,7 +25507,7 @@ function fromJson4(statements) {
|
|
25499
25507
|
};
|
25500
25508
|
return result;
|
25501
25509
|
}
|
25502
|
-
var convertor4, createTable3, dropTable3, renameTable3, addColumn2, dropColumn2, renameColumn2, alterColumn2, recreateColumn2, createIndex3, dropIndex3, createFK2, createPK2, renamePk, renameCheck, renameFk, renameIndex, renameUnique, createCheck2, dropConstraint2, createView3, dropView3, renameView2, alterView2, createSchema, dropSchema, renameSchema, moveTable, moveView, addUniqueConvertor2, dropPK2, recreatePK2, recreateView, addCheck, dropCheck, alterCheck, dropUnique, dropForeignKey, convertors4;
|
25510
|
+
var convertor4, createTable3, dropTable3, renameTable3, addColumn2, dropColumn2, renameColumn2, alterColumn2, recreateColumn2, createIndex3, dropIndex3, createFK2, createPK2, renamePk, renameCheck, renameFk, renameIndex, renameUnique, createCheck2, dropConstraint2, createView3, dropView3, renameView2, alterView2, createSchema, dropSchema, renameSchema, moveTable, moveView, addUniqueConvertor2, dropPK2, recreatePK2, recreateView, addCheck, dropCheck, alterCheck, dropUnique, dropForeignKey, addDefault, dropDefault, renameDefault, convertors4;
|
25503
25511
|
var init_convertor4 = __esm({
|
25504
25512
|
"src/dialects/mssql/convertor.ts"() {
|
25505
25513
|
"use strict";
|
@@ -25526,11 +25534,9 @@ var init_convertor4 = __esm({
|
|
25526
25534
|
const identity = column8.identity;
|
25527
25535
|
const identityStatement = identity ? ` IDENTITY(${identity.seed}, ${identity.increment})` : "";
|
25528
25536
|
const notNullStatement = isPK ? "" : column8.notNull && !column8.identity ? " NOT NULL" : "";
|
25529
|
-
const def = defaultToSQL(column8.default);
|
25530
|
-
const defaultStatement = def ? ` DEFAULT ${def}` : "";
|
25531
25537
|
const generatedType = ((_a = column8.generated) == null ? void 0 : _a.type.toUpperCase()) === "VIRTUAL" ? "" : (_b = column8.generated) == null ? void 0 : _b.type.toUpperCase();
|
25532
25538
|
const generatedStatement = column8.generated ? ` AS (${(_c = column8.generated) == null ? void 0 : _c.as})${" " + generatedType}` : "";
|
25533
|
-
statement += ` [${column8.name}] ${column8.type}${identityStatement}${generatedStatement}${notNullStatement}
|
25539
|
+
statement += ` [${column8.name}] ${column8.type}${identityStatement}${generatedStatement}${notNullStatement}`;
|
25534
25540
|
statement += i2 === columns.length - 1 ? "" : ",\n";
|
25535
25541
|
}
|
25536
25542
|
if (pk) {
|
@@ -25574,8 +25580,6 @@ var init_convertor4 = __esm({
|
|
25574
25580
|
identity,
|
25575
25581
|
schema: schema4
|
25576
25582
|
} = column8;
|
25577
|
-
const def = defaultToSQL(column8.default);
|
25578
|
-
const defaultStatement = def ? ` DEFAULT ${def}` : "";
|
25579
25583
|
const notNullStatement = `${notNull ? " NOT NULL" : ""}`;
|
25580
25584
|
const identityStatement = identity ? ` IDENTITY(${identity.seed}, ${identity.increment})` : "";
|
25581
25585
|
const generatedType = ((_a = column8.generated) == null ? void 0 : _a.type.toUpperCase()) === "VIRTUAL" ? "" : (_b = column8.generated) == null ? void 0 : _b.type.toUpperCase();
|
@@ -25583,7 +25587,7 @@ var init_convertor4 = __esm({
|
|
25583
25587
|
const key = schema4 !== "dbo" ? `[${schema4}].[${table5}]` : `[${table5}]`;
|
25584
25588
|
let statement = `ALTER TABLE ${key} ADD [${name}]`;
|
25585
25589
|
if (!generated) statement += ` ${type}`;
|
25586
|
-
statement += `${identityStatement}${
|
25590
|
+
statement += `${identityStatement}${generatedStatement}${notNullStatement};`;
|
25587
25591
|
return statement;
|
25588
25592
|
});
|
25589
25593
|
dropColumn2 = convertor4("drop_column", (st) => {
|
@@ -25599,14 +25603,12 @@ var init_convertor4 = __esm({
|
|
25599
25603
|
});
|
25600
25604
|
alterColumn2 = convertor4("alter_column", (st) => {
|
25601
25605
|
const { diff: diff2, column: column8, isPK } = st;
|
25602
|
-
const def = defaultToSQL(column8.default);
|
25603
|
-
const defaultStatement = def ? ` DEFAULT ${def}` : "";
|
25604
25606
|
const identity = column8.identity;
|
25605
25607
|
const notNullStatement = `${column8.notNull ? " NOT NULL" : ""}`;
|
25606
25608
|
const identityStatement = identity ? ` IDENTITY(${identity.seed}, ${identity.increment})` : "";
|
25607
25609
|
const generatedStatement = column8.generated ? ` AS (${column8.generated.as}) ${column8.generated.type.toUpperCase()}` : "";
|
25608
25610
|
const key = column8.schema !== "dbo" ? `[${column8.schema}].[${column8.table}]` : `[${column8.table}]`;
|
25609
|
-
return `ALTER TABLE ${key} ALTER COLUMN [${column8.name}] ${column8.type}${identityStatement}${
|
25611
|
+
return `ALTER TABLE ${key} ALTER COLUMN [${column8.name}] ${column8.type}${identityStatement}${generatedStatement}${notNullStatement};`;
|
25610
25612
|
});
|
25611
25613
|
recreateColumn2 = convertor4("recreate_column", (st) => {
|
25612
25614
|
return [dropColumn2.convert(st), addColumn2.convert(st)];
|
@@ -25827,6 +25829,22 @@ WITH CHECK OPTION` : "";
|
|
25827
25829
|
return `ALTER TABLE ${tableNameWithSchema} DROP CONSTRAINT [${name}];
|
25828
25830
|
`;
|
25829
25831
|
});
|
25832
|
+
addDefault = convertor4("create_default", (st) => {
|
25833
|
+
const { schema: schema4, table: table5, name, default: tableDefault } = st.default;
|
25834
|
+
const tableNameWithSchema = schema4 !== "dbo" ? `[${schema4}].[${table5}]` : `[${table5}]`;
|
25835
|
+
return `ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT [${name}] DEFAULT ${defaultToSQL(tableDefault)};`;
|
25836
|
+
});
|
25837
|
+
dropDefault = convertor4("drop_default", (st) => {
|
25838
|
+
const { schema: schema4, table: table5, name } = st.default;
|
25839
|
+
const tableNameWithSchema = schema4 !== "dbo" ? `[${schema4}].[${table5}]` : `[${table5}]`;
|
25840
|
+
return `ALTER TABLE ${tableNameWithSchema} DROP CONSTRAINT [${name}];`;
|
25841
|
+
});
|
25842
|
+
renameDefault = convertor4("rename_default", (st) => {
|
25843
|
+
const { name: nameFrom, schema: schemaFrom } = st.from;
|
25844
|
+
const { name: nameTo } = st.to;
|
25845
|
+
const key = schemaFrom !== "dbo" ? `${schemaFrom}.${nameFrom}` : `${nameFrom}`;
|
25846
|
+
return `EXEC sp_rename '${key}', [${nameTo}], 'OBJECT';`;
|
25847
|
+
});
|
25830
25848
|
convertors4 = [
|
25831
25849
|
createTable3,
|
25832
25850
|
dropTable3,
|
@@ -25864,7 +25882,10 @@ WITH CHECK OPTION` : "";
|
|
25864
25882
|
renameIndex,
|
25865
25883
|
dropUnique,
|
25866
25884
|
dropForeignKey,
|
25867
|
-
renameUnique
|
25885
|
+
renameUnique,
|
25886
|
+
addDefault,
|
25887
|
+
dropDefault,
|
25888
|
+
renameDefault
|
25868
25889
|
];
|
25869
25890
|
}
|
25870
25891
|
});
|
@@ -25910,10 +25931,11 @@ var init_diff5 = __esm({
|
|
25910
25931
|
mockResolver(mocks),
|
25911
25932
|
mockResolver(mocks),
|
25912
25933
|
mockResolver(mocks),
|
25934
|
+
mockResolver(mocks),
|
25913
25935
|
mode
|
25914
25936
|
);
|
25915
25937
|
};
|
25916
|
-
ddlDiff3 = async (ddl1, ddl22, schemasResolver, tablesResolver, columnsResolver, viewsResolver, uniquesResolver, indexesResolver, checksResolver, pksResolver, fksResolver, type) => {
|
25938
|
+
ddlDiff3 = async (ddl1, ddl22, schemasResolver, tablesResolver, columnsResolver, viewsResolver, uniquesResolver, indexesResolver, checksResolver, pksResolver, fksResolver, defaultsResolver, type) => {
|
25917
25939
|
const ddl1Copy = createDDL();
|
25918
25940
|
for (const entity of ddl1.entities.list()) {
|
25919
25941
|
ddl1Copy.entities.push(entity);
|
@@ -25948,7 +25970,6 @@ var init_diff5 = __esm({
|
|
25948
25970
|
const createSchemas = createdSchemas.map((it) => prepareStatement4("create_schema", it));
|
25949
25971
|
const dropSchemas = deletedSchemas.map((it) => prepareStatement4("drop_schema", it));
|
25950
25972
|
const renameSchemas = renamedSchemas.map((it) => prepareStatement4("rename_schema", it));
|
25951
|
-
const checkRenames = [];
|
25952
25973
|
const tablesDiff = diff(ddl1, ddl22, "tables");
|
25953
25974
|
const {
|
25954
25975
|
created: createdTables,
|
@@ -25964,6 +25985,8 @@ var init_diff5 = __esm({
|
|
25964
25985
|
const pksRenames = [];
|
25965
25986
|
const uniqueRenames = [];
|
25966
25987
|
const fksRenames = [];
|
25988
|
+
const checkRenames = [];
|
25989
|
+
const defaultsRenames = [];
|
25967
25990
|
for (const rename of renamedOrMovedTables) {
|
25968
25991
|
ddl1.tables.update({
|
25969
25992
|
set: {
|
@@ -25995,7 +26018,7 @@ var init_diff5 = __esm({
|
|
25995
26018
|
table: rename.from.name
|
25996
26019
|
}
|
25997
26020
|
});
|
25998
|
-
const copies = [...copy(fks1), ...copy(fks2)];
|
26021
|
+
const copies = [...copy(fks1.data), ...copy(fks2.data)];
|
25999
26022
|
for (const fk5 of copies.filter((it) => !it.nameExplicit)) {
|
26000
26023
|
const name = defaultNameForFK(fk5.table, fk5.columns, fk5.tableTo, fk5.columnsTo);
|
26001
26024
|
const updated = ddl1.fks.update({
|
@@ -26007,7 +26030,7 @@ var init_diff5 = __esm({
|
|
26007
26030
|
nameExplicit: false
|
26008
26031
|
}
|
26009
26032
|
});
|
26010
|
-
fksRenames.push({ to: updated[0], from: fk5 });
|
26033
|
+
fksRenames.push({ to: updated.data[0], from: fk5 });
|
26011
26034
|
}
|
26012
26035
|
const res = ddl1.entities.update({
|
26013
26036
|
set: {
|
@@ -26019,7 +26042,7 @@ var init_diff5 = __esm({
|
|
26019
26042
|
schema: rename.from.schema
|
26020
26043
|
}
|
26021
26044
|
});
|
26022
|
-
for (const it of res) {
|
26045
|
+
for (const it of res.data) {
|
26023
26046
|
if (it.entityType === "pks" && !it.nameExplicit) {
|
26024
26047
|
const name = defaultNameForPK(it.table);
|
26025
26048
|
const originalPk = copy(
|
@@ -26037,7 +26060,7 @@ var init_diff5 = __esm({
|
|
26037
26060
|
nameExplicit: false
|
26038
26061
|
}
|
26039
26062
|
});
|
26040
|
-
pksRenames.push({ from: originalPk, to: updated[0] });
|
26063
|
+
pksRenames.push({ from: originalPk, to: updated.data[0] });
|
26041
26064
|
}
|
26042
26065
|
if (it.entityType === "uniques" && !it.nameExplicit) {
|
26043
26066
|
const name = defaultNameForUnique(it.table, it.columns);
|
@@ -26059,7 +26082,29 @@ var init_diff5 = __esm({
|
|
26059
26082
|
nameExplicit: false
|
26060
26083
|
}
|
26061
26084
|
});
|
26062
|
-
uniqueRenames.push({ from: originalUnique, to: updated[0] });
|
26085
|
+
uniqueRenames.push({ from: originalUnique, to: updated.data[0] });
|
26086
|
+
}
|
26087
|
+
if (it.entityType === "defaults" && !it.nameExplicit) {
|
26088
|
+
const name = defaultNameForDefault(it.table, it.column);
|
26089
|
+
const originalDefaults = copy(ddl1.defaults.one({
|
26090
|
+
schema: it.schema,
|
26091
|
+
table: it.table,
|
26092
|
+
name: it.name,
|
26093
|
+
nameExplicit: false
|
26094
|
+
}));
|
26095
|
+
if (!originalDefaults) throw Error("Unhandled error occurred: Can not find original Default");
|
26096
|
+
const updated = ddl1.defaults.update({
|
26097
|
+
set: {
|
26098
|
+
name
|
26099
|
+
},
|
26100
|
+
where: {
|
26101
|
+
schema: it.schema,
|
26102
|
+
table: it.table,
|
26103
|
+
name: it.name,
|
26104
|
+
nameExplicit: false
|
26105
|
+
}
|
26106
|
+
});
|
26107
|
+
defaultsRenames.push({ from: originalDefaults, to: updated.data[0] });
|
26063
26108
|
}
|
26064
26109
|
}
|
26065
26110
|
}
|
@@ -26121,17 +26166,19 @@ var init_diff5 = __esm({
|
|
26121
26166
|
tableTo: rename.from.table
|
26122
26167
|
}
|
26123
26168
|
});
|
26124
|
-
|
26169
|
+
const copies = [...copy(fks1.data), ...copy(fks2.data)];
|
26170
|
+
for (const fk5 of copies.filter((it) => !it.nameExplicit)) {
|
26125
26171
|
const name = defaultNameForFK(fk5.table, fk5.columns, fk5.tableTo, fk5.columnsTo);
|
26126
|
-
|
26127
|
-
set: { name
|
26172
|
+
const updated = ddl1.fks.update({
|
26173
|
+
set: { name },
|
26128
26174
|
where: {
|
26129
26175
|
schema: fk5.schema,
|
26130
26176
|
table: fk5.table,
|
26131
|
-
name,
|
26177
|
+
name: fk5.name,
|
26132
26178
|
nameExplicit: false
|
26133
26179
|
}
|
26134
26180
|
});
|
26181
|
+
fksRenames.push({ to: updated.data[0], from: fk5 });
|
26135
26182
|
}
|
26136
26183
|
const uniques = ddl1.uniques.update({
|
26137
26184
|
set: {
|
@@ -26144,19 +26191,56 @@ var init_diff5 = __esm({
|
|
26144
26191
|
table: rename.from.table
|
26145
26192
|
}
|
26146
26193
|
});
|
26147
|
-
for (const it of uniques.filter((it2) => !it2.nameExplicit)) {
|
26194
|
+
for (const it of uniques.data.filter((it2) => !it2.nameExplicit)) {
|
26195
|
+
const originalUnique = copy(ddl1.uniques.one({
|
26196
|
+
schema: it.schema,
|
26197
|
+
table: it.table,
|
26198
|
+
name: it.name,
|
26199
|
+
nameExplicit: false
|
26200
|
+
}));
|
26201
|
+
if (!originalUnique) throw Error("Unhandled error occurred: Can not find original Unique");
|
26148
26202
|
const name = defaultNameForUnique(it.table, [it.columns[0]]);
|
26149
|
-
|
26203
|
+
const updated = ddl1.uniques.update({
|
26150
26204
|
set: {
|
26151
|
-
name
|
26205
|
+
name
|
26152
26206
|
},
|
26153
26207
|
where: {
|
26154
26208
|
schema: it.schema,
|
26155
26209
|
table: it.table,
|
26156
|
-
name,
|
26210
|
+
name: it.name,
|
26211
|
+
nameExplicit: false
|
26212
|
+
}
|
26213
|
+
});
|
26214
|
+
uniqueRenames.push({ from: originalUnique, to: updated.data[0] });
|
26215
|
+
}
|
26216
|
+
const columnsDefaults = ddl1.defaults.update({
|
26217
|
+
set: { column: rename.to.name },
|
26218
|
+
where: {
|
26219
|
+
schema: rename.from.schema,
|
26220
|
+
table: rename.from.table
|
26221
|
+
}
|
26222
|
+
});
|
26223
|
+
for (const it of columnsDefaults.data.filter((it2) => !it2.nameExplicit)) {
|
26224
|
+
const originalDefault = copy(ddl1.defaults.one({
|
26225
|
+
schema: it.schema,
|
26226
|
+
table: it.table,
|
26227
|
+
name: it.name,
|
26228
|
+
nameExplicit: false
|
26229
|
+
}));
|
26230
|
+
if (!originalDefault) throw Error("Unhandled error occurred: Can not find original Default");
|
26231
|
+
const name = defaultNameForDefault(it.table, it.column);
|
26232
|
+
const updated = ddl1.defaults.update({
|
26233
|
+
set: {
|
26234
|
+
name
|
26235
|
+
},
|
26236
|
+
where: {
|
26237
|
+
schema: it.schema,
|
26238
|
+
table: it.table,
|
26239
|
+
name: it.name,
|
26157
26240
|
nameExplicit: false
|
26158
26241
|
}
|
26159
26242
|
});
|
26243
|
+
defaultsRenames.push({ from: originalDefault, to: updated.data[0] });
|
26160
26244
|
}
|
26161
26245
|
ddl1.checks.update({
|
26162
26246
|
set: {
|
@@ -26330,6 +26414,31 @@ var init_diff5 = __esm({
|
|
26330
26414
|
}
|
26331
26415
|
});
|
26332
26416
|
}
|
26417
|
+
const diffDefaults = diff(ddl1, ddl22, "defaults");
|
26418
|
+
const groupedDefaultsDiff = groupDiffs(diffDefaults);
|
26419
|
+
const defaultsCreates = [];
|
26420
|
+
const defaultsDeletes = [];
|
26421
|
+
for (const entry of groupedDefaultsDiff) {
|
26422
|
+
const { renamedOrMoved, created, deleted } = await defaultsResolver({
|
26423
|
+
created: entry.inserted,
|
26424
|
+
deleted: entry.deleted
|
26425
|
+
});
|
26426
|
+
defaultsCreates.push(...created);
|
26427
|
+
defaultsDeletes.push(...deleted);
|
26428
|
+
defaultsRenames.push(...renamedOrMoved);
|
26429
|
+
}
|
26430
|
+
for (const rename of defaultsRenames) {
|
26431
|
+
ddl1.defaults.update({
|
26432
|
+
set: {
|
26433
|
+
name: rename.to.name,
|
26434
|
+
schema: rename.to.schema
|
26435
|
+
},
|
26436
|
+
where: {
|
26437
|
+
name: rename.from.name,
|
26438
|
+
schema: rename.from.schema
|
26439
|
+
}
|
26440
|
+
});
|
26441
|
+
}
|
26333
26442
|
const alters = diff.alters(ddl1, ddl22);
|
26334
26443
|
const jsonStatements = [];
|
26335
26444
|
const tablesFilter = (type2) => {
|
@@ -26346,6 +26455,15 @@ var init_diff5 = __esm({
|
|
26346
26455
|
(index5) => prepareStatement4("drop_index", { index: index5 })
|
26347
26456
|
);
|
26348
26457
|
const jsonRenameIndex = indexesRenames.map((it) => prepareStatement4("rename_index", { from: it.from, to: it.to }));
|
26458
|
+
const jsonCreateDefaults = defaultsCreates.map(
|
26459
|
+
(defaultValue) => prepareStatement4("create_default", { default: defaultValue })
|
26460
|
+
);
|
26461
|
+
const jsonDropDefaults = defaultsDeletes.filter(tablesFilter("deleted")).map(
|
26462
|
+
(defaultValue) => prepareStatement4("drop_default", { default: defaultValue })
|
26463
|
+
);
|
26464
|
+
const jsonRenameDefaults = defaultsRenames.map(
|
26465
|
+
(it) => prepareStatement4("rename_default", { from: it.from, to: it.to })
|
26466
|
+
);
|
26349
26467
|
for (const idx of alters.filter((it) => it.entityType === "indexes")) {
|
26350
26468
|
const forWhere = !!idx.where && (idx.where.from !== null && idx.where.to !== null ? type !== "push" : true);
|
26351
26469
|
const forColumns = !!idx.columns && (idx.columns.from.length === idx.columns.to.length ? type !== "push" : true);
|
@@ -26378,13 +26496,7 @@ var init_diff5 = __esm({
|
|
26378
26496
|
isPK: ddl22.pks.one({ schema: it.schema, table: it.table, columns: [it.name] }) !== null
|
26379
26497
|
})
|
26380
26498
|
);
|
26381
|
-
const columnAlters = alters.filter((it) => it.entityType === "columns").
|
26382
|
-
var _a, _b;
|
26383
|
-
if (it.default && ((_a = it.default.from) == null ? void 0 : _a.value) === ((_b = it.default.to) == null ? void 0 : _b.value)) {
|
26384
|
-
delete it.default;
|
26385
|
-
}
|
26386
|
-
return it;
|
26387
|
-
}).filter((it) => Object.keys(it).length > 5);
|
26499
|
+
const columnAlters = alters.filter((it) => it.entityType === "columns").filter((it) => Object.keys(it).length > 5);
|
26388
26500
|
const columnsToRecreate = columnAlters.filter((it) => it.generated).filter((it) => {
|
26389
26501
|
var _a;
|
26390
26502
|
return !(((_a = it.generated) == null ? void 0 : _a.to) && it.generated.from && type === "push");
|
@@ -26502,6 +26614,7 @@ var init_diff5 = __esm({
|
|
26502
26614
|
jsonStatements.push(...jsonDeletedUniqueConstraints);
|
26503
26615
|
jsonStatements.push(...jsonDeletedCheckConstraints);
|
26504
26616
|
jsonStatements.push(...jsonDropReferences);
|
26617
|
+
jsonStatements.push(...jsonDropDefaults);
|
26505
26618
|
jsonStatements.push(...jsonDropIndexes);
|
26506
26619
|
jsonStatements.push(...jsonDropPrimaryKeys);
|
26507
26620
|
jsonStatements.push(...jsonAddColumnsStatemets);
|
@@ -26510,6 +26623,7 @@ var init_diff5 = __esm({
|
|
26510
26623
|
jsonStatements.push(...jsonAddPrimaryKeys);
|
26511
26624
|
jsonStatements.push(...jsonRenamePrimaryKeys);
|
26512
26625
|
jsonStatements.push(...jsonCreateReferences);
|
26626
|
+
jsonStatements.push(...jsonCreateDefaults);
|
26513
26627
|
jsonStatements.push(...jsonRenameFks);
|
26514
26628
|
jsonStatements.push(...jsonCreateIndexes);
|
26515
26629
|
jsonStatements.push(...jsonRenameIndex);
|
@@ -26520,6 +26634,7 @@ var init_diff5 = __esm({
|
|
26520
26634
|
jsonStatements.push(...jsonCreatedCheckConstraints);
|
26521
26635
|
jsonStatements.push(...jsonRenamedCheckConstraints);
|
26522
26636
|
jsonStatements.push(...jsonRenameUniqueConstraints);
|
26637
|
+
jsonStatements.push(...jsonRenameDefaults);
|
26523
26638
|
jsonStatements.push(...createViews);
|
26524
26639
|
jsonStatements.push(...dropSchemas);
|
26525
26640
|
const { groupedStatements, sqlStatements } = fromJson4(jsonStatements);
|
@@ -26545,7 +26660,7 @@ var init_diff5 = __esm({
|
|
26545
26660
|
});
|
26546
26661
|
|
26547
26662
|
// src/dialects/mssql/drizzle.ts
|
26548
|
-
var import_drizzle_orm5, import_mssql_core, upper3, defaultFromColumn4, fromDrizzleSchema5, prepareFromSchemaFiles5,
|
26663
|
+
var import_drizzle_orm5, import_mssql_core, upper3, defaultFromColumn4, fromDrizzleSchema5, prepareFromSchemaFiles5, fromExport;
|
26549
26664
|
var init_drizzle5 = __esm({
|
26550
26665
|
"src/dialects/mssql/drizzle.ts"() {
|
26551
26666
|
"use strict";
|
@@ -26607,7 +26722,8 @@ var init_drizzle5 = __esm({
|
|
26607
26722
|
checks: [],
|
26608
26723
|
views: [],
|
26609
26724
|
viewColumns: [],
|
26610
|
-
uniques: []
|
26725
|
+
uniques: [],
|
26726
|
+
defaults: []
|
26611
26727
|
};
|
26612
26728
|
for (const { table: table5, config } of tableConfigPairs) {
|
26613
26729
|
const {
|
@@ -26625,7 +26741,7 @@ var init_drizzle5 = __esm({
|
|
26625
26741
|
continue;
|
26626
26742
|
}
|
26627
26743
|
for (const column8 of columns) {
|
26628
|
-
const
|
26744
|
+
const columnName = getColumnCasing(column8, casing2);
|
26629
26745
|
const notNull = column8.notNull;
|
26630
26746
|
const sqlType = column8.getSQLType();
|
26631
26747
|
const identity = column8.identity;
|
@@ -26637,7 +26753,7 @@ var init_drizzle5 = __esm({
|
|
26637
26753
|
schema: schema5,
|
26638
26754
|
entityType: "columns",
|
26639
26755
|
table: tableName,
|
26640
|
-
name,
|
26756
|
+
name: columnName,
|
26641
26757
|
type: sqlType,
|
26642
26758
|
notNull: notNull && !column8.primary && !column8.generated && !identity,
|
26643
26759
|
// @ts-expect-error
|
@@ -26651,9 +26767,19 @@ var init_drizzle5 = __esm({
|
|
26651
26767
|
identity: identity ?? null,
|
26652
26768
|
isPK: column8.primary,
|
26653
26769
|
isUnique: column8.isUnique,
|
26654
|
-
uniqueName: column8.uniqueName ?? null
|
26655
|
-
default: defaultFromColumn4(column8, casing2)
|
26770
|
+
uniqueName: column8.uniqueName ?? null
|
26656
26771
|
});
|
26772
|
+
if (typeof column8.default !== "undefined") {
|
26773
|
+
result.defaults.push({
|
26774
|
+
entityType: "defaults",
|
26775
|
+
name: defaultNameForDefault(tableName, columnName),
|
26776
|
+
nameExplicit: false,
|
26777
|
+
schema: schema5,
|
26778
|
+
column: columnName,
|
26779
|
+
table: tableName,
|
26780
|
+
default: defaultFromColumn4(column8, casing2)
|
26781
|
+
});
|
26782
|
+
}
|
26657
26783
|
}
|
26658
26784
|
for (const pk of primaryKeys) {
|
26659
26785
|
const columnNames = pk.columns.map((c) => getColumnCasing(c, casing2));
|
@@ -26798,7 +26924,7 @@ var init_drizzle5 = __esm({
|
|
26798
26924
|
for (let i2 = 0; i2 < imports.length; i2++) {
|
26799
26925
|
const it = imports[i2];
|
26800
26926
|
const i0 = require(`${it}`);
|
26801
|
-
const prepared =
|
26927
|
+
const prepared = fromExport(i0);
|
26802
26928
|
tables.push(...prepared.tables);
|
26803
26929
|
schemas.push(...prepared.schemas);
|
26804
26930
|
views.push(...prepared.views);
|
@@ -26810,7 +26936,7 @@ var init_drizzle5 = __esm({
|
|
26810
26936
|
views
|
26811
26937
|
};
|
26812
26938
|
};
|
26813
|
-
|
26939
|
+
fromExport = (exports2) => {
|
26814
26940
|
const tables = [];
|
26815
26941
|
const schemas = [];
|
26816
26942
|
const views = [];
|
@@ -26932,6 +27058,8 @@ var init_generate_mssql = __esm({
|
|
26932
27058
|
// pks
|
26933
27059
|
resolver("foreign key", "dbo"),
|
26934
27060
|
// fks
|
27061
|
+
resolver("default", "dbo"),
|
27062
|
+
// fks
|
26935
27063
|
"default"
|
26936
27064
|
);
|
26937
27065
|
writeResult({
|
@@ -32254,8 +32382,8 @@ var init_get_search = __esm({
|
|
32254
32382
|
return parsedURL.search;
|
32255
32383
|
}
|
32256
32384
|
const lastOffset = parsedURL.href.length - 1;
|
32257
|
-
const
|
32258
|
-
return parsedURL.href[lastOffset -
|
32385
|
+
const hash2 = parsedURL.hash || (parsedURL.href[lastOffset] === "#" ? "#" : "");
|
32386
|
+
return parsedURL.href[lastOffset - hash2.length] === "?" ? "?" : "";
|
32259
32387
|
};
|
32260
32388
|
}
|
32261
32389
|
});
|
@@ -44543,9 +44671,9 @@ var require_dist_cjs36 = __commonJS({
|
|
44543
44671
|
});
|
44544
44672
|
}, "clearCredentialCache");
|
44545
44673
|
var hmac = /* @__PURE__ */ __name((ctor, secret, data) => {
|
44546
|
-
const
|
44547
|
-
|
44548
|
-
return
|
44674
|
+
const hash2 = new ctor(secret);
|
44675
|
+
hash2.update((0, import_util_utf8.toUint8Array)(data));
|
44676
|
+
return hash2.digest();
|
44549
44677
|
}, "hmac");
|
44550
44678
|
var getCanonicalHeaders = /* @__PURE__ */ __name(({ headers }, unsignableHeaders, signableHeaders) => {
|
44551
44679
|
const canonical = {};
|
@@ -44869,9 +44997,9 @@ var require_dist_cjs36 = __commonJS({
|
|
44869
44997
|
const { shortDate, longDate } = formatDate(signingDate);
|
44870
44998
|
const scope = createScope(shortDate, region, signingService ?? this.service);
|
44871
44999
|
const hashedPayload = await getPayloadHash({ headers: {}, body: payload }, this.sha256);
|
44872
|
-
const
|
44873
|
-
|
44874
|
-
const hashedHeaders = (0, import_util_hex_encoding.toHex)(await
|
45000
|
+
const hash2 = new this.sha256();
|
45001
|
+
hash2.update(headers);
|
45002
|
+
const hashedHeaders = (0, import_util_hex_encoding.toHex)(await hash2.digest());
|
44875
45003
|
const stringToSign = [
|
44876
45004
|
EVENT_ALGORITHM_IDENTIFIER,
|
44877
45005
|
longDate,
|
@@ -44904,9 +45032,9 @@ var require_dist_cjs36 = __commonJS({
|
|
44904
45032
|
this.validateResolvedCredentials(credentials2);
|
44905
45033
|
const region = signingRegion ?? await this.regionProvider();
|
44906
45034
|
const { shortDate } = formatDate(signingDate);
|
44907
|
-
const
|
44908
|
-
|
44909
|
-
return (0, import_util_hex_encoding.toHex)(await
|
45035
|
+
const hash2 = new this.sha256(await this.getSigningKey(credentials2, region, shortDate, signingService));
|
45036
|
+
hash2.update((0, import_util_utf84.toUint8Array)(stringToSign));
|
45037
|
+
return (0, import_util_hex_encoding.toHex)(await hash2.digest());
|
44910
45038
|
}
|
44911
45039
|
async signRequest(requestToSign, {
|
44912
45040
|
signingDate = /* @__PURE__ */ new Date(),
|
@@ -44950,9 +45078,9 @@ ${sortedHeaders.join(";")}
|
|
44950
45078
|
${payloadHash}`;
|
44951
45079
|
}
|
44952
45080
|
async createStringToSign(longDate, credentialScope, canonicalRequest) {
|
44953
|
-
const
|
44954
|
-
|
44955
|
-
const hashedRequest = await
|
45081
|
+
const hash2 = new this.sha256();
|
45082
|
+
hash2.update((0, import_util_utf84.toUint8Array)(canonicalRequest));
|
45083
|
+
const hashedRequest = await hash2.digest();
|
44956
45084
|
return `${ALGORITHM_IDENTIFIER}
|
44957
45085
|
${longDate}
|
44958
45086
|
${credentialScope}
|
@@ -44980,9 +45108,9 @@ ${(0, import_util_hex_encoding.toHex)(hashedRequest)}`;
|
|
44980
45108
|
}
|
44981
45109
|
async getSignature(longDate, credentialScope, keyPromise, canonicalRequest) {
|
44982
45110
|
const stringToSign = await this.createStringToSign(longDate, credentialScope, canonicalRequest);
|
44983
|
-
const
|
44984
|
-
|
44985
|
-
return (0, import_util_hex_encoding.toHex)(await
|
45111
|
+
const hash2 = new this.sha256(await keyPromise);
|
45112
|
+
hash2.update((0, import_util_utf84.toUint8Array)(stringToSign));
|
45113
|
+
return (0, import_util_hex_encoding.toHex)(await hash2.digest());
|
44986
45114
|
}
|
44987
45115
|
getSigningKey(credentials2, region, shortDate, service) {
|
44988
45116
|
return getSigningKey(this.sha256, credentials2, shortDate, region, service || this.service);
|
@@ -49619,9 +49747,9 @@ var require_dist_cjs46 = __commonJS({
|
|
49619
49747
|
}
|
49620
49748
|
});
|
49621
49749
|
|
49622
|
-
// ../node_modules/.pnpm/@aws-sdk+client-sso-oidc@3.583.0/node_modules/@aws-sdk/client-sso-oidc/dist-cjs/auth/httpAuthSchemeProvider.js
|
49750
|
+
// ../node_modules/.pnpm/@aws-sdk+client-sso-oidc@3.583.0_@aws-sdk+client-sts@3.583.0/node_modules/@aws-sdk/client-sso-oidc/dist-cjs/auth/httpAuthSchemeProvider.js
|
49623
49751
|
var require_httpAuthSchemeProvider3 = __commonJS({
|
49624
|
-
"../node_modules/.pnpm/@aws-sdk+client-sso-oidc@3.583.0/node_modules/@aws-sdk/client-sso-oidc/dist-cjs/auth/httpAuthSchemeProvider.js"(exports2) {
|
49752
|
+
"../node_modules/.pnpm/@aws-sdk+client-sso-oidc@3.583.0_@aws-sdk+client-sts@3.583.0/node_modules/@aws-sdk/client-sso-oidc/dist-cjs/auth/httpAuthSchemeProvider.js"(exports2) {
|
49625
49753
|
"use strict";
|
49626
49754
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
49627
49755
|
exports2.resolveHttpAuthSchemeConfig = exports2.defaultSSOOIDCHttpAuthSchemeProvider = exports2.defaultSSOOIDCHttpAuthSchemeParametersProvider = void 0;
|
@@ -49688,9 +49816,9 @@ var require_httpAuthSchemeProvider3 = __commonJS({
|
|
49688
49816
|
}
|
49689
49817
|
});
|
49690
49818
|
|
49691
|
-
// ../node_modules/.pnpm/@aws-sdk+client-sso-oidc@3.583.0/node_modules/@aws-sdk/client-sso-oidc/package.json
|
49819
|
+
// ../node_modules/.pnpm/@aws-sdk+client-sso-oidc@3.583.0_@aws-sdk+client-sts@3.583.0/node_modules/@aws-sdk/client-sso-oidc/package.json
|
49692
49820
|
var require_package4 = __commonJS({
|
49693
|
-
"../node_modules/.pnpm/@aws-sdk+client-sso-oidc@3.583.0/node_modules/@aws-sdk/client-sso-oidc/package.json"(exports2, module2) {
|
49821
|
+
"../node_modules/.pnpm/@aws-sdk+client-sso-oidc@3.583.0_@aws-sdk+client-sts@3.583.0/node_modules/@aws-sdk/client-sso-oidc/package.json"(exports2, module2) {
|
49694
49822
|
module2.exports = {
|
49695
49823
|
name: "@aws-sdk/client-sso-oidc",
|
49696
49824
|
description: "AWS SDK for JavaScript Sso Oidc Client for Node.js, Browser and React Native",
|
@@ -49794,9 +49922,9 @@ var require_package4 = __commonJS({
|
|
49794
49922
|
}
|
49795
49923
|
});
|
49796
49924
|
|
49797
|
-
// ../node_modules/.pnpm/@aws-sdk+client-sso-oidc@3.583.0/node_modules/@aws-sdk/client-sso-oidc/dist-cjs/endpoint/ruleset.js
|
49925
|
+
// ../node_modules/.pnpm/@aws-sdk+client-sso-oidc@3.583.0_@aws-sdk+client-sts@3.583.0/node_modules/@aws-sdk/client-sso-oidc/dist-cjs/endpoint/ruleset.js
|
49798
49926
|
var require_ruleset2 = __commonJS({
|
49799
|
-
"../node_modules/.pnpm/@aws-sdk+client-sso-oidc@3.583.0/node_modules/@aws-sdk/client-sso-oidc/dist-cjs/endpoint/ruleset.js"(exports2) {
|
49927
|
+
"../node_modules/.pnpm/@aws-sdk+client-sso-oidc@3.583.0_@aws-sdk+client-sts@3.583.0/node_modules/@aws-sdk/client-sso-oidc/dist-cjs/endpoint/ruleset.js"(exports2) {
|
49800
49928
|
"use strict";
|
49801
49929
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
49802
49930
|
exports2.ruleSet = void 0;
|
@@ -49829,9 +49957,9 @@ var require_ruleset2 = __commonJS({
|
|
49829
49957
|
}
|
49830
49958
|
});
|
49831
49959
|
|
49832
|
-
// ../node_modules/.pnpm/@aws-sdk+client-sso-oidc@3.583.0/node_modules/@aws-sdk/client-sso-oidc/dist-cjs/endpoint/endpointResolver.js
|
49960
|
+
// ../node_modules/.pnpm/@aws-sdk+client-sso-oidc@3.583.0_@aws-sdk+client-sts@3.583.0/node_modules/@aws-sdk/client-sso-oidc/dist-cjs/endpoint/endpointResolver.js
|
49833
49961
|
var require_endpointResolver2 = __commonJS({
|
49834
|
-
"../node_modules/.pnpm/@aws-sdk+client-sso-oidc@3.583.0/node_modules/@aws-sdk/client-sso-oidc/dist-cjs/endpoint/endpointResolver.js"(exports2) {
|
49962
|
+
"../node_modules/.pnpm/@aws-sdk+client-sso-oidc@3.583.0_@aws-sdk+client-sts@3.583.0/node_modules/@aws-sdk/client-sso-oidc/dist-cjs/endpoint/endpointResolver.js"(exports2) {
|
49835
49963
|
"use strict";
|
49836
49964
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
49837
49965
|
exports2.defaultEndpointResolver = void 0;
|
@@ -49849,9 +49977,9 @@ var require_endpointResolver2 = __commonJS({
|
|
49849
49977
|
}
|
49850
49978
|
});
|
49851
49979
|
|
49852
|
-
// ../node_modules/.pnpm/@aws-sdk+client-sso-oidc@3.583.0/node_modules/@aws-sdk/client-sso-oidc/dist-cjs/runtimeConfig.shared.js
|
49980
|
+
// ../node_modules/.pnpm/@aws-sdk+client-sso-oidc@3.583.0_@aws-sdk+client-sts@3.583.0/node_modules/@aws-sdk/client-sso-oidc/dist-cjs/runtimeConfig.shared.js
|
49853
49981
|
var require_runtimeConfig_shared2 = __commonJS({
|
49854
|
-
"../node_modules/.pnpm/@aws-sdk+client-sso-oidc@3.583.0/node_modules/@aws-sdk/client-sso-oidc/dist-cjs/runtimeConfig.shared.js"(exports2) {
|
49982
|
+
"../node_modules/.pnpm/@aws-sdk+client-sso-oidc@3.583.0_@aws-sdk+client-sts@3.583.0/node_modules/@aws-sdk/client-sso-oidc/dist-cjs/runtimeConfig.shared.js"(exports2) {
|
49855
49983
|
"use strict";
|
49856
49984
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
49857
49985
|
exports2.getRuntimeConfig = void 0;
|
@@ -49895,9 +50023,9 @@ var require_runtimeConfig_shared2 = __commonJS({
|
|
49895
50023
|
}
|
49896
50024
|
});
|
49897
50025
|
|
49898
|
-
// ../node_modules/.pnpm/@aws-sdk+client-sso-oidc@3.583.0/node_modules/@aws-sdk/client-sso-oidc/dist-cjs/runtimeConfig.js
|
50026
|
+
// ../node_modules/.pnpm/@aws-sdk+client-sso-oidc@3.583.0_@aws-sdk+client-sts@3.583.0/node_modules/@aws-sdk/client-sso-oidc/dist-cjs/runtimeConfig.js
|
49899
50027
|
var require_runtimeConfig2 = __commonJS({
|
49900
|
-
"../node_modules/.pnpm/@aws-sdk+client-sso-oidc@3.583.0/node_modules/@aws-sdk/client-sso-oidc/dist-cjs/runtimeConfig.js"(exports2) {
|
50028
|
+
"../node_modules/.pnpm/@aws-sdk+client-sso-oidc@3.583.0_@aws-sdk+client-sts@3.583.0/node_modules/@aws-sdk/client-sso-oidc/dist-cjs/runtimeConfig.js"(exports2) {
|
49901
50029
|
"use strict";
|
49902
50030
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
49903
50031
|
exports2.getRuntimeConfig = void 0;
|
@@ -49948,9 +50076,9 @@ var require_runtimeConfig2 = __commonJS({
|
|
49948
50076
|
}
|
49949
50077
|
});
|
49950
50078
|
|
49951
|
-
// ../node_modules/.pnpm/@aws-sdk+client-sso-oidc@3.583.0/node_modules/@aws-sdk/client-sso-oidc/dist-cjs/index.js
|
50079
|
+
// ../node_modules/.pnpm/@aws-sdk+client-sso-oidc@3.583.0_@aws-sdk+client-sts@3.583.0/node_modules/@aws-sdk/client-sso-oidc/dist-cjs/index.js
|
49952
50080
|
var require_dist_cjs47 = __commonJS({
|
49953
|
-
"../node_modules/.pnpm/@aws-sdk+client-sso-oidc@3.583.0/node_modules/@aws-sdk/client-sso-oidc/dist-cjs/index.js"(exports2, module2) {
|
50081
|
+
"../node_modules/.pnpm/@aws-sdk+client-sso-oidc@3.583.0_@aws-sdk+client-sts@3.583.0/node_modules/@aws-sdk/client-sso-oidc/dist-cjs/index.js"(exports2, module2) {
|
49954
50082
|
"use strict";
|
49955
50083
|
var __defProp3 = Object.defineProperty;
|
49956
50084
|
var __getOwnPropDesc3 = Object.getOwnPropertyDescriptor;
|
@@ -51296,9 +51424,9 @@ Reference: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.ht
|
|
51296
51424
|
}
|
51297
51425
|
});
|
51298
51426
|
|
51299
|
-
// ../node_modules/.pnpm/@aws-sdk+client-sts@3.583.
|
51427
|
+
// ../node_modules/.pnpm/@aws-sdk+client-sts@3.583.0/node_modules/@aws-sdk/client-sts/dist-cjs/auth/httpAuthSchemeProvider.js
|
51300
51428
|
var require_httpAuthSchemeProvider4 = __commonJS({
|
51301
|
-
"../node_modules/.pnpm/@aws-sdk+client-sts@3.583.
|
51429
|
+
"../node_modules/.pnpm/@aws-sdk+client-sts@3.583.0/node_modules/@aws-sdk/client-sts/dist-cjs/auth/httpAuthSchemeProvider.js"(exports2) {
|
51302
51430
|
"use strict";
|
51303
51431
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
51304
51432
|
exports2.resolveHttpAuthSchemeConfig = exports2.resolveStsAuthConfig = exports2.defaultSTSHttpAuthSchemeProvider = exports2.defaultSTSHttpAuthSchemeParametersProvider = void 0;
|
@@ -51368,9 +51496,9 @@ var require_httpAuthSchemeProvider4 = __commonJS({
|
|
51368
51496
|
}
|
51369
51497
|
});
|
51370
51498
|
|
51371
|
-
// ../node_modules/.pnpm/@aws-sdk+client-sts@3.583.
|
51499
|
+
// ../node_modules/.pnpm/@aws-sdk+client-sts@3.583.0/node_modules/@aws-sdk/client-sts/dist-cjs/endpoint/EndpointParameters.js
|
51372
51500
|
var require_EndpointParameters = __commonJS({
|
51373
|
-
"../node_modules/.pnpm/@aws-sdk+client-sts@3.583.
|
51501
|
+
"../node_modules/.pnpm/@aws-sdk+client-sts@3.583.0/node_modules/@aws-sdk/client-sts/dist-cjs/endpoint/EndpointParameters.js"(exports2) {
|
51374
51502
|
"use strict";
|
51375
51503
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
51376
51504
|
exports2.commonParams = exports2.resolveClientEndpointParameters = void 0;
|
@@ -51394,9 +51522,9 @@ var require_EndpointParameters = __commonJS({
|
|
51394
51522
|
}
|
51395
51523
|
});
|
51396
51524
|
|
51397
|
-
// ../node_modules/.pnpm/@aws-sdk+client-sts@3.583.
|
51525
|
+
// ../node_modules/.pnpm/@aws-sdk+client-sts@3.583.0/node_modules/@aws-sdk/client-sts/package.json
|
51398
51526
|
var require_package5 = __commonJS({
|
51399
|
-
"../node_modules/.pnpm/@aws-sdk+client-sts@3.583.
|
51527
|
+
"../node_modules/.pnpm/@aws-sdk+client-sts@3.583.0/node_modules/@aws-sdk/client-sts/package.json"(exports2, module2) {
|
51400
51528
|
module2.exports = {
|
51401
51529
|
name: "@aws-sdk/client-sts",
|
51402
51530
|
description: "AWS SDK for JavaScript Sts Client for Node.js, Browser and React Native",
|
@@ -51502,9 +51630,9 @@ var require_package5 = __commonJS({
|
|
51502
51630
|
}
|
51503
51631
|
});
|
51504
51632
|
|
51505
|
-
// ../node_modules/.pnpm/@aws-sdk+client-sts@3.583.
|
51633
|
+
// ../node_modules/.pnpm/@aws-sdk+client-sts@3.583.0/node_modules/@aws-sdk/client-sts/dist-cjs/endpoint/ruleset.js
|
51506
51634
|
var require_ruleset3 = __commonJS({
|
51507
|
-
"../node_modules/.pnpm/@aws-sdk+client-sts@3.583.
|
51635
|
+
"../node_modules/.pnpm/@aws-sdk+client-sts@3.583.0/node_modules/@aws-sdk/client-sts/dist-cjs/endpoint/ruleset.js"(exports2) {
|
51508
51636
|
"use strict";
|
51509
51637
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
51510
51638
|
exports2.ruleSet = void 0;
|
@@ -51549,9 +51677,9 @@ var require_ruleset3 = __commonJS({
|
|
51549
51677
|
}
|
51550
51678
|
});
|
51551
51679
|
|
51552
|
-
// ../node_modules/.pnpm/@aws-sdk+client-sts@3.583.
|
51680
|
+
// ../node_modules/.pnpm/@aws-sdk+client-sts@3.583.0/node_modules/@aws-sdk/client-sts/dist-cjs/endpoint/endpointResolver.js
|
51553
51681
|
var require_endpointResolver3 = __commonJS({
|
51554
|
-
"../node_modules/.pnpm/@aws-sdk+client-sts@3.583.
|
51682
|
+
"../node_modules/.pnpm/@aws-sdk+client-sts@3.583.0/node_modules/@aws-sdk/client-sts/dist-cjs/endpoint/endpointResolver.js"(exports2) {
|
51555
51683
|
"use strict";
|
51556
51684
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
51557
51685
|
exports2.defaultEndpointResolver = void 0;
|
@@ -51569,9 +51697,9 @@ var require_endpointResolver3 = __commonJS({
|
|
51569
51697
|
}
|
51570
51698
|
});
|
51571
51699
|
|
51572
|
-
// ../node_modules/.pnpm/@aws-sdk+client-sts@3.583.
|
51700
|
+
// ../node_modules/.pnpm/@aws-sdk+client-sts@3.583.0/node_modules/@aws-sdk/client-sts/dist-cjs/runtimeConfig.shared.js
|
51573
51701
|
var require_runtimeConfig_shared3 = __commonJS({
|
51574
|
-
"../node_modules/.pnpm/@aws-sdk+client-sts@3.583.
|
51702
|
+
"../node_modules/.pnpm/@aws-sdk+client-sts@3.583.0/node_modules/@aws-sdk/client-sts/dist-cjs/runtimeConfig.shared.js"(exports2) {
|
51575
51703
|
"use strict";
|
51576
51704
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
51577
51705
|
exports2.getRuntimeConfig = void 0;
|
@@ -51615,9 +51743,9 @@ var require_runtimeConfig_shared3 = __commonJS({
|
|
51615
51743
|
}
|
51616
51744
|
});
|
51617
51745
|
|
51618
|
-
// ../node_modules/.pnpm/@aws-sdk+client-sts@3.583.
|
51746
|
+
// ../node_modules/.pnpm/@aws-sdk+client-sts@3.583.0/node_modules/@aws-sdk/client-sts/dist-cjs/runtimeConfig.js
|
51619
51747
|
var require_runtimeConfig3 = __commonJS({
|
51620
|
-
"../node_modules/.pnpm/@aws-sdk+client-sts@3.583.
|
51748
|
+
"../node_modules/.pnpm/@aws-sdk+client-sts@3.583.0/node_modules/@aws-sdk/client-sts/dist-cjs/runtimeConfig.js"(exports2) {
|
51621
51749
|
"use strict";
|
51622
51750
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
51623
51751
|
exports2.getRuntimeConfig = void 0;
|
@@ -51681,9 +51809,9 @@ var require_runtimeConfig3 = __commonJS({
|
|
51681
51809
|
}
|
51682
51810
|
});
|
51683
51811
|
|
51684
|
-
// ../node_modules/.pnpm/@aws-sdk+client-sts@3.583.
|
51812
|
+
// ../node_modules/.pnpm/@aws-sdk+client-sts@3.583.0/node_modules/@aws-sdk/client-sts/dist-cjs/auth/httpAuthExtensionConfiguration.js
|
51685
51813
|
var require_httpAuthExtensionConfiguration = __commonJS({
|
51686
|
-
"../node_modules/.pnpm/@aws-sdk+client-sts@3.583.
|
51814
|
+
"../node_modules/.pnpm/@aws-sdk+client-sts@3.583.0/node_modules/@aws-sdk/client-sts/dist-cjs/auth/httpAuthExtensionConfiguration.js"(exports2) {
|
51687
51815
|
"use strict";
|
51688
51816
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
51689
51817
|
exports2.resolveHttpAuthRuntimeConfig = exports2.getHttpAuthExtensionConfiguration = void 0;
|
@@ -51729,9 +51857,9 @@ var require_httpAuthExtensionConfiguration = __commonJS({
|
|
51729
51857
|
}
|
51730
51858
|
});
|
51731
51859
|
|
51732
|
-
// ../node_modules/.pnpm/@aws-sdk+client-sts@3.583.
|
51860
|
+
// ../node_modules/.pnpm/@aws-sdk+client-sts@3.583.0/node_modules/@aws-sdk/client-sts/dist-cjs/runtimeExtensions.js
|
51733
51861
|
var require_runtimeExtensions = __commonJS({
|
51734
|
-
"../node_modules/.pnpm/@aws-sdk+client-sts@3.583.
|
51862
|
+
"../node_modules/.pnpm/@aws-sdk+client-sts@3.583.0/node_modules/@aws-sdk/client-sts/dist-cjs/runtimeExtensions.js"(exports2) {
|
51735
51863
|
"use strict";
|
51736
51864
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
51737
51865
|
exports2.resolveRuntimeExtensions = void 0;
|
@@ -51760,9 +51888,9 @@ var require_runtimeExtensions = __commonJS({
|
|
51760
51888
|
}
|
51761
51889
|
});
|
51762
51890
|
|
51763
|
-
// ../node_modules/.pnpm/@aws-sdk+client-sts@3.583.
|
51891
|
+
// ../node_modules/.pnpm/@aws-sdk+client-sts@3.583.0/node_modules/@aws-sdk/client-sts/dist-cjs/STSClient.js
|
51764
51892
|
var require_STSClient = __commonJS({
|
51765
|
-
"../node_modules/.pnpm/@aws-sdk+client-sts@3.583.
|
51893
|
+
"../node_modules/.pnpm/@aws-sdk+client-sts@3.583.0/node_modules/@aws-sdk/client-sts/dist-cjs/STSClient.js"(exports2) {
|
51766
51894
|
"use strict";
|
51767
51895
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
51768
51896
|
exports2.STSClient = exports2.__Client = void 0;
|
@@ -51824,9 +51952,9 @@ var require_STSClient = __commonJS({
|
|
51824
51952
|
}
|
51825
51953
|
});
|
51826
51954
|
|
51827
|
-
// ../node_modules/.pnpm/@aws-sdk+client-sts@3.583.
|
51955
|
+
// ../node_modules/.pnpm/@aws-sdk+client-sts@3.583.0/node_modules/@aws-sdk/client-sts/dist-cjs/index.js
|
51828
51956
|
var require_dist_cjs50 = __commonJS({
|
51829
|
-
"../node_modules/.pnpm/@aws-sdk+client-sts@3.583.
|
51957
|
+
"../node_modules/.pnpm/@aws-sdk+client-sts@3.583.0/node_modules/@aws-sdk/client-sts/dist-cjs/index.js"(exports2, module2) {
|
51830
51958
|
"use strict";
|
51831
51959
|
var __defProp3 = Object.defineProperty;
|
51832
51960
|
var __getOwnPropDesc3 = Object.getOwnPropertyDescriptor;
|
@@ -65089,9 +65217,9 @@ var require_conUtils_server = __commonJS({
|
|
65089
65217
|
if (platform.isWindows && !projectPath.startsWith("\\\\")) {
|
65090
65218
|
projectPath = "\\\\?\\" + projectPath;
|
65091
65219
|
}
|
65092
|
-
const
|
65220
|
+
const hash2 = (0, systemUtils_1.hashSHA1toHex)(projectPath);
|
65093
65221
|
const baseName = node_path_1.default.basename(projectPath);
|
65094
|
-
const dirName = baseName + "-" +
|
65222
|
+
const dirName = baseName + "-" + hash2;
|
65095
65223
|
return platform.searchConfigDir("projects", dirName);
|
65096
65224
|
}
|
65097
65225
|
exports2.serverUtils = {
|
@@ -67842,14 +67970,14 @@ var require_functions = __commonJS({
|
|
67842
67970
|
description: (_a = func.annotations[0]) == null ? void 0 : _a["@value"]
|
67843
67971
|
};
|
67844
67972
|
replaceNumberTypes(funcDef);
|
67845
|
-
const
|
67846
|
-
if (!seenFuncDefHashes.has(
|
67973
|
+
const hash2 = hashFuncDef(funcDef);
|
67974
|
+
if (!seenFuncDefHashes.has(hash2)) {
|
67847
67975
|
if (!functionMap.has(name)) {
|
67848
67976
|
functionMap.set(name, [funcDef]);
|
67849
67977
|
} else {
|
67850
67978
|
functionMap.get(name).push(funcDef);
|
67851
67979
|
}
|
67852
|
-
seenFuncDefHashes.add(
|
67980
|
+
seenFuncDefHashes.add(hash2);
|
67853
67981
|
}
|
67854
67982
|
}
|
67855
67983
|
return functionMap;
|
@@ -67974,14 +68102,14 @@ var require_operators = __commonJS({
|
|
67974
68102
|
annotations: void 0
|
67975
68103
|
};
|
67976
68104
|
(0, functions_1.replaceNumberTypes)(opDef);
|
67977
|
-
const
|
67978
|
-
if (!seenOpDefHashes.has(
|
68105
|
+
const hash2 = hashOpDef(opDef);
|
68106
|
+
if (!seenOpDefHashes.has(hash2)) {
|
67979
68107
|
if (!operators.has(name)) {
|
67980
68108
|
operators.set(name, [opDef]);
|
67981
68109
|
} else {
|
67982
68110
|
operators.get(name).push(opDef);
|
67983
68111
|
}
|
67984
|
-
seenOpDefHashes.add(
|
68112
|
+
seenOpDefHashes.add(hash2);
|
67985
68113
|
}
|
67986
68114
|
}
|
67987
68115
|
return operators;
|
@@ -69083,6 +69211,7 @@ var init_selector_ui = __esm({
|
|
69083
69211
|
init_source();
|
69084
69212
|
import_hanji6 = __toESM(require_hanji());
|
69085
69213
|
Select = class extends import_hanji6.Prompt {
|
69214
|
+
data;
|
69086
69215
|
constructor(items) {
|
69087
69216
|
super();
|
69088
69217
|
this.on("attach", (terminal) => terminal.toggleCursor("hide"));
|
@@ -69246,7 +69375,7 @@ var init_unescape = __esm({
|
|
69246
69375
|
});
|
69247
69376
|
|
69248
69377
|
// ../node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/index.js
|
69249
|
-
var import_brace_expansion, minimatch, starDotExtRE, starDotExtTest, starDotExtTestDot, starDotExtTestNocase, starDotExtTestNocaseDot, starDotStarRE, starDotStarTest, starDotStarTestDot, dotStarRE, dotStarTest, starRE, starTest, starTestDot, qmarksRE, qmarksTestNocase, qmarksTestNocaseDot, qmarksTestDot, qmarksTest, qmarksTestNoExt, qmarksTestNoExtDot, defaultPlatform, path2, sep, GLOBSTAR, plTypes, qmark, star, twoStarDot, twoStarNoDot, charSet, reSpecials, addPatternStartSet, filter, ext,
|
69378
|
+
var import_brace_expansion, minimatch, starDotExtRE, starDotExtTest, starDotExtTestDot, starDotExtTestNocase, starDotExtTestNocaseDot, starDotStarRE, starDotStarTest, starDotStarTestDot, dotStarRE, dotStarTest, starRE, starTest, starTestDot, qmarksRE, qmarksTestNocase, qmarksTestNocaseDot, qmarksTestDot, qmarksTest, qmarksTestNoExt, qmarksTestNoExtDot, defaultPlatform, path2, sep, GLOBSTAR, plTypes, qmark, star, twoStarDot, twoStarNoDot, charSet, reSpecials, addPatternStartSet, filter, ext, defaults3, braceExpand, MAX_PATTERN_LENGTH, assertValidPattern, makeRe, match, globUnescape, globMagic, regExpEscape, Minimatch;
|
69250
69379
|
var init_mjs = __esm({
|
69251
69380
|
"../node_modules/.pnpm/minimatch@7.4.6/node_modules/minimatch/dist/mjs/index.js"() {
|
69252
69381
|
import_brace_expansion = __toESM(require_brace_expansion(), 1);
|
@@ -69341,7 +69470,7 @@ var init_mjs = __esm({
|
|
69341
69470
|
filter = (pattern, options = {}) => (p) => minimatch(p, pattern, options);
|
69342
69471
|
minimatch.filter = filter;
|
69343
69472
|
ext = (a, b = {}) => Object.assign({}, a, b);
|
69344
|
-
|
69473
|
+
defaults3 = (def) => {
|
69345
69474
|
if (!def || typeof def !== "object" || !Object.keys(def).length) {
|
69346
69475
|
return minimatch;
|
69347
69476
|
}
|
@@ -69367,7 +69496,7 @@ var init_mjs = __esm({
|
|
69367
69496
|
GLOBSTAR
|
69368
69497
|
});
|
69369
69498
|
};
|
69370
|
-
minimatch.defaults =
|
69499
|
+
minimatch.defaults = defaults3;
|
69371
69500
|
braceExpand = (pattern, options = {}) => {
|
69372
69501
|
assertValidPattern(pattern);
|
69373
69502
|
if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
|
@@ -72120,6 +72249,14 @@ var init_introspect2 = __esm({
|
|
72120
72249
|
name: it.name,
|
72121
72250
|
values: [it.value]
|
72122
72251
|
};
|
72252
|
+
} else {
|
72253
|
+
acc[it.oid].values.push(it.value);
|
72254
|
+
}
|
72255
|
+
return acc;
|
72256
|
+
}, {});
|
72257
|
+
const groupedArrEnums = enumsList.reduce((acc, it) => {
|
72258
|
+
if (!(it.arrayTypeId in acc)) {
|
72259
|
+
const schemaName = filteredNamespaces.find((sch) => sch.oid === it.schemaId).name;
|
72123
72260
|
acc[it.arrayTypeId] = {
|
72124
72261
|
oid: it.oid,
|
72125
72262
|
schema: schemaName,
|
@@ -72127,7 +72264,6 @@ var init_introspect2 = __esm({
|
|
72127
72264
|
values: [it.value]
|
72128
72265
|
};
|
72129
72266
|
} else {
|
72130
|
-
acc[it.oid].values.push(it.value);
|
72131
72267
|
acc[it.arrayTypeId].values.push(it.value);
|
72132
72268
|
}
|
72133
72269
|
return acc;
|
@@ -72200,15 +72336,14 @@ var init_introspect2 = __esm({
|
|
72200
72336
|
if (expr) {
|
72201
72337
|
const table5 = tablesList.find((it) => it.oid === column8.tableId);
|
72202
72338
|
const schema4 = namespaces.find((it) => it.oid === table5.schemaId);
|
72203
|
-
const
|
72204
|
-
const isSerial = expr.expression === expectedExpression;
|
72339
|
+
const isSerial = isSerialExpression(expr.expression, schema4.name);
|
72205
72340
|
column8.type = isSerial ? type === "bigint" ? "bigserial" : type === "integer" ? "serial" : "smallserial" : type;
|
72206
72341
|
}
|
72207
72342
|
}
|
72208
72343
|
for (const column8 of columnsList.filter((x2) => x2.kind === "r")) {
|
72209
72344
|
const table5 = tablesList.find((it) => it.oid === column8.tableId);
|
72210
72345
|
const schema4 = namespaces.find((it) => it.oid === table5.schemaId);
|
72211
|
-
const enumType2 = column8.typeId in groupedEnums ? groupedEnums[column8.typeId] : null;
|
72346
|
+
const enumType2 = column8.typeId in groupedEnums ? groupedEnums[column8.typeId] : column8.typeId in groupedArrEnums ? groupedArrEnums[column8.typeId] : null;
|
72212
72347
|
let columnTypeMapped = enumType2 ? enumType2.name : column8.type.replace("[]", "");
|
72213
72348
|
columnTypeMapped = trimChar(columnTypeMapped, '"');
|
72214
72349
|
if (columnTypeMapped.startsWith("numeric(")) {
|
@@ -72255,7 +72390,7 @@ ${JSON.stringify(column8.metadata)}`
|
|
72255
72390
|
unique: !!unique,
|
72256
72391
|
uniqueName: unique ? unique.name : null,
|
72257
72392
|
uniqueNullsNotDistinct: (unique == null ? void 0 : unique.definition.includes("NULLS NOT DISTINCT")) ?? false,
|
72258
|
-
notNull: column8.notNull
|
72393
|
+
notNull: column8.notNull,
|
72259
72394
|
pk: pk !== null,
|
72260
72395
|
pkName: pk !== null ? pk.name : null,
|
72261
72396
|
generated: column8.generatedType === "s" ? { type: "stored", as: metadata.expression } : null,
|
@@ -72372,6 +72507,8 @@ ${JSON.stringify(column8.metadata)}`
|
|
72372
72507
|
`);
|
72373
72508
|
for (const idx of idxs) {
|
72374
72509
|
const { metadata } = idx;
|
72510
|
+
const forUnique = metadata.isUnique && constraintsList.some((x2) => x2.type === "u" && x2.indexId === idx.oid);
|
72511
|
+
const forPK = metadata.isPrimary && constraintsList.some((x2) => x2.type === "p" && x2.indexId === idx.oid);
|
72375
72512
|
const opclasses = metadata.opclassIds.map((it) => opsById[it]);
|
72376
72513
|
const expr = splitExpressions(metadata.expression);
|
72377
72514
|
const schema4 = namespaces.find((it) => it.oid === idx.schemaId);
|
@@ -72443,7 +72580,8 @@ ${JSON.stringify(column8.metadata)}`
|
|
72443
72580
|
where: idx.metadata.where,
|
72444
72581
|
columns: columns2,
|
72445
72582
|
concurrently: false,
|
72446
|
-
|
72583
|
+
forUnique,
|
72584
|
+
forPK
|
72447
72585
|
});
|
72448
72586
|
}
|
72449
72587
|
progressCallback("columns", columnsCount, "fetching");
|
@@ -72453,7 +72591,7 @@ ${JSON.stringify(column8.metadata)}`
|
|
72453
72591
|
for (const it of columnsList.filter((x2) => x2.kind === "m" || x2.kind === "v")) {
|
72454
72592
|
const view5 = viewsList.find((x2) => x2.oid === it.tableId);
|
72455
72593
|
const schema4 = namespaces.find((x2) => x2.oid === view5.schemaId);
|
72456
|
-
const enumType2 = it.typeId in groupedEnums ? groupedEnums[it.typeId] : null;
|
72594
|
+
const enumType2 = it.typeId in groupedEnums ? groupedEnums[it.typeId] : it.typeId in groupedArrEnums ? groupedArrEnums[it.typeId] : null;
|
72457
72595
|
let columnTypeMapped = enumType2 ? enumType2.name : it.type.replace("[]", "");
|
72458
72596
|
columnTypeMapped = trimChar(columnTypeMapped, '"');
|
72459
72597
|
if (columnTypeMapped.startsWith("numeric(")) {
|
@@ -72558,7 +72696,7 @@ ${JSON.stringify(column8.metadata)}`
|
|
72558
72696
|
}) => {
|
72559
72697
|
const res = await fromDatabase2(db2, tableFilter, schemaFilters, entities, progressCallback);
|
72560
72698
|
res.schemas = res.schemas.filter((it) => it.name !== "public");
|
72561
|
-
res.indexes = res.indexes.filter((it) => !it.
|
72699
|
+
res.indexes = res.indexes.filter((it) => !it.forPK && !it.forUnique);
|
72562
72700
|
return res;
|
72563
72701
|
};
|
72564
72702
|
}
|
@@ -72568,9 +72706,9 @@ ${JSON.stringify(column8.metadata)}`
|
|
72568
72706
|
var pull_postgres_exports = {};
|
72569
72707
|
__export(pull_postgres_exports, {
|
72570
72708
|
handle: () => handle7,
|
72571
|
-
|
72709
|
+
introspect: () => introspect
|
72572
72710
|
});
|
72573
|
-
var import_fs9, import_hanji8, import_path6, handle7,
|
72711
|
+
var import_fs9, import_hanji8, import_path6, handle7, introspect;
|
72574
72712
|
var init_pull_postgres = __esm({
|
72575
72713
|
"src/cli/commands/pull-postgres.ts"() {
|
72576
72714
|
"use strict";
|
@@ -72581,7 +72719,6 @@ var init_pull_postgres = __esm({
|
|
72581
72719
|
import_path6 = require("path");
|
72582
72720
|
init_snapshot3();
|
72583
72721
|
init_global();
|
72584
|
-
init_mocks();
|
72585
72722
|
init_ddl3();
|
72586
72723
|
init_diff();
|
72587
72724
|
init_introspect2();
|
@@ -72589,7 +72726,6 @@ var init_pull_postgres = __esm({
|
|
72589
72726
|
init_utils_node();
|
72590
72727
|
init_prompts();
|
72591
72728
|
init_views();
|
72592
|
-
init_views();
|
72593
72729
|
init_generate_common();
|
72594
72730
|
init_pull_common();
|
72595
72731
|
handle7 = async (casing2, out, breakpoints, credentials2, tablesFilter, schemasFilters, prefix2, entities) => {
|
@@ -72637,17 +72773,11 @@ var init_pull_postgres = __esm({
|
|
72637
72773
|
resolver("table"),
|
72638
72774
|
resolver("column"),
|
72639
72775
|
resolver("view"),
|
72640
|
-
|
72641
|
-
|
72642
|
-
|
72643
|
-
|
72644
|
-
|
72645
|
-
mockResolver(blanks),
|
72646
|
-
// checks
|
72647
|
-
mockResolver(blanks),
|
72648
|
-
// pks
|
72649
|
-
mockResolver(blanks),
|
72650
|
-
// fks
|
72776
|
+
resolver("unique"),
|
72777
|
+
resolver("index"),
|
72778
|
+
resolver("check"),
|
72779
|
+
resolver("primary key"),
|
72780
|
+
resolver("foreign key"),
|
72651
72781
|
"push"
|
72652
72782
|
);
|
72653
72783
|
writeResult({
|
@@ -72681,7 +72811,7 @@ var init_pull_postgres = __esm({
|
|
72681
72811
|
);
|
72682
72812
|
process.exit(0);
|
72683
72813
|
};
|
72684
|
-
|
72814
|
+
introspect = async (db2, filters, schemaFilters, entities, progress) => {
|
72685
72815
|
const matchers = filters.map((it) => {
|
72686
72816
|
return new Minimatch(it);
|
72687
72817
|
});
|
@@ -72703,17 +72833,8 @@ var init_pull_postgres = __esm({
|
|
72703
72833
|
}
|
72704
72834
|
return false;
|
72705
72835
|
};
|
72706
|
-
const
|
72707
|
-
|
72708
|
-
"Pulling schema from database..."
|
72709
|
-
);
|
72710
|
-
const schemaFilter = (it) => {
|
72711
|
-
return schemaFilters.some((x2) => x2 === it);
|
72712
|
-
};
|
72713
|
-
const schema4 = await (0, import_hanji8.renderWithTask)(
|
72714
|
-
progress,
|
72715
|
-
fromDatabaseForDrizzle2(db2, filter2, schemaFilter, entities)
|
72716
|
-
);
|
72836
|
+
const schemaFilter = typeof schemaFilters === "function" ? schemaFilters : (it) => schemaFilters.some((x2) => x2 === it);
|
72837
|
+
const schema4 = await (0, import_hanji8.renderWithTask)(progress, fromDatabaseForDrizzle2(db2, filter2, schemaFilter, entities));
|
72717
72838
|
return { schema: schema4 };
|
72718
72839
|
};
|
72719
72840
|
}
|
@@ -72735,14 +72856,13 @@ var init_push_postgres = __esm({
|
|
72735
72856
|
init_diff();
|
72736
72857
|
init_drizzle();
|
72737
72858
|
init_serializer();
|
72738
|
-
init_mocks();
|
72739
72859
|
init_prompts();
|
72740
72860
|
init_selector_ui();
|
72741
72861
|
init_outputs();
|
72742
72862
|
init_views();
|
72743
72863
|
handle8 = async (schemaPath, verbose, strict, credentials2, tablesFilter, schemasFilter, entities, force, casing2) => {
|
72744
72864
|
const { preparePostgresDB: preparePostgresDB2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
|
72745
|
-
const {
|
72865
|
+
const { introspect: pgPushIntrospect } = await Promise.resolve().then(() => (init_pull_postgres(), pull_postgres_exports));
|
72746
72866
|
const db2 = await preparePostgresDB2(credentials2);
|
72747
72867
|
const filenames = prepareFilenames(schemaPath);
|
72748
72868
|
const res = await prepareFromSchemaFiles(filenames);
|
@@ -72754,7 +72874,8 @@ var init_push_postgres = __esm({
|
|
72754
72874
|
console.log(errors.map((it) => schemaError(it)).join("\n"));
|
72755
72875
|
process.exit(1);
|
72756
72876
|
}
|
72757
|
-
const
|
72877
|
+
const progress = new ProgressView("Pulling schema from database...", "Pulling schema from database...");
|
72878
|
+
const { schema: schemaFrom } = await pgPushIntrospect(db2, tablesFilter, schemasFilter, entities, progress);
|
72758
72879
|
const { ddl: ddl1, errors: errors1 } = interimToDDL3(schemaFrom);
|
72759
72880
|
const { ddl: ddl22, errors: errors2 } = interimToDDL3(schemaTo);
|
72760
72881
|
if (errors1.length > 0) {
|
@@ -72773,16 +72894,11 @@ var init_push_postgres = __esm({
|
|
72773
72894
|
resolver("table"),
|
72774
72895
|
resolver("column"),
|
72775
72896
|
resolver("view"),
|
72776
|
-
|
72777
|
-
|
72778
|
-
|
72779
|
-
|
72780
|
-
|
72781
|
-
// checks
|
72782
|
-
mockResolver(blanks),
|
72783
|
-
// pks
|
72784
|
-
mockResolver(blanks),
|
72785
|
-
// fks
|
72897
|
+
resolver("unique"),
|
72898
|
+
resolver("index"),
|
72899
|
+
resolver("check"),
|
72900
|
+
resolver("primary key"),
|
72901
|
+
resolver("foreign key"),
|
72786
72902
|
"push"
|
72787
72903
|
);
|
72788
72904
|
if (sqlStatements.length === 0) {
|
@@ -77024,14 +77140,14 @@ var cors;
|
|
77024
77140
|
var init_cors = __esm({
|
77025
77141
|
"../node_modules/.pnpm/hono@4.5.0/node_modules/hono/dist/middleware/cors/index.js"() {
|
77026
77142
|
cors = (options) => {
|
77027
|
-
const
|
77143
|
+
const defaults4 = {
|
77028
77144
|
origin: "*",
|
77029
77145
|
allowMethods: ["GET", "HEAD", "PUT", "POST", "DELETE", "PATCH"],
|
77030
77146
|
allowHeaders: [],
|
77031
77147
|
exposeHeaders: []
|
77032
77148
|
};
|
77033
77149
|
const opts = {
|
77034
|
-
...
|
77150
|
+
...defaults4,
|
77035
77151
|
...options
|
77036
77152
|
};
|
77037
77153
|
const findAllowOrigin = ((optsOrigin) => {
|
@@ -78859,7 +78975,7 @@ var require_parse = __commonJS2({
|
|
78859
78975
|
var META = "|&;()<> \\t";
|
78860
78976
|
var SINGLE_QUOTE = '"((\\\\"|[^"])*?)"';
|
78861
78977
|
var DOUBLE_QUOTE = "'((\\\\'|[^'])*?)'";
|
78862
|
-
var
|
78978
|
+
var hash2 = /^#$/;
|
78863
78979
|
var SQ = "'";
|
78864
78980
|
var DQ = '"';
|
78865
78981
|
var DS = "$";
|
@@ -78989,7 +79105,7 @@ var require_parse = __commonJS2({
|
|
78989
79105
|
quote = c;
|
78990
79106
|
} else if (controlRE.test(c)) {
|
78991
79107
|
return { op: s2 };
|
78992
|
-
} else if (
|
79108
|
+
} else if (hash2.test(c)) {
|
78993
79109
|
commented = true;
|
78994
79110
|
var commentObj = { comment: string2.slice(match2.index + i22 + 1) };
|
78995
79111
|
if (out.length) {
|
@@ -80267,7 +80383,6 @@ var updateToV8 = (it) => {
|
|
80267
80383
|
table: table5.name,
|
80268
80384
|
name: idx.name,
|
80269
80385
|
columns,
|
80270
|
-
isPrimary: false,
|
80271
80386
|
isUnique: idx.isUnique,
|
80272
80387
|
method: idx.method,
|
80273
80388
|
concurrently: idx.concurrently,
|
@@ -81191,11 +81306,11 @@ var flattenDatabaseCredentials = (config) => {
|
|
81191
81306
|
};
|
81192
81307
|
var flattenPull = (config) => {
|
81193
81308
|
if ("dbCredentials" in config) {
|
81194
|
-
const { dbCredentials, introspect, ...rest } = config;
|
81309
|
+
const { dbCredentials, introspect: introspect2, ...rest } = config;
|
81195
81310
|
return {
|
81196
81311
|
...rest,
|
81197
81312
|
...dbCredentials,
|
81198
|
-
casing:
|
81313
|
+
casing: introspect2 == null ? void 0 : introspect2.casing
|
81199
81314
|
};
|
81200
81315
|
}
|
81201
81316
|
return config;
|
@@ -82445,7 +82560,7 @@ init_utils4();
|
|
82445
82560
|
var version2 = async () => {
|
82446
82561
|
const { npmVersion } = await ormCoreVersions();
|
82447
82562
|
const ormVersion = npmVersion ? `drizzle-orm: v${npmVersion}` : "";
|
82448
|
-
const envVersion = "0.31.1-
|
82563
|
+
const envVersion = "0.31.1-a4825a4";
|
82449
82564
|
const kitVersion = envVersion ? `v${envVersion}` : "--";
|
82450
82565
|
const versions = `drizzle-kit: ${kitVersion}
|
82451
82566
|
${ormVersion}`;
|