drizzle-kit 0.16.9-fcedf83 → 0.17.0-5763371
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/index.js +1874 -765
- package/package.json +12 -7
- package/utils.js +433 -112
package/utils.js
CHANGED
|
@@ -6669,7 +6669,7 @@ __export(utils_exports, {
|
|
|
6669
6669
|
mapValues: () => mapValues,
|
|
6670
6670
|
prepareMigrationFolder: () => prepareMigrationFolder,
|
|
6671
6671
|
prepareMigrationMeta: () => prepareMigrationMeta,
|
|
6672
|
-
prepareOutFolder: () =>
|
|
6672
|
+
prepareOutFolder: () => prepareOutFolder2,
|
|
6673
6673
|
schemaRenameKey: () => schemaRenameKey,
|
|
6674
6674
|
snapshotsPriorV4: () => snapshotsPriorV4,
|
|
6675
6675
|
statementsForDiffs: () => statementsForDiffs,
|
|
@@ -7169,7 +7169,7 @@ var info = (msg, greyMsg = "") => {
|
|
|
7169
7169
|
var originUUID = "00000000-0000-0000-0000-000000000000";
|
|
7170
7170
|
var snapshotVersion = "5";
|
|
7171
7171
|
|
|
7172
|
-
// node_modules/.pnpm/zod@3.20.
|
|
7172
|
+
// node_modules/.pnpm/zod@3.20.6/node_modules/zod/lib/index.mjs
|
|
7173
7173
|
var util;
|
|
7174
7174
|
(function(util2) {
|
|
7175
7175
|
util2.assertEqual = (val) => val;
|
|
@@ -7584,7 +7584,7 @@ var OK = (value) => ({ status: "valid", value });
|
|
|
7584
7584
|
var isAborted = (x) => x.status === "aborted";
|
|
7585
7585
|
var isDirty = (x) => x.status === "dirty";
|
|
7586
7586
|
var isValid = (x) => x.status === "valid";
|
|
7587
|
-
var isAsync = (x) => typeof Promise !==
|
|
7587
|
+
var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
|
7588
7588
|
var errorUtil;
|
|
7589
7589
|
(function(errorUtil2) {
|
|
7590
7590
|
errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
@@ -7800,28 +7800,29 @@ var ZodType = class {
|
|
|
7800
7800
|
return this._refinement(refinement);
|
|
7801
7801
|
}
|
|
7802
7802
|
optional() {
|
|
7803
|
-
return ZodOptional.create(this);
|
|
7803
|
+
return ZodOptional.create(this, this._def);
|
|
7804
7804
|
}
|
|
7805
7805
|
nullable() {
|
|
7806
|
-
return ZodNullable.create(this);
|
|
7806
|
+
return ZodNullable.create(this, this._def);
|
|
7807
7807
|
}
|
|
7808
7808
|
nullish() {
|
|
7809
|
-
return this.
|
|
7809
|
+
return this.nullable().optional();
|
|
7810
7810
|
}
|
|
7811
7811
|
array() {
|
|
7812
|
-
return ZodArray.create(this);
|
|
7812
|
+
return ZodArray.create(this, this._def);
|
|
7813
7813
|
}
|
|
7814
7814
|
promise() {
|
|
7815
|
-
return ZodPromise.create(this);
|
|
7815
|
+
return ZodPromise.create(this, this._def);
|
|
7816
7816
|
}
|
|
7817
7817
|
or(option) {
|
|
7818
|
-
return ZodUnion.create([this, option]);
|
|
7818
|
+
return ZodUnion.create([this, option], this._def);
|
|
7819
7819
|
}
|
|
7820
7820
|
and(incoming) {
|
|
7821
|
-
return ZodIntersection.create(this, incoming);
|
|
7821
|
+
return ZodIntersection.create(this, incoming, this._def);
|
|
7822
7822
|
}
|
|
7823
7823
|
transform(transform) {
|
|
7824
7824
|
return new ZodEffects({
|
|
7825
|
+
...processCreateParams(this._def),
|
|
7825
7826
|
schema: this,
|
|
7826
7827
|
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
|
7827
7828
|
effect: { type: "transform", transform }
|
|
@@ -7830,6 +7831,7 @@ var ZodType = class {
|
|
|
7830
7831
|
default(def) {
|
|
7831
7832
|
const defaultValueFunc = typeof def === "function" ? def : () => def;
|
|
7832
7833
|
return new ZodDefault({
|
|
7834
|
+
...processCreateParams(this._def),
|
|
7833
7835
|
innerType: this,
|
|
7834
7836
|
defaultValue: defaultValueFunc,
|
|
7835
7837
|
typeName: ZodFirstPartyTypeKind.ZodDefault
|
|
@@ -7839,14 +7841,15 @@ var ZodType = class {
|
|
|
7839
7841
|
return new ZodBranded({
|
|
7840
7842
|
typeName: ZodFirstPartyTypeKind.ZodBranded,
|
|
7841
7843
|
type: this,
|
|
7842
|
-
...processCreateParams(
|
|
7844
|
+
...processCreateParams(this._def)
|
|
7843
7845
|
});
|
|
7844
7846
|
}
|
|
7845
7847
|
catch(def) {
|
|
7846
|
-
const
|
|
7848
|
+
const catchValueFunc = typeof def === "function" ? def : () => def;
|
|
7847
7849
|
return new ZodCatch({
|
|
7850
|
+
...processCreateParams(this._def),
|
|
7848
7851
|
innerType: this,
|
|
7849
|
-
|
|
7852
|
+
catchValue: catchValueFunc,
|
|
7850
7853
|
typeName: ZodFirstPartyTypeKind.ZodCatch
|
|
7851
7854
|
});
|
|
7852
7855
|
}
|
|
@@ -7868,24 +7871,25 @@ var ZodType = class {
|
|
|
7868
7871
|
}
|
|
7869
7872
|
};
|
|
7870
7873
|
var cuidRegex = /^c[^\s-]{8,}$/i;
|
|
7874
|
+
var cuid2Regex = /^[a-z][a-z0-9]*$/;
|
|
7871
7875
|
var uuidRegex = /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i;
|
|
7872
|
-
var emailRegex = /^(([^<>()[\]
|
|
7876
|
+
var emailRegex = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|([^-]([a-zA-Z0-9-]*\.)+[a-zA-Z]{2,}))$/;
|
|
7873
7877
|
var datetimeRegex = (args) => {
|
|
7874
7878
|
if (args.precision) {
|
|
7875
7879
|
if (args.offset) {
|
|
7876
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}
|
|
7880
|
+
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
|
|
7877
7881
|
} else {
|
|
7878
7882
|
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`);
|
|
7879
7883
|
}
|
|
7880
7884
|
} else if (args.precision === 0) {
|
|
7881
7885
|
if (args.offset) {
|
|
7882
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}
|
|
7886
|
+
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
|
|
7883
7887
|
} else {
|
|
7884
7888
|
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
|
|
7885
7889
|
}
|
|
7886
7890
|
} else {
|
|
7887
7891
|
if (args.offset) {
|
|
7888
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}
|
|
7892
|
+
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
|
|
7889
7893
|
} else {
|
|
7890
7894
|
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
|
|
7891
7895
|
}
|
|
@@ -8007,6 +8011,16 @@ var ZodString = class extends ZodType {
|
|
|
8007
8011
|
});
|
|
8008
8012
|
status.dirty();
|
|
8009
8013
|
}
|
|
8014
|
+
} else if (check.kind === "cuid2") {
|
|
8015
|
+
if (!cuid2Regex.test(input.data)) {
|
|
8016
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
8017
|
+
addIssueToContext(ctx, {
|
|
8018
|
+
validation: "cuid2",
|
|
8019
|
+
code: ZodIssueCode.invalid_string,
|
|
8020
|
+
message: check.message
|
|
8021
|
+
});
|
|
8022
|
+
status.dirty();
|
|
8023
|
+
}
|
|
8010
8024
|
} else if (check.kind === "url") {
|
|
8011
8025
|
try {
|
|
8012
8026
|
new URL(input.data);
|
|
@@ -8088,6 +8102,9 @@ var ZodString = class extends ZodType {
|
|
|
8088
8102
|
cuid(message) {
|
|
8089
8103
|
return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
|
|
8090
8104
|
}
|
|
8105
|
+
cuid2(message) {
|
|
8106
|
+
return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
|
|
8107
|
+
}
|
|
8091
8108
|
datetime(options) {
|
|
8092
8109
|
var _a;
|
|
8093
8110
|
if (typeof options === "string") {
|
|
@@ -8162,6 +8179,9 @@ var ZodString = class extends ZodType {
|
|
|
8162
8179
|
get isCUID() {
|
|
8163
8180
|
return !!this._def.checks.find((ch) => ch.kind === "cuid");
|
|
8164
8181
|
}
|
|
8182
|
+
get isCUID2() {
|
|
8183
|
+
return !!this._def.checks.find((ch) => ch.kind === "cuid2");
|
|
8184
|
+
}
|
|
8165
8185
|
get minLength() {
|
|
8166
8186
|
let min = null;
|
|
8167
8187
|
for (const ch of this._def.checks) {
|
|
@@ -8392,7 +8412,22 @@ var ZodNumber = class extends ZodType {
|
|
|
8392
8412
|
return max;
|
|
8393
8413
|
}
|
|
8394
8414
|
get isInt() {
|
|
8395
|
-
return !!this._def.checks.find((ch) => ch.kind === "int");
|
|
8415
|
+
return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
|
|
8416
|
+
}
|
|
8417
|
+
get isFinite() {
|
|
8418
|
+
let max = null, min = null;
|
|
8419
|
+
for (const ch of this._def.checks) {
|
|
8420
|
+
if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
|
|
8421
|
+
return true;
|
|
8422
|
+
} else if (ch.kind === "min") {
|
|
8423
|
+
if (min === null || ch.value > min)
|
|
8424
|
+
min = ch.value;
|
|
8425
|
+
} else if (ch.kind === "max") {
|
|
8426
|
+
if (max === null || ch.value < max)
|
|
8427
|
+
max = ch.value;
|
|
8428
|
+
}
|
|
8429
|
+
}
|
|
8430
|
+
return Number.isFinite(min) && Number.isFinite(max);
|
|
8396
8431
|
}
|
|
8397
8432
|
};
|
|
8398
8433
|
ZodNumber.create = (params) => {
|
|
@@ -8749,13 +8784,13 @@ var ZodArray = class extends ZodType {
|
|
|
8749
8784
|
}
|
|
8750
8785
|
}
|
|
8751
8786
|
if (ctx.common.async) {
|
|
8752
|
-
return Promise.all(ctx.data.map((item, i) => {
|
|
8787
|
+
return Promise.all([...ctx.data].map((item, i) => {
|
|
8753
8788
|
return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
|
|
8754
8789
|
})).then((result2) => {
|
|
8755
8790
|
return ParseStatus.mergeArray(status, result2);
|
|
8756
8791
|
});
|
|
8757
8792
|
}
|
|
8758
|
-
const result = ctx.data.map((item, i) => {
|
|
8793
|
+
const result = [...ctx.data].map((item, i) => {
|
|
8759
8794
|
return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
|
|
8760
8795
|
});
|
|
8761
8796
|
return ParseStatus.mergeArray(status, result);
|
|
@@ -8804,15 +8839,6 @@ var objectUtil;
|
|
|
8804
8839
|
};
|
|
8805
8840
|
};
|
|
8806
8841
|
})(objectUtil || (objectUtil = {}));
|
|
8807
|
-
var AugmentFactory = (def) => (augmentation) => {
|
|
8808
|
-
return new ZodObject({
|
|
8809
|
-
...def,
|
|
8810
|
-
shape: () => ({
|
|
8811
|
-
...def.shape(),
|
|
8812
|
-
...augmentation
|
|
8813
|
-
})
|
|
8814
|
-
});
|
|
8815
|
-
};
|
|
8816
8842
|
function deepPartialify(schema3) {
|
|
8817
8843
|
if (schema3 instanceof ZodObject) {
|
|
8818
8844
|
const newShape = {};
|
|
@@ -8841,8 +8867,7 @@ var ZodObject = class extends ZodType {
|
|
|
8841
8867
|
super(...arguments);
|
|
8842
8868
|
this._cached = null;
|
|
8843
8869
|
this.nonstrict = this.passthrough;
|
|
8844
|
-
this.augment =
|
|
8845
|
-
this.extend = AugmentFactory(this._def);
|
|
8870
|
+
this.augment = this.extend;
|
|
8846
8871
|
}
|
|
8847
8872
|
_getCached() {
|
|
8848
8873
|
if (this._cached !== null)
|
|
@@ -8971,8 +8996,14 @@ var ZodObject = class extends ZodType {
|
|
|
8971
8996
|
unknownKeys: "passthrough"
|
|
8972
8997
|
});
|
|
8973
8998
|
}
|
|
8974
|
-
|
|
8975
|
-
return
|
|
8999
|
+
extend(augmentation) {
|
|
9000
|
+
return new ZodObject({
|
|
9001
|
+
...this._def,
|
|
9002
|
+
shape: () => ({
|
|
9003
|
+
...this._def.shape(),
|
|
9004
|
+
...augmentation
|
|
9005
|
+
})
|
|
9006
|
+
});
|
|
8976
9007
|
}
|
|
8977
9008
|
merge(merging) {
|
|
8978
9009
|
const merged = new ZodObject({
|
|
@@ -8983,6 +9014,9 @@ var ZodObject = class extends ZodType {
|
|
|
8983
9014
|
});
|
|
8984
9015
|
return merged;
|
|
8985
9016
|
}
|
|
9017
|
+
setKey(key, schema3) {
|
|
9018
|
+
return this.augment({ [key]: schema3 });
|
|
9019
|
+
}
|
|
8986
9020
|
catchall(index4) {
|
|
8987
9021
|
return new ZodObject({
|
|
8988
9022
|
...this._def,
|
|
@@ -8991,9 +9025,10 @@ var ZodObject = class extends ZodType {
|
|
|
8991
9025
|
}
|
|
8992
9026
|
pick(mask) {
|
|
8993
9027
|
const shape = {};
|
|
8994
|
-
util.objectKeys(mask).
|
|
8995
|
-
if (this.shape[key])
|
|
9028
|
+
util.objectKeys(mask).forEach((key) => {
|
|
9029
|
+
if (mask[key] && this.shape[key]) {
|
|
8996
9030
|
shape[key] = this.shape[key];
|
|
9031
|
+
}
|
|
8997
9032
|
});
|
|
8998
9033
|
return new ZodObject({
|
|
8999
9034
|
...this._def,
|
|
@@ -9002,8 +9037,8 @@ var ZodObject = class extends ZodType {
|
|
|
9002
9037
|
}
|
|
9003
9038
|
omit(mask) {
|
|
9004
9039
|
const shape = {};
|
|
9005
|
-
util.objectKeys(this.shape).
|
|
9006
|
-
if (
|
|
9040
|
+
util.objectKeys(this.shape).forEach((key) => {
|
|
9041
|
+
if (!mask[key]) {
|
|
9007
9042
|
shape[key] = this.shape[key];
|
|
9008
9043
|
}
|
|
9009
9044
|
});
|
|
@@ -9017,24 +9052,14 @@ var ZodObject = class extends ZodType {
|
|
|
9017
9052
|
}
|
|
9018
9053
|
partial(mask) {
|
|
9019
9054
|
const newShape = {};
|
|
9020
|
-
|
|
9021
|
-
|
|
9022
|
-
|
|
9023
|
-
|
|
9024
|
-
|
|
9025
|
-
newShape[key] = this.shape[key].optional();
|
|
9026
|
-
}
|
|
9027
|
-
});
|
|
9028
|
-
return new ZodObject({
|
|
9029
|
-
...this._def,
|
|
9030
|
-
shape: () => newShape
|
|
9031
|
-
});
|
|
9032
|
-
} else {
|
|
9033
|
-
for (const key in this.shape) {
|
|
9034
|
-
const fieldSchema = this.shape[key];
|
|
9055
|
+
util.objectKeys(this.shape).forEach((key) => {
|
|
9056
|
+
const fieldSchema = this.shape[key];
|
|
9057
|
+
if (mask && !mask[key]) {
|
|
9058
|
+
newShape[key] = fieldSchema;
|
|
9059
|
+
} else {
|
|
9035
9060
|
newShape[key] = fieldSchema.optional();
|
|
9036
9061
|
}
|
|
9037
|
-
}
|
|
9062
|
+
});
|
|
9038
9063
|
return new ZodObject({
|
|
9039
9064
|
...this._def,
|
|
9040
9065
|
shape: () => newShape
|
|
@@ -9042,21 +9067,10 @@ var ZodObject = class extends ZodType {
|
|
|
9042
9067
|
}
|
|
9043
9068
|
required(mask) {
|
|
9044
9069
|
const newShape = {};
|
|
9045
|
-
|
|
9046
|
-
|
|
9047
|
-
|
|
9048
|
-
|
|
9049
|
-
} else {
|
|
9050
|
-
const fieldSchema = this.shape[key];
|
|
9051
|
-
let newField = fieldSchema;
|
|
9052
|
-
while (newField instanceof ZodOptional) {
|
|
9053
|
-
newField = newField._def.innerType;
|
|
9054
|
-
}
|
|
9055
|
-
newShape[key] = newField;
|
|
9056
|
-
}
|
|
9057
|
-
});
|
|
9058
|
-
} else {
|
|
9059
|
-
for (const key in this.shape) {
|
|
9070
|
+
util.objectKeys(this.shape).forEach((key) => {
|
|
9071
|
+
if (mask && !mask[key]) {
|
|
9072
|
+
newShape[key] = this.shape[key];
|
|
9073
|
+
} else {
|
|
9060
9074
|
const fieldSchema = this.shape[key];
|
|
9061
9075
|
let newField = fieldSchema;
|
|
9062
9076
|
while (newField instanceof ZodOptional) {
|
|
@@ -9064,7 +9078,7 @@ var ZodObject = class extends ZodType {
|
|
|
9064
9078
|
}
|
|
9065
9079
|
newShape[key] = newField;
|
|
9066
9080
|
}
|
|
9067
|
-
}
|
|
9081
|
+
});
|
|
9068
9082
|
return new ZodObject({
|
|
9069
9083
|
...this._def,
|
|
9070
9084
|
shape: () => newShape
|
|
@@ -9404,7 +9418,7 @@ var ZodTuple = class extends ZodType {
|
|
|
9404
9418
|
});
|
|
9405
9419
|
status.dirty();
|
|
9406
9420
|
}
|
|
9407
|
-
const items = ctx.data.map((item, itemIndex) => {
|
|
9421
|
+
const items = [...ctx.data].map((item, itemIndex) => {
|
|
9408
9422
|
const schema3 = this._def.items[itemIndex] || this._def.rest;
|
|
9409
9423
|
if (!schema3)
|
|
9410
9424
|
return null;
|
|
@@ -9771,6 +9785,7 @@ var ZodLiteral = class extends ZodType {
|
|
|
9771
9785
|
if (input.data !== this._def.value) {
|
|
9772
9786
|
const ctx = this._getOrReturnCtx(input);
|
|
9773
9787
|
addIssueToContext(ctx, {
|
|
9788
|
+
received: ctx.data,
|
|
9774
9789
|
code: ZodIssueCode.invalid_literal,
|
|
9775
9790
|
expected: this._def.value
|
|
9776
9791
|
});
|
|
@@ -9844,6 +9859,12 @@ var ZodEnum = class extends ZodType {
|
|
|
9844
9859
|
}
|
|
9845
9860
|
return enumValues;
|
|
9846
9861
|
}
|
|
9862
|
+
extract(values) {
|
|
9863
|
+
return ZodEnum.create(values);
|
|
9864
|
+
}
|
|
9865
|
+
exclude(values) {
|
|
9866
|
+
return ZodEnum.create(this.options.filter((opt) => !values.includes(opt)));
|
|
9867
|
+
}
|
|
9847
9868
|
};
|
|
9848
9869
|
ZodEnum.create = createZodEnum;
|
|
9849
9870
|
var ZodNativeEnum = class extends ZodType {
|
|
@@ -9882,6 +9903,9 @@ ZodNativeEnum.create = (values, params) => {
|
|
|
9882
9903
|
});
|
|
9883
9904
|
};
|
|
9884
9905
|
var ZodPromise = class extends ZodType {
|
|
9906
|
+
unwrap() {
|
|
9907
|
+
return this._def.type;
|
|
9908
|
+
}
|
|
9885
9909
|
_parse(input) {
|
|
9886
9910
|
const { ctx } = this._processInputParams(input);
|
|
9887
9911
|
if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
|
|
@@ -10095,23 +10119,29 @@ var ZodCatch = class extends ZodType {
|
|
|
10095
10119
|
const result = this._def.innerType._parse({
|
|
10096
10120
|
data: ctx.data,
|
|
10097
10121
|
path: ctx.path,
|
|
10098
|
-
parent:
|
|
10122
|
+
parent: {
|
|
10123
|
+
...ctx,
|
|
10124
|
+
common: {
|
|
10125
|
+
...ctx.common,
|
|
10126
|
+
issues: []
|
|
10127
|
+
}
|
|
10128
|
+
}
|
|
10099
10129
|
});
|
|
10100
10130
|
if (isAsync(result)) {
|
|
10101
10131
|
return result.then((result2) => {
|
|
10102
10132
|
return {
|
|
10103
10133
|
status: "valid",
|
|
10104
|
-
value: result2.status === "valid" ? result2.value : this._def.
|
|
10134
|
+
value: result2.status === "valid" ? result2.value : this._def.catchValue()
|
|
10105
10135
|
};
|
|
10106
10136
|
});
|
|
10107
10137
|
} else {
|
|
10108
10138
|
return {
|
|
10109
10139
|
status: "valid",
|
|
10110
|
-
value: result.status === "valid" ? result.value : this._def.
|
|
10140
|
+
value: result.status === "valid" ? result.value : this._def.catchValue()
|
|
10111
10141
|
};
|
|
10112
10142
|
}
|
|
10113
10143
|
}
|
|
10114
|
-
|
|
10144
|
+
removeCatch() {
|
|
10115
10145
|
return this._def.innerType;
|
|
10116
10146
|
}
|
|
10117
10147
|
};
|
|
@@ -10119,7 +10149,7 @@ ZodCatch.create = (type, params) => {
|
|
|
10119
10149
|
return new ZodCatch({
|
|
10120
10150
|
innerType: type,
|
|
10121
10151
|
typeName: ZodFirstPartyTypeKind.ZodCatch,
|
|
10122
|
-
|
|
10152
|
+
catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
|
|
10123
10153
|
...processCreateParams(params)
|
|
10124
10154
|
});
|
|
10125
10155
|
};
|
|
@@ -10323,13 +10353,25 @@ var tableV3 = objectType({
|
|
|
10323
10353
|
indexes: recordType(stringType(), index),
|
|
10324
10354
|
foreignKeys: recordType(stringType(), fk)
|
|
10325
10355
|
}).strict();
|
|
10326
|
-
var
|
|
10356
|
+
var compositePK = objectType({
|
|
10357
|
+
name: stringType(),
|
|
10358
|
+
columns: stringType().array()
|
|
10359
|
+
}).strict();
|
|
10360
|
+
var tableV4 = objectType({
|
|
10327
10361
|
name: stringType(),
|
|
10328
10362
|
schema: stringType().optional(),
|
|
10329
10363
|
columns: recordType(stringType(), column),
|
|
10330
10364
|
indexes: recordType(stringType(), index),
|
|
10331
10365
|
foreignKeys: recordType(stringType(), fk)
|
|
10332
10366
|
}).strict();
|
|
10367
|
+
var table = objectType({
|
|
10368
|
+
name: stringType(),
|
|
10369
|
+
schema: stringType().optional(),
|
|
10370
|
+
columns: recordType(stringType(), column),
|
|
10371
|
+
indexes: recordType(stringType(), index),
|
|
10372
|
+
foreignKeys: recordType(stringType(), fk),
|
|
10373
|
+
compositePrimaryKeys: recordType(stringType(), compositePK)
|
|
10374
|
+
}).strict();
|
|
10333
10375
|
var dialect = literalType("mysql");
|
|
10334
10376
|
var schemaHash = objectType({
|
|
10335
10377
|
id: stringType(),
|
|
@@ -10343,7 +10385,7 @@ var schemaInternalV3 = objectType({
|
|
|
10343
10385
|
var schemaInternalV4 = objectType({
|
|
10344
10386
|
version: literalType("4"),
|
|
10345
10387
|
dialect,
|
|
10346
|
-
tables: recordType(stringType(),
|
|
10388
|
+
tables: recordType(stringType(), tableV4),
|
|
10347
10389
|
schemas: recordType(stringType(), stringType())
|
|
10348
10390
|
}).strict();
|
|
10349
10391
|
var schemaInternal = objectType({
|
|
@@ -10360,19 +10402,33 @@ var schemaInternal = objectType({
|
|
|
10360
10402
|
var schemaV3 = schemaInternalV3.merge(schemaHash);
|
|
10361
10403
|
var schemaV4 = schemaInternalV4.merge(schemaHash);
|
|
10362
10404
|
var schema = schemaInternal.merge(schemaHash);
|
|
10363
|
-
var
|
|
10405
|
+
var tableSquashedV4 = objectType({
|
|
10364
10406
|
name: stringType(),
|
|
10365
10407
|
schema: stringType().optional(),
|
|
10366
10408
|
columns: recordType(stringType(), column),
|
|
10367
10409
|
indexes: recordType(stringType(), stringType()),
|
|
10368
10410
|
foreignKeys: recordType(stringType(), stringType())
|
|
10369
10411
|
}).strict();
|
|
10412
|
+
var tableSquashed = objectType({
|
|
10413
|
+
name: stringType(),
|
|
10414
|
+
schema: stringType().optional(),
|
|
10415
|
+
columns: recordType(stringType(), column),
|
|
10416
|
+
indexes: recordType(stringType(), stringType()),
|
|
10417
|
+
foreignKeys: recordType(stringType(), stringType()),
|
|
10418
|
+
compositePrimaryKeys: recordType(stringType(), stringType())
|
|
10419
|
+
}).strict();
|
|
10370
10420
|
var schemaSquashed = objectType({
|
|
10371
10421
|
version: literalType("5"),
|
|
10372
10422
|
dialect,
|
|
10373
10423
|
tables: recordType(stringType(), tableSquashed),
|
|
10374
10424
|
schemas: recordType(stringType(), stringType())
|
|
10375
10425
|
}).strict();
|
|
10426
|
+
var schemaSquashedV4 = objectType({
|
|
10427
|
+
version: literalType("4"),
|
|
10428
|
+
dialect,
|
|
10429
|
+
tables: recordType(stringType(), tableSquashedV4),
|
|
10430
|
+
schemas: recordType(stringType(), stringType())
|
|
10431
|
+
}).strict();
|
|
10376
10432
|
var MySqlSquasher = {
|
|
10377
10433
|
squashIdx: (idx) => {
|
|
10378
10434
|
var _a, _b, _c;
|
|
@@ -10391,6 +10447,13 @@ var MySqlSquasher = {
|
|
|
10391
10447
|
};
|
|
10392
10448
|
return index.parse(destructed);
|
|
10393
10449
|
},
|
|
10450
|
+
squashPK: (pk) => {
|
|
10451
|
+
return `${pk.name};${pk.columns.join(",")}`;
|
|
10452
|
+
},
|
|
10453
|
+
unsquashPK: (pk) => {
|
|
10454
|
+
const splitted = pk.split(";");
|
|
10455
|
+
return { name: splitted[0], columns: splitted[1].split(",") };
|
|
10456
|
+
},
|
|
10394
10457
|
squashFK: (fk4) => {
|
|
10395
10458
|
var _a, _b;
|
|
10396
10459
|
return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${(_a = fk4.onUpdate) != null ? _a : ""};${(_b = fk4.onDelete) != null ? _b : ""}`;
|
|
@@ -10518,13 +10581,25 @@ var tableV32 = objectType({
|
|
|
10518
10581
|
indexes: recordType(stringType(), index2),
|
|
10519
10582
|
foreignKeys: recordType(stringType(), fk2)
|
|
10520
10583
|
}).strict();
|
|
10521
|
-
var
|
|
10584
|
+
var compositePK2 = objectType({
|
|
10585
|
+
name: stringType(),
|
|
10586
|
+
columns: stringType().array()
|
|
10587
|
+
}).strict();
|
|
10588
|
+
var tableV42 = objectType({
|
|
10522
10589
|
name: stringType(),
|
|
10523
10590
|
schema: stringType(),
|
|
10524
10591
|
columns: recordType(stringType(), column2),
|
|
10525
10592
|
indexes: recordType(stringType(), index2),
|
|
10526
10593
|
foreignKeys: recordType(stringType(), fk2)
|
|
10527
10594
|
}).strict();
|
|
10595
|
+
var table2 = objectType({
|
|
10596
|
+
name: stringType(),
|
|
10597
|
+
schema: stringType(),
|
|
10598
|
+
columns: recordType(stringType(), column2),
|
|
10599
|
+
indexes: recordType(stringType(), index2),
|
|
10600
|
+
foreignKeys: recordType(stringType(), fk2),
|
|
10601
|
+
compositePrimaryKeys: recordType(stringType(), compositePK2)
|
|
10602
|
+
}).strict();
|
|
10528
10603
|
var schemaHash2 = objectType({
|
|
10529
10604
|
id: stringType(),
|
|
10530
10605
|
prevId: stringType()
|
|
@@ -10538,7 +10613,7 @@ var pgSchemaInternalV3 = objectType({
|
|
|
10538
10613
|
var pgSchemaInternalV4 = objectType({
|
|
10539
10614
|
version: literalType("4"),
|
|
10540
10615
|
dialect: literalType("pg"),
|
|
10541
|
-
tables: recordType(stringType(),
|
|
10616
|
+
tables: recordType(stringType(), tableV42),
|
|
10542
10617
|
enums: recordType(stringType(), enumSchema),
|
|
10543
10618
|
schemas: recordType(stringType(), stringType())
|
|
10544
10619
|
}).strict();
|
|
@@ -10555,12 +10630,27 @@ var pgSchemaInternal = objectType({
|
|
|
10555
10630
|
})
|
|
10556
10631
|
}).strict();
|
|
10557
10632
|
var tableSquashed2 = objectType({
|
|
10633
|
+
name: stringType(),
|
|
10634
|
+
schema: stringType(),
|
|
10635
|
+
columns: recordType(stringType(), column2),
|
|
10636
|
+
indexes: recordType(stringType(), stringType()),
|
|
10637
|
+
foreignKeys: recordType(stringType(), stringType()),
|
|
10638
|
+
compositePrimaryKeys: recordType(stringType(), stringType())
|
|
10639
|
+
}).strict();
|
|
10640
|
+
var tableSquashedV42 = objectType({
|
|
10558
10641
|
name: stringType(),
|
|
10559
10642
|
schema: stringType(),
|
|
10560
10643
|
columns: recordType(stringType(), column2),
|
|
10561
10644
|
indexes: recordType(stringType(), stringType()),
|
|
10562
10645
|
foreignKeys: recordType(stringType(), stringType())
|
|
10563
10646
|
}).strict();
|
|
10647
|
+
var pgSchemaSquashedV4 = objectType({
|
|
10648
|
+
version: literalType("4"),
|
|
10649
|
+
dialect: enumType(["pg"]),
|
|
10650
|
+
tables: recordType(stringType(), tableSquashedV42),
|
|
10651
|
+
enums: recordType(stringType(), enumSchema),
|
|
10652
|
+
schemas: recordType(stringType(), stringType())
|
|
10653
|
+
}).strict();
|
|
10564
10654
|
var pgSchemaSquashed = objectType({
|
|
10565
10655
|
version: literalType("5"),
|
|
10566
10656
|
dialect: enumType(["pg"]),
|
|
@@ -10596,6 +10686,12 @@ var PgSquasher = {
|
|
|
10596
10686
|
var _a, _b;
|
|
10597
10687
|
return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${(_a = fk4.onUpdate) != null ? _a : ""};${(_b = fk4.onDelete) != null ? _b : ""}`;
|
|
10598
10688
|
},
|
|
10689
|
+
squashPK: (pk) => {
|
|
10690
|
+
return `${pk.columns.join(",")}`;
|
|
10691
|
+
},
|
|
10692
|
+
unsquashPK: (pk) => {
|
|
10693
|
+
return { name: "", columns: pk.split(",") };
|
|
10694
|
+
},
|
|
10599
10695
|
unsquashFK: (input) => {
|
|
10600
10696
|
const [
|
|
10601
10697
|
name,
|
|
@@ -10627,6 +10723,9 @@ var squashPgScheme = (json) => {
|
|
|
10627
10723
|
const squashedFKs = mapValues(it[1].foreignKeys, (fk4) => {
|
|
10628
10724
|
return PgSquasher.squashFK(fk4);
|
|
10629
10725
|
});
|
|
10726
|
+
const squashedPKs = mapValues(it[1].compositePrimaryKeys, (pk) => {
|
|
10727
|
+
return PgSquasher.squashPK(pk);
|
|
10728
|
+
});
|
|
10630
10729
|
return [
|
|
10631
10730
|
it[0],
|
|
10632
10731
|
{
|
|
@@ -10634,7 +10733,8 @@ var squashPgScheme = (json) => {
|
|
|
10634
10733
|
schema: it[1].schema,
|
|
10635
10734
|
columns: it[1].columns,
|
|
10636
10735
|
indexes: squashedIndexes,
|
|
10637
|
-
foreignKeys: squashedFKs
|
|
10736
|
+
foreignKeys: squashedFKs,
|
|
10737
|
+
compositePrimaryKeys: squashedPKs
|
|
10638
10738
|
}
|
|
10639
10739
|
];
|
|
10640
10740
|
})
|
|
@@ -10678,7 +10778,7 @@ var fk3 = objectType({
|
|
|
10678
10778
|
onUpdate: stringType().optional(),
|
|
10679
10779
|
onDelete: stringType().optional()
|
|
10680
10780
|
}).strict();
|
|
10681
|
-
var
|
|
10781
|
+
var compositePK3 = objectType({
|
|
10682
10782
|
columns: stringType().array()
|
|
10683
10783
|
}).strict();
|
|
10684
10784
|
var column3 = objectType({
|
|
@@ -10700,7 +10800,7 @@ var table3 = objectType({
|
|
|
10700
10800
|
columns: recordType(stringType(), column3),
|
|
10701
10801
|
indexes: recordType(stringType(), index3),
|
|
10702
10802
|
foreignKeys: recordType(stringType(), fk3),
|
|
10703
|
-
compositePrimaryKeys: recordType(stringType(),
|
|
10803
|
+
compositePrimaryKeys: recordType(stringType(), compositePK3)
|
|
10704
10804
|
}).strict();
|
|
10705
10805
|
var dialect2 = enumType(["sqlite"]);
|
|
10706
10806
|
var schemaHash3 = objectType({
|
|
@@ -11052,13 +11152,26 @@ var pgNativeTypes = /* @__PURE__ */ new Set([
|
|
|
11052
11152
|
"interval",
|
|
11053
11153
|
"bigint",
|
|
11054
11154
|
"bigserial",
|
|
11055
|
-
"double precision"
|
|
11155
|
+
"double precision",
|
|
11156
|
+
"interval year",
|
|
11157
|
+
"interval month",
|
|
11158
|
+
"interval day",
|
|
11159
|
+
"interval hour",
|
|
11160
|
+
"interval minute",
|
|
11161
|
+
"interval second",
|
|
11162
|
+
"interval year to month",
|
|
11163
|
+
"interval day to hour",
|
|
11164
|
+
"interval day to minute",
|
|
11165
|
+
"interval day to second",
|
|
11166
|
+
"interval hour to minute",
|
|
11167
|
+
"interval hour to second",
|
|
11168
|
+
"interval minute to second"
|
|
11056
11169
|
]);
|
|
11057
11170
|
var isPgNativeType = (it) => {
|
|
11058
11171
|
if (pgNativeTypes.has(it))
|
|
11059
11172
|
return true;
|
|
11060
11173
|
const toCheck = it.replace(/ /g, "");
|
|
11061
|
-
return toCheck.startsWith("varchar(") || toCheck.startsWith("numeric(") || toCheck.startsWith("timestamp(");
|
|
11174
|
+
return toCheck.startsWith("varchar(") || toCheck.startsWith("char(") || toCheck.startsWith("numeric(") || toCheck.startsWith("timestamp(");
|
|
11062
11175
|
};
|
|
11063
11176
|
var Convertor = class {
|
|
11064
11177
|
};
|
|
@@ -11067,7 +11180,7 @@ var PgCreateTableConvertor = class extends Convertor {
|
|
|
11067
11180
|
return statement.type === "create_table" && dialect3 === "pg";
|
|
11068
11181
|
}
|
|
11069
11182
|
convert(st) {
|
|
11070
|
-
const { tableName, schema: schema3, columns } = st;
|
|
11183
|
+
const { tableName, schema: schema3, columns, compositePKs } = st;
|
|
11071
11184
|
let statement = "";
|
|
11072
11185
|
const name = schema3 ? `"${schema3}"."${tableName}"` : `"${tableName}"`;
|
|
11073
11186
|
statement += `CREATE TABLE IF NOT EXISTS ${name} (
|
|
@@ -11077,13 +11190,19 @@ var PgCreateTableConvertor = class extends Convertor {
|
|
|
11077
11190
|
const primaryKeyStatement = column4.primaryKey ? "PRIMARY KEY" : "";
|
|
11078
11191
|
const notNullStatement = column4.notNull ? "NOT NULL" : "";
|
|
11079
11192
|
const defaultStatement = column4.default !== void 0 ? `DEFAULT ${column4.default}` : "";
|
|
11080
|
-
const type = isPgNativeType(column4.type) ? column4.type :
|
|
11193
|
+
const type = isPgNativeType(column4.type) ? column4.type : `${column4.type}`;
|
|
11081
11194
|
statement += " " + `"${column4.name}" ${type} ${primaryKeyStatement} ${defaultStatement} ${notNullStatement}`.replace(/ +/g, " ").trim();
|
|
11082
11195
|
statement += (i === columns.length - 1 ? "" : ",") + "\n";
|
|
11083
11196
|
}
|
|
11084
11197
|
statement += `);`;
|
|
11085
11198
|
statement += `
|
|
11086
11199
|
`;
|
|
11200
|
+
if (typeof compositePKs !== "undefined" && compositePKs.length > 0) {
|
|
11201
|
+
const compositePK4 = PgSquasher.unsquashPK(compositePKs[0]);
|
|
11202
|
+
statement += `ALTER TABLE ${name} ADD CONSTRAINT "${st.compositePkName}" PRIMARY KEY("${compositePK4.columns.join('","')}");`;
|
|
11203
|
+
statement += `
|
|
11204
|
+
`;
|
|
11205
|
+
}
|
|
11087
11206
|
return statement;
|
|
11088
11207
|
}
|
|
11089
11208
|
};
|
|
@@ -11092,7 +11211,7 @@ var MySqlCreateTableConvertor = class extends Convertor {
|
|
|
11092
11211
|
return statement.type === "create_table" && dialect3 === "mysql";
|
|
11093
11212
|
}
|
|
11094
11213
|
convert(st) {
|
|
11095
|
-
const { tableName, columns, schema: schema3 } = st;
|
|
11214
|
+
const { tableName, columns, schema: schema3, compositePKs } = st;
|
|
11096
11215
|
let statement = "";
|
|
11097
11216
|
const tName = schema3 ? `\`${schema3}\`.\`${tableName}\`` : `\`${tableName}\``;
|
|
11098
11217
|
statement += `CREATE TABLE ${tName} (
|
|
@@ -11110,6 +11229,12 @@ var MySqlCreateTableConvertor = class extends Convertor {
|
|
|
11110
11229
|
statement += `);`;
|
|
11111
11230
|
statement += `
|
|
11112
11231
|
`;
|
|
11232
|
+
if (typeof compositePKs !== "undefined" && compositePKs.length > 0) {
|
|
11233
|
+
const compositePK4 = MySqlSquasher.unsquashPK(compositePKs[0]);
|
|
11234
|
+
statement += `ALTER TABLE ${tName} ADD PRIMARY KEY(\`${compositePK4.columns.join("`,`")}\`);`;
|
|
11235
|
+
statement += `
|
|
11236
|
+
`;
|
|
11237
|
+
}
|
|
11113
11238
|
return statement;
|
|
11114
11239
|
}
|
|
11115
11240
|
};
|
|
@@ -11479,6 +11604,67 @@ var SqliteAlterTableAlterColumnDropDefaultConvertor = class extends Convertor {
|
|
|
11479
11604
|
*/`;
|
|
11480
11605
|
}
|
|
11481
11606
|
};
|
|
11607
|
+
var PgAlterTableCreateCompositePrimaryKeyConvertor = class extends Convertor {
|
|
11608
|
+
can(statement, dialect3) {
|
|
11609
|
+
return statement.type === "create_composite_pk" && dialect3 === "pg";
|
|
11610
|
+
}
|
|
11611
|
+
convert(statement) {
|
|
11612
|
+
const { name, columns } = PgSquasher.unsquashPK(statement.data);
|
|
11613
|
+
return `ALTER TABLE "${statement.tableName}" ADD CONSTRAINT "${statement.constraintName}" PRIMARY KEY("${columns.join('","')}");`;
|
|
11614
|
+
}
|
|
11615
|
+
};
|
|
11616
|
+
var PgAlterTableDeleteCompositePrimaryKeyConvertor = class extends Convertor {
|
|
11617
|
+
can(statement, dialect3) {
|
|
11618
|
+
return statement.type === "delete_composite_pk" && dialect3 === "pg";
|
|
11619
|
+
}
|
|
11620
|
+
convert(statement) {
|
|
11621
|
+
const { name, columns } = PgSquasher.unsquashPK(statement.data);
|
|
11622
|
+
return `ALTER TABLE "${statement.tableName}" DROP CONSTRAINT "${statement.constraintName}";`;
|
|
11623
|
+
}
|
|
11624
|
+
};
|
|
11625
|
+
var PgAlterTableAlterCompositePrimaryKeyConvertor = class extends Convertor {
|
|
11626
|
+
can(statement, dialect3) {
|
|
11627
|
+
return statement.type === "alter_composite_pk" && dialect3 === "pg";
|
|
11628
|
+
}
|
|
11629
|
+
convert(statement) {
|
|
11630
|
+
const { name, columns } = PgSquasher.unsquashPK(statement.old);
|
|
11631
|
+
const { name: newName, columns: newColumns } = PgSquasher.unsquashPK(
|
|
11632
|
+
statement.new
|
|
11633
|
+
);
|
|
11634
|
+
return `ALTER TABLE "${statement.tableName}" DROP CONSTRAINT ${statement.oldConstraintName};
|
|
11635
|
+
ALTER TABLE "${statement.tableName}" ADD CONSTRAINT ${statement.newConstraintName} PRIMARY KEY(${newColumns.join(",")});`;
|
|
11636
|
+
}
|
|
11637
|
+
};
|
|
11638
|
+
var MySqlAlterTableCreateCompositePrimaryKeyConvertor = class extends Convertor {
|
|
11639
|
+
can(statement, dialect3) {
|
|
11640
|
+
return statement.type === "create_composite_pk" && dialect3 === "mysql";
|
|
11641
|
+
}
|
|
11642
|
+
convert(statement) {
|
|
11643
|
+
const { name, columns } = MySqlSquasher.unsquashPK(statement.data);
|
|
11644
|
+
return `ALTER TABLE \`${statement.tableName}\` ADD PRIMARY KEY(\`${columns.join("`,`")}\`);`;
|
|
11645
|
+
}
|
|
11646
|
+
};
|
|
11647
|
+
var MySqlAlterTableDeleteCompositePrimaryKeyConvertor = class extends Convertor {
|
|
11648
|
+
can(statement, dialect3) {
|
|
11649
|
+
return statement.type === "delete_composite_pk" && dialect3 === "mysql";
|
|
11650
|
+
}
|
|
11651
|
+
convert(statement) {
|
|
11652
|
+
const { name, columns } = MySqlSquasher.unsquashPK(statement.data);
|
|
11653
|
+
return `ALTER TABLE \`${statement.tableName}\` DROP PRIMARY KEY;`;
|
|
11654
|
+
}
|
|
11655
|
+
};
|
|
11656
|
+
var MySqlAlterTableAlterCompositePrimaryKeyConvertor = class extends Convertor {
|
|
11657
|
+
can(statement, dialect3) {
|
|
11658
|
+
return statement.type === "alter_composite_pk" && dialect3 === "mysql";
|
|
11659
|
+
}
|
|
11660
|
+
convert(statement) {
|
|
11661
|
+
const { name, columns } = MySqlSquasher.unsquashPK(statement.old);
|
|
11662
|
+
const { name: newName, columns: newColumns } = MySqlSquasher.unsquashPK(
|
|
11663
|
+
statement.new
|
|
11664
|
+
);
|
|
11665
|
+
return `ALTER TABLE \`${statement.tableName}\` DROP PRIMARY KEY, ADD PRIMARY KEY(\`${newColumns.join("`,`")}\`);`;
|
|
11666
|
+
}
|
|
11667
|
+
};
|
|
11482
11668
|
var SqliteAlterTableCreateCompositePrimaryKeyConvertor = class extends Convertor {
|
|
11483
11669
|
can(statement, dialect3) {
|
|
11484
11670
|
return statement.type === "create_composite_pk" && dialect3 === "sqlite";
|
|
@@ -11985,6 +12171,12 @@ convertors.push(new SqliteAlterTableAlterColumnDropDefaultConvertor());
|
|
|
11985
12171
|
convertors.push(new SqliteAlterTableCreateCompositePrimaryKeyConvertor());
|
|
11986
12172
|
convertors.push(new SqliteAlterTableDeleteCompositePrimaryKeyConvertor());
|
|
11987
12173
|
convertors.push(new SqliteAlterTableAlterCompositePrimaryKeyConvertor());
|
|
12174
|
+
convertors.push(new PgAlterTableCreateCompositePrimaryKeyConvertor());
|
|
12175
|
+
convertors.push(new PgAlterTableDeleteCompositePrimaryKeyConvertor());
|
|
12176
|
+
convertors.push(new PgAlterTableAlterCompositePrimaryKeyConvertor());
|
|
12177
|
+
convertors.push(new MySqlAlterTableCreateCompositePrimaryKeyConvertor());
|
|
12178
|
+
convertors.push(new MySqlAlterTableDeleteCompositePrimaryKeyConvertor());
|
|
12179
|
+
convertors.push(new MySqlAlterTableAlterCompositePrimaryKeyConvertor());
|
|
11988
12180
|
var fromJson = (statements, dialect3) => {
|
|
11989
12181
|
const result = statements.map((statement) => {
|
|
11990
12182
|
const filtered = convertors.filter((it) => {
|
|
@@ -12025,13 +12217,30 @@ drop type __venum;
|
|
|
12025
12217
|
`;
|
|
12026
12218
|
|
|
12027
12219
|
// src/jsonStatements.ts
|
|
12028
|
-
var
|
|
12029
|
-
const { name, schema: schema3, columns } = table4;
|
|
12220
|
+
var preparePgCreateTableJson = (table4, json2) => {
|
|
12221
|
+
const { name, schema: schema3, columns, compositePrimaryKeys } = table4;
|
|
12030
12222
|
return {
|
|
12031
12223
|
type: "create_table",
|
|
12032
12224
|
tableName: name,
|
|
12033
12225
|
schema: schema3,
|
|
12034
|
-
columns: Object.values(columns)
|
|
12226
|
+
columns: Object.values(columns),
|
|
12227
|
+
compositePKs: Object.values(compositePrimaryKeys),
|
|
12228
|
+
compositePkName: Object.values(compositePrimaryKeys).length > 0 ? json2.tables[name].compositePrimaryKeys[`${name}_${PgSquasher.unsquashPK(
|
|
12229
|
+
Object.values(compositePrimaryKeys)[0]
|
|
12230
|
+
).columns.join("_")}`].name : ""
|
|
12231
|
+
};
|
|
12232
|
+
};
|
|
12233
|
+
var prepareMySqlCreateTableJson = (table4, json2) => {
|
|
12234
|
+
const { name, schema: schema3, columns, compositePrimaryKeys } = table4;
|
|
12235
|
+
return {
|
|
12236
|
+
type: "create_table",
|
|
12237
|
+
tableName: name,
|
|
12238
|
+
schema: schema3,
|
|
12239
|
+
columns: Object.values(columns),
|
|
12240
|
+
compositePKs: Object.values(compositePrimaryKeys),
|
|
12241
|
+
compositePkName: Object.values(compositePrimaryKeys).length > 0 ? json2.tables[name].compositePrimaryKeys[`${name}_${MySqlSquasher.unsquashPK(
|
|
12242
|
+
Object.values(compositePrimaryKeys)[0]
|
|
12243
|
+
).columns.join("_")}`].name : ""
|
|
12035
12244
|
};
|
|
12036
12245
|
};
|
|
12037
12246
|
var prepareSQLiteCreateTable = (table4) => {
|
|
@@ -12415,6 +12624,70 @@ var prepareAlterCompositePrimaryKeySqlite = (tableName, pks) => {
|
|
|
12415
12624
|
};
|
|
12416
12625
|
});
|
|
12417
12626
|
};
|
|
12627
|
+
var prepareAddCompositePrimaryKeyPg = (tableName, pks, json2) => {
|
|
12628
|
+
return Object.values(pks).map((it) => {
|
|
12629
|
+
return {
|
|
12630
|
+
type: "create_composite_pk",
|
|
12631
|
+
tableName,
|
|
12632
|
+
data: it,
|
|
12633
|
+
constraintName: json2.tables[tableName].compositePrimaryKeys[`${tableName}_${PgSquasher.unsquashPK(it).columns.join("_")}`].name
|
|
12634
|
+
};
|
|
12635
|
+
});
|
|
12636
|
+
};
|
|
12637
|
+
var prepareDeleteCompositePrimaryKeyPg = (tableName, pks, json1) => {
|
|
12638
|
+
return Object.values(pks).map((it) => {
|
|
12639
|
+
return {
|
|
12640
|
+
type: "delete_composite_pk",
|
|
12641
|
+
tableName,
|
|
12642
|
+
data: it,
|
|
12643
|
+
constraintName: json1.tables[tableName].compositePrimaryKeys[`${tableName}_${PgSquasher.unsquashPK(it).columns.join("_")}`].name
|
|
12644
|
+
};
|
|
12645
|
+
});
|
|
12646
|
+
};
|
|
12647
|
+
var prepareAlterCompositePrimaryKeyPg = (tableName, pks, json1, json2) => {
|
|
12648
|
+
return Object.values(pks).map((it) => {
|
|
12649
|
+
return {
|
|
12650
|
+
type: "alter_composite_pk",
|
|
12651
|
+
tableName,
|
|
12652
|
+
old: it.__old,
|
|
12653
|
+
new: it.__new,
|
|
12654
|
+
oldConstraintName: json1.tables[tableName].compositePrimaryKeys[`${tableName}_${PgSquasher.unsquashPK(it.__old).columns.join("_")}`].name,
|
|
12655
|
+
newConstraintName: json2.tables[tableName].compositePrimaryKeys[`${tableName}_${PgSquasher.unsquashPK(it.__new).columns.join("_")}`].name
|
|
12656
|
+
};
|
|
12657
|
+
});
|
|
12658
|
+
};
|
|
12659
|
+
var prepareAddCompositePrimaryKeyMySql = (tableName, pks, json2) => {
|
|
12660
|
+
return Object.values(pks).map((it) => {
|
|
12661
|
+
return {
|
|
12662
|
+
type: "create_composite_pk",
|
|
12663
|
+
tableName,
|
|
12664
|
+
data: it,
|
|
12665
|
+
constraintName: json2.tables[tableName].compositePrimaryKeys[`${tableName}_${MySqlSquasher.unsquashPK(it).columns.join("_")}`].name
|
|
12666
|
+
};
|
|
12667
|
+
});
|
|
12668
|
+
};
|
|
12669
|
+
var prepareDeleteCompositePrimaryKeyMySql = (tableName, pks, json1) => {
|
|
12670
|
+
return Object.values(pks).map((it) => {
|
|
12671
|
+
return {
|
|
12672
|
+
type: "delete_composite_pk",
|
|
12673
|
+
tableName,
|
|
12674
|
+
data: it,
|
|
12675
|
+
constraintName: json1.tables[tableName].compositePrimaryKeys[`${tableName}_${MySqlSquasher.unsquashPK(it).columns.join("_")}`].name
|
|
12676
|
+
};
|
|
12677
|
+
});
|
|
12678
|
+
};
|
|
12679
|
+
var prepareAlterCompositePrimaryKeyMySql = (tableName, pks, json1, json2) => {
|
|
12680
|
+
return Object.values(pks).map((it) => {
|
|
12681
|
+
return {
|
|
12682
|
+
type: "alter_composite_pk",
|
|
12683
|
+
tableName,
|
|
12684
|
+
old: it.__old,
|
|
12685
|
+
new: it.__new,
|
|
12686
|
+
oldConstraintName: json1.tables[tableName].compositePrimaryKeys[`${tableName}_${MySqlSquasher.unsquashPK(it.__old).columns.join("_")}`].name,
|
|
12687
|
+
newConstraintName: json2.tables[tableName].compositePrimaryKeys[`${tableName}_${MySqlSquasher.unsquashPK(it.__new).columns.join("_")}`].name
|
|
12688
|
+
};
|
|
12689
|
+
});
|
|
12690
|
+
};
|
|
12418
12691
|
|
|
12419
12692
|
// src/snapshotsDiffer.ts
|
|
12420
12693
|
var makeChanged = (schema3) => {
|
|
@@ -12556,7 +12829,7 @@ var diffResultScheme = objectType({
|
|
|
12556
12829
|
addedSchemas: stringType().array(),
|
|
12557
12830
|
deletedSchemas: stringType().array()
|
|
12558
12831
|
}).strict();
|
|
12559
|
-
var applySnapshotsDiff = async (json1, json2, dialect3, schemasResolver, tablesResolver, columnsResolver) => {
|
|
12832
|
+
var applySnapshotsDiff = async (json1, json2, dialect3, schemasResolver, tablesResolver, columnsResolver, prevFull, curFull) => {
|
|
12560
12833
|
var _a, _b, _c, _d;
|
|
12561
12834
|
const diffResult = applyJsonDiff(json1, json2);
|
|
12562
12835
|
if (Object.keys(diffResult).length === 0) {
|
|
@@ -12586,9 +12859,6 @@ var applySnapshotsDiff = async (json1, json2, dialect3, schemasResolver, tablesR
|
|
|
12586
12859
|
const jsonSQLiteCreateTables = created.map((it) => {
|
|
12587
12860
|
return prepareSQLiteCreateTable(it);
|
|
12588
12861
|
});
|
|
12589
|
-
const jsonCreateTables = created.map((it) => {
|
|
12590
|
-
return prepareCreateTableJson(it);
|
|
12591
|
-
});
|
|
12592
12862
|
const jsonCreateIndexesForCreatedTables = created.map((it) => {
|
|
12593
12863
|
return prepareCreateIndexesJson(it.name, it.schema, it.indexes);
|
|
12594
12864
|
}).flat();
|
|
@@ -12646,18 +12916,57 @@ var applySnapshotsDiff = async (json1, json2, dialect3, schemasResolver, tablesR
|
|
|
12646
12916
|
const jsonRemoveTableFromSchemas = [];
|
|
12647
12917
|
const jsonSetNewTableSchemas = [];
|
|
12648
12918
|
allAlteredResolved.forEach((it) => {
|
|
12649
|
-
|
|
12650
|
-
|
|
12651
|
-
|
|
12652
|
-
)
|
|
12653
|
-
|
|
12654
|
-
|
|
12655
|
-
|
|
12656
|
-
|
|
12657
|
-
|
|
12658
|
-
|
|
12659
|
-
|
|
12660
|
-
|
|
12919
|
+
let addedCompositePKs;
|
|
12920
|
+
let deletedCompositePKs;
|
|
12921
|
+
let alteredCompositePKs;
|
|
12922
|
+
if (dialect3 === "sqlite") {
|
|
12923
|
+
addedCompositePKs = prepareAddCompositePrimaryKeySqlite(
|
|
12924
|
+
it.name,
|
|
12925
|
+
it.addedCompositePKs
|
|
12926
|
+
);
|
|
12927
|
+
deletedCompositePKs = prepareDeleteCompositePrimaryKeySqlite(
|
|
12928
|
+
it.name,
|
|
12929
|
+
it.deletedCompositePKs
|
|
12930
|
+
);
|
|
12931
|
+
alteredCompositePKs = prepareAlterCompositePrimaryKeySqlite(
|
|
12932
|
+
it.name,
|
|
12933
|
+
it.alteredCompositePKs
|
|
12934
|
+
);
|
|
12935
|
+
} else if (dialect3 === "pg") {
|
|
12936
|
+
addedCompositePKs = prepareAddCompositePrimaryKeyPg(
|
|
12937
|
+
it.name,
|
|
12938
|
+
it.addedCompositePKs,
|
|
12939
|
+
curFull
|
|
12940
|
+
);
|
|
12941
|
+
deletedCompositePKs = prepareDeleteCompositePrimaryKeyPg(
|
|
12942
|
+
it.name,
|
|
12943
|
+
it.deletedCompositePKs,
|
|
12944
|
+
prevFull
|
|
12945
|
+
);
|
|
12946
|
+
alteredCompositePKs = prepareAlterCompositePrimaryKeyPg(
|
|
12947
|
+
it.name,
|
|
12948
|
+
it.alteredCompositePKs,
|
|
12949
|
+
prevFull,
|
|
12950
|
+
curFull
|
|
12951
|
+
);
|
|
12952
|
+
} else {
|
|
12953
|
+
addedCompositePKs = prepareAddCompositePrimaryKeyMySql(
|
|
12954
|
+
it.name,
|
|
12955
|
+
it.addedCompositePKs,
|
|
12956
|
+
curFull
|
|
12957
|
+
);
|
|
12958
|
+
deletedCompositePKs = prepareDeleteCompositePrimaryKeyMySql(
|
|
12959
|
+
it.name,
|
|
12960
|
+
it.deletedCompositePKs,
|
|
12961
|
+
prevFull
|
|
12962
|
+
);
|
|
12963
|
+
alteredCompositePKs = prepareAlterCompositePrimaryKeyMySql(
|
|
12964
|
+
it.name,
|
|
12965
|
+
it.alteredCompositePKs,
|
|
12966
|
+
prevFull,
|
|
12967
|
+
curFull
|
|
12968
|
+
);
|
|
12969
|
+
}
|
|
12661
12970
|
if (it.schema && typeof it.schema !== "string") {
|
|
12662
12971
|
switch (it.schema.type) {
|
|
12663
12972
|
case "added": {
|
|
@@ -12780,8 +13089,16 @@ var applySnapshotsDiff = async (json1, json2, dialect3, schemasResolver, tablesR
|
|
|
12780
13089
|
jsonStatements.push(...jsonAlterEnumsWithAddedValues);
|
|
12781
13090
|
if (dialect3 === "sqlite") {
|
|
12782
13091
|
jsonStatements.push(...jsonSQLiteCreateTables);
|
|
13092
|
+
} else if (dialect3 === "pg") {
|
|
13093
|
+
const jsonPgCreateTables = created.map((it) => {
|
|
13094
|
+
return preparePgCreateTableJson(it, curFull);
|
|
13095
|
+
});
|
|
13096
|
+
jsonStatements.push(...jsonPgCreateTables);
|
|
12783
13097
|
} else {
|
|
12784
|
-
|
|
13098
|
+
const jsonMySqlCreateTables = created.map((it) => {
|
|
13099
|
+
return prepareMySqlCreateTableJson(it, curFull);
|
|
13100
|
+
});
|
|
13101
|
+
jsonStatements.push(...jsonMySqlCreateTables);
|
|
12785
13102
|
}
|
|
12786
13103
|
jsonStatements.push(...jsonDropTables);
|
|
12787
13104
|
jsonStatements.push(...jsonRenameTables);
|
|
@@ -12810,7 +13127,11 @@ var applySnapshotsDiff = async (json1, json2, dialect3, schemasResolver, tablesR
|
|
|
12810
13127
|
}
|
|
12811
13128
|
});
|
|
12812
13129
|
const _meta = prepareMigrationMeta(rSchemas, rTables, rColumns);
|
|
12813
|
-
return {
|
|
13130
|
+
return {
|
|
13131
|
+
statements: jsonStatements,
|
|
13132
|
+
sqlStatements: uniqueSqlStatements,
|
|
13133
|
+
_meta
|
|
13134
|
+
};
|
|
12814
13135
|
};
|
|
12815
13136
|
|
|
12816
13137
|
// src/cli/commands/upFolders.ts
|
|
@@ -12945,7 +13266,7 @@ var snapshotsPriorV4 = (out) => {
|
|
|
12945
13266
|
return pathJson;
|
|
12946
13267
|
});
|
|
12947
13268
|
};
|
|
12948
|
-
var
|
|
13269
|
+
var prepareOutFolder2 = (out, dialect3) => {
|
|
12949
13270
|
const meta = (0, import_path.join)(out, "meta");
|
|
12950
13271
|
const journalPath = (0, import_path.join)(meta, "_journal.json");
|
|
12951
13272
|
if (!(0, import_fs.existsSync)((0, import_path.join)(out, "meta"))) {
|
|
@@ -12969,7 +13290,7 @@ var validatorForDialect = (dialect3) => {
|
|
|
12969
13290
|
case "pg":
|
|
12970
13291
|
return { validator: backwardCompatiblePgSchema, version: 5 };
|
|
12971
13292
|
case "sqlite":
|
|
12972
|
-
return { validator: backwardCompatibleSqliteSchema, version:
|
|
13293
|
+
return { validator: backwardCompatibleSqliteSchema, version: 5 };
|
|
12973
13294
|
case "mysql":
|
|
12974
13295
|
return { validator: backwardCompatibleMysqlSchema, version: 5 };
|
|
12975
13296
|
}
|
|
@@ -13018,7 +13339,7 @@ var validateWithReport = (snapshots, dialect3) => {
|
|
|
13018
13339
|
return result;
|
|
13019
13340
|
};
|
|
13020
13341
|
var prepareMigrationFolder = (outFolder = "drizzle", dialect3) => {
|
|
13021
|
-
const { snapshots, journal } =
|
|
13342
|
+
const { snapshots, journal } = prepareOutFolder2(outFolder, dialect3);
|
|
13022
13343
|
const report = validateWithReport(snapshots, dialect3);
|
|
13023
13344
|
if (report.nonLatest.length > 0) {
|
|
13024
13345
|
console.log(
|