drizzle-kit 0.27.1-19f042a → 0.27.1-2293cf4
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.js +56 -63
- package/api.mjs +56 -63
- package/bin.cjs +47400 -47409
- package/package.json +1 -4
package/api.js
CHANGED
@@ -8091,6 +8091,16 @@ var init_pgSchema = __esm({
|
|
8091
8091
|
squashPolicyPush: (policy4) => {
|
8092
8092
|
return `${policy4.name}--${policy4.as}--${policy4.for}--${policy4.to?.join(",")}--${policy4.on}`;
|
8093
8093
|
},
|
8094
|
+
unsquashPolicyPush: (policy4) => {
|
8095
|
+
const splitted = policy4.split("--");
|
8096
|
+
return {
|
8097
|
+
name: splitted[0],
|
8098
|
+
as: splitted[1],
|
8099
|
+
for: splitted[2],
|
8100
|
+
to: splitted[3].split(","),
|
8101
|
+
on: splitted[4] !== "undefined" ? splitted[4] : void 0
|
8102
|
+
};
|
8103
|
+
},
|
8094
8104
|
squashPK: (pk) => {
|
8095
8105
|
return `${pk.columns.join(",")};${pk.name}`;
|
8096
8106
|
},
|
@@ -12053,9 +12063,9 @@ var init_sqlgenerator = __esm({
|
|
12053
12063
|
can(statement, dialect4) {
|
12054
12064
|
return statement.type === "alter_policy" && dialect4 === "postgresql";
|
12055
12065
|
}
|
12056
|
-
convert(statement) {
|
12057
|
-
const newPolicy = PgSquasher.unsquashPolicy(statement.newData);
|
12058
|
-
const oldPolicy = PgSquasher.unsquashPolicy(statement.oldData);
|
12066
|
+
convert(statement, _dialect, action) {
|
12067
|
+
const newPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(statement.newData) : PgSquasher.unsquashPolicy(statement.newData);
|
12068
|
+
const oldPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(statement.oldData) : PgSquasher.unsquashPolicy(statement.oldData);
|
12059
12069
|
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
12060
12070
|
const usingPart = newPolicy.using ? ` USING (${newPolicy.using})` : oldPolicy.using ? ` USING (${oldPolicy.using})` : "";
|
12061
12071
|
const withCheckPart = newPolicy.withCheck ? ` WITH CHECK (${newPolicy.withCheck})` : oldPolicy.withCheck ? ` WITH CHECK (${oldPolicy.withCheck})` : "";
|
@@ -12775,7 +12785,7 @@ WITH ${withCheckOption} CHECK OPTION` : "";
|
|
12775
12785
|
can(statement, dialect4) {
|
12776
12786
|
return statement.type === "drop_table" && dialect4 === "postgresql";
|
12777
12787
|
}
|
12778
|
-
convert(statement) {
|
12788
|
+
convert(statement, _d5, action) {
|
12779
12789
|
const { tableName, schema: schema4, policies } = statement;
|
12780
12790
|
const tableNameWithSchema = schema4 ? `"${schema4}"."${tableName}"` : `"${tableName}"`;
|
12781
12791
|
const dropPolicyConvertor = new PgDropPolicyConvertor();
|
@@ -12783,7 +12793,7 @@ WITH ${withCheckOption} CHECK OPTION` : "";
|
|
12783
12793
|
return dropPolicyConvertor.convert({
|
12784
12794
|
type: "drop_policy",
|
12785
12795
|
tableName,
|
12786
|
-
data: PgSquasher.unsquashPolicy(p),
|
12796
|
+
data: action === "push" ? PgSquasher.unsquashPolicyPush(p) : PgSquasher.unsquashPolicy(p),
|
12787
12797
|
schema: schema4
|
12788
12798
|
});
|
12789
12799
|
}) ?? [];
|
@@ -16770,8 +16780,10 @@ var init_snapshotsDiffer = __esm({
|
|
16770
16780
|
const { renamed, created: created2, deleted: deleted2 } = await policyResolver2({
|
16771
16781
|
tableName: entry.name,
|
16772
16782
|
schema: entry.schema,
|
16773
|
-
deleted: entry.policies.deleted.map(
|
16774
|
-
|
16783
|
+
deleted: entry.policies.deleted.map(
|
16784
|
+
action === "push" ? PgSquasher.unsquashPolicyPush : PgSquasher.unsquashPolicy
|
16785
|
+
),
|
16786
|
+
created: entry.policies.added.map(action === "push" ? PgSquasher.unsquashPolicyPush : PgSquasher.unsquashPolicy)
|
16775
16787
|
});
|
16776
16788
|
if (created2.length > 0) {
|
16777
16789
|
policyCreates.push({
|
@@ -16811,7 +16823,7 @@ var init_snapshotsDiffer = __esm({
|
|
16811
16823
|
(policyKey, policy4) => {
|
16812
16824
|
const rens = policyRenamesDict[`${tableValue.schema || "public"}.${tableValue.name}`] || [];
|
16813
16825
|
const newName = columnChangeFor(policyKey, rens);
|
16814
|
-
const unsquashedPolicy = PgSquasher.unsquashPolicy(policy4);
|
16826
|
+
const unsquashedPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(policy4) : PgSquasher.unsquashPolicy(policy4);
|
16815
16827
|
unsquashedPolicy.name = newName;
|
16816
16828
|
policy4 = PgSquasher.squashPolicy(unsquashedPolicy);
|
16817
16829
|
return newName;
|
@@ -16825,8 +16837,12 @@ var init_snapshotsDiffer = __esm({
|
|
16825
16837
|
const indPolicyCreates = [];
|
16826
16838
|
const indPolicyDeletes = [];
|
16827
16839
|
const { renamed: indPolicyRenames, created, deleted } = await indPolicyResolver2({
|
16828
|
-
deleted: indPolicyRes.deleted.map(
|
16829
|
-
|
16840
|
+
deleted: indPolicyRes.deleted.map(
|
16841
|
+
(t) => action === "push" ? PgSquasher.unsquashPolicyPush(t.values) : PgSquasher.unsquashPolicy(t.values)
|
16842
|
+
),
|
16843
|
+
created: indPolicyRes.added.map(
|
16844
|
+
(t) => action === "push" ? PgSquasher.unsquashPolicyPush(t.values) : PgSquasher.unsquashPolicy(t.values)
|
16845
|
+
)
|
16830
16846
|
});
|
16831
16847
|
if (created.length > 0) {
|
16832
16848
|
indPolicyCreates.push({
|
@@ -17101,9 +17117,9 @@ var init_snapshotsDiffer = __esm({
|
|
17101
17117
|
);
|
17102
17118
|
}
|
17103
17119
|
typedResult.alteredPolicies.forEach(({ values }) => {
|
17104
|
-
const policy4 = PgSquasher.unsquashPolicy(values);
|
17105
|
-
const newPolicy = PgSquasher.unsquashPolicy(json22.policies[policy4.name].values);
|
17106
|
-
const oldPolicy = PgSquasher.unsquashPolicy(json1.policies[policy4.name].values);
|
17120
|
+
const policy4 = action === "push" ? PgSquasher.unsquashPolicyPush(values) : PgSquasher.unsquashPolicy(values);
|
17121
|
+
const newPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(json22.policies[policy4.name].values) : PgSquasher.unsquashPolicy(json22.policies[policy4.name].values);
|
17122
|
+
const oldPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(json22.policies[policy4.name].values) : PgSquasher.unsquashPolicy(json1.policies[policy4.name].values);
|
17107
17123
|
if (newPolicy.as !== oldPolicy.as) {
|
17108
17124
|
jsonDropIndPoliciesStatements.push(
|
17109
17125
|
...prepareDropIndPolicyJsons(
|
@@ -17162,8 +17178,8 @@ var init_snapshotsDiffer = __esm({
|
|
17162
17178
|
}
|
17163
17179
|
alteredTables.forEach((it) => {
|
17164
17180
|
Object.keys(it.alteredPolicies).forEach((policyName) => {
|
17165
|
-
const newPolicy = PgSquasher.unsquashPolicy(it.alteredPolicies[policyName].__new);
|
17166
|
-
const oldPolicy = PgSquasher.unsquashPolicy(it.alteredPolicies[policyName].__old);
|
17181
|
+
const newPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(it.alteredPolicies[policyName].__new) : PgSquasher.unsquashPolicy(it.alteredPolicies[policyName].__new);
|
17182
|
+
const oldPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(it.alteredPolicies[policyName].__old) : PgSquasher.unsquashPolicy(it.alteredPolicies[policyName].__old);
|
17167
17183
|
if (newPolicy.as !== oldPolicy.as) {
|
17168
17184
|
jsonDropPoliciesStatements.push(
|
17169
17185
|
...prepareDropPolicyJsons(
|
@@ -17217,7 +17233,8 @@ var init_snapshotsDiffer = __esm({
|
|
17217
17233
|
if (policiesInPreviousState.length > 0 && policiesInCurrentState.length === 0 && !table4.isRLSEnabled) {
|
17218
17234
|
jsonDisableRLSStatements.push({ type: "disable_rls", tableName: table4.name, schema: table4.schema });
|
17219
17235
|
}
|
17220
|
-
|
17236
|
+
const wasRlsEnabled = tableInPreviousState ? tableInPreviousState.isRLSEnabled : false;
|
17237
|
+
if (table4.isRLSEnabled !== wasRlsEnabled) {
|
17221
17238
|
if (table4.isRLSEnabled) {
|
17222
17239
|
jsonEnableRLSStatements.push({ type: "enable_rls", tableName: table4.name, schema: table4.schema });
|
17223
17240
|
} else if (!table4.isRLSEnabled && policiesInCurrentState.length === 0) {
|
@@ -17344,7 +17361,11 @@ var init_snapshotsDiffer = __esm({
|
|
17344
17361
|
});
|
17345
17362
|
jsonCreatePoliciesStatements.push(...[].concat(
|
17346
17363
|
...createdTables.map(
|
17347
|
-
(it) => prepareCreatePolicyJsons(
|
17364
|
+
(it) => prepareCreatePolicyJsons(
|
17365
|
+
it.name,
|
17366
|
+
it.schema,
|
17367
|
+
Object.values(it.policies).map(action === "push" ? PgSquasher.unsquashPolicyPush : PgSquasher.unsquashPolicy)
|
17368
|
+
)
|
17348
17369
|
)
|
17349
17370
|
));
|
17350
17371
|
const createViews = [];
|
@@ -17559,7 +17580,7 @@ var init_snapshotsDiffer = __esm({
|
|
17559
17580
|
}
|
17560
17581
|
return true;
|
17561
17582
|
});
|
17562
|
-
const sqlStatements = fromJson(filteredEnumsJsonStatements, "postgresql");
|
17583
|
+
const sqlStatements = fromJson(filteredEnumsJsonStatements, "postgresql", action);
|
17563
17584
|
const uniqueSqlStatements = [];
|
17564
17585
|
sqlStatements.forEach((ss) => {
|
17565
17586
|
if (!uniqueSqlStatements.includes(ss)) {
|
@@ -34679,7 +34700,7 @@ var init_datetime = __esm({
|
|
34679
34700
|
// ../drizzle-orm/dist/mysql-core/columns/decimal.js
|
34680
34701
|
function decimal(a, b = {}) {
|
34681
34702
|
const { name: name2, config } = getColumnNameAndConfig(a, b);
|
34682
|
-
return new MySqlDecimalBuilder(name2, config);
|
34703
|
+
return new MySqlDecimalBuilder(name2, config.precision, config.scale);
|
34683
34704
|
}
|
34684
34705
|
var _a259, _b182, MySqlDecimalBuilder, _a260, _b183, MySqlDecimal;
|
34685
34706
|
var init_decimal = __esm({
|
@@ -34689,11 +34710,10 @@ var init_decimal = __esm({
|
|
34689
34710
|
init_utils2();
|
34690
34711
|
init_common4();
|
34691
34712
|
MySqlDecimalBuilder = class extends (_b182 = MySqlColumnBuilderWithAutoIncrement, _a259 = entityKind, _b182) {
|
34692
|
-
constructor(name2,
|
34713
|
+
constructor(name2, precision, scale) {
|
34693
34714
|
super(name2, "string", "MySqlDecimal");
|
34694
|
-
this.config.precision =
|
34695
|
-
this.config.scale =
|
34696
|
-
this.config.unsigned = config?.unsigned;
|
34715
|
+
this.config.precision = precision;
|
34716
|
+
this.config.scale = scale;
|
34697
34717
|
}
|
34698
34718
|
/** @internal */
|
34699
34719
|
build(table4) {
|
@@ -34709,19 +34729,15 @@ var init_decimal = __esm({
|
|
34709
34729
|
super(...arguments);
|
34710
34730
|
__publicField(this, "precision", this.config.precision);
|
34711
34731
|
__publicField(this, "scale", this.config.scale);
|
34712
|
-
__publicField(this, "unsigned", this.config.unsigned);
|
34713
34732
|
}
|
34714
34733
|
getSQLType() {
|
34715
|
-
let type = "";
|
34716
34734
|
if (this.precision !== void 0 && this.scale !== void 0) {
|
34717
|
-
|
34735
|
+
return `decimal(${this.precision},${this.scale})`;
|
34718
34736
|
} else if (this.precision === void 0) {
|
34719
|
-
|
34737
|
+
return "decimal";
|
34720
34738
|
} else {
|
34721
|
-
|
34739
|
+
return `decimal(${this.precision})`;
|
34722
34740
|
}
|
34723
|
-
type = type === "decimal(10,0)" || type === "decimal(10)" ? "decimal" : type;
|
34724
|
-
return this.unsigned ? `${type} unsigned` : type;
|
34725
34741
|
}
|
34726
34742
|
};
|
34727
34743
|
__publicField(MySqlDecimal, _a260, "MySqlDecimal");
|
@@ -34745,7 +34761,6 @@ var init_double = __esm({
|
|
34745
34761
|
super(name2, "number", "MySqlDouble");
|
34746
34762
|
this.config.precision = config?.precision;
|
34747
34763
|
this.config.scale = config?.scale;
|
34748
|
-
this.config.unsigned = config?.unsigned;
|
34749
34764
|
}
|
34750
34765
|
/** @internal */
|
34751
34766
|
build(table4) {
|
@@ -34758,18 +34773,15 @@ var init_double = __esm({
|
|
34758
34773
|
super(...arguments);
|
34759
34774
|
__publicField(this, "precision", this.config.precision);
|
34760
34775
|
__publicField(this, "scale", this.config.scale);
|
34761
|
-
__publicField(this, "unsigned", this.config.unsigned);
|
34762
34776
|
}
|
34763
34777
|
getSQLType() {
|
34764
|
-
let type = "";
|
34765
34778
|
if (this.precision !== void 0 && this.scale !== void 0) {
|
34766
|
-
|
34779
|
+
return `double(${this.precision},${this.scale})`;
|
34767
34780
|
} else if (this.precision === void 0) {
|
34768
|
-
|
34781
|
+
return "double";
|
34769
34782
|
} else {
|
34770
|
-
|
34783
|
+
return `double(${this.precision})`;
|
34771
34784
|
}
|
34772
|
-
return this.unsigned ? `${type} unsigned` : type;
|
34773
34785
|
}
|
34774
34786
|
};
|
34775
34787
|
__publicField(MySqlDouble, _a262, "MySqlDouble");
|
@@ -34819,23 +34831,18 @@ var init_enum2 = __esm({
|
|
34819
34831
|
});
|
34820
34832
|
|
34821
34833
|
// ../drizzle-orm/dist/mysql-core/columns/float.js
|
34822
|
-
function float(
|
34823
|
-
|
34824
|
-
return new MySqlFloatBuilder(name2, config);
|
34834
|
+
function float(name2) {
|
34835
|
+
return new MySqlFloatBuilder(name2 ?? "");
|
34825
34836
|
}
|
34826
34837
|
var _a265, _b188, MySqlFloatBuilder, _a266, _b189, MySqlFloat;
|
34827
34838
|
var init_float = __esm({
|
34828
34839
|
"../drizzle-orm/dist/mysql-core/columns/float.js"() {
|
34829
34840
|
"use strict";
|
34830
34841
|
init_entity();
|
34831
|
-
init_utils2();
|
34832
34842
|
init_common4();
|
34833
34843
|
MySqlFloatBuilder = class extends (_b188 = MySqlColumnBuilderWithAutoIncrement, _a265 = entityKind, _b188) {
|
34834
|
-
constructor(name2
|
34844
|
+
constructor(name2) {
|
34835
34845
|
super(name2, "number", "MySqlFloat");
|
34836
|
-
this.config.precision = config?.precision;
|
34837
|
-
this.config.scale = config?.scale;
|
34838
|
-
this.config.unsigned = config?.unsigned;
|
34839
34846
|
}
|
34840
34847
|
/** @internal */
|
34841
34848
|
build(table4) {
|
@@ -34844,22 +34851,8 @@ var init_float = __esm({
|
|
34844
34851
|
};
|
34845
34852
|
__publicField(MySqlFloatBuilder, _a265, "MySqlFloatBuilder");
|
34846
34853
|
MySqlFloat = class extends (_b189 = MySqlColumnWithAutoIncrement, _a266 = entityKind, _b189) {
|
34847
|
-
constructor() {
|
34848
|
-
super(...arguments);
|
34849
|
-
__publicField(this, "precision", this.config.precision);
|
34850
|
-
__publicField(this, "scale", this.config.scale);
|
34851
|
-
__publicField(this, "unsigned", this.config.unsigned);
|
34852
|
-
}
|
34853
34854
|
getSQLType() {
|
34854
|
-
|
34855
|
-
if (this.precision !== void 0 && this.scale !== void 0) {
|
34856
|
-
type += `float(${this.precision},${this.scale})`;
|
34857
|
-
} else if (this.precision === void 0) {
|
34858
|
-
type += "float";
|
34859
|
-
} else {
|
34860
|
-
type += `float(${this.precision})`;
|
34861
|
-
}
|
34862
|
-
return this.unsigned ? `${type} unsigned` : type;
|
34855
|
+
return "float";
|
34863
34856
|
}
|
34864
34857
|
};
|
34865
34858
|
__publicField(MySqlFloat, _a266, "MySqlFloat");
|
@@ -38851,8 +38844,8 @@ ${withStyle.errorWarning(
|
|
38851
38844
|
changedType = columnType.replace("bigint unsigned", "serial");
|
38852
38845
|
}
|
38853
38846
|
}
|
38854
|
-
if (columnType.
|
38855
|
-
changedType =
|
38847
|
+
if (columnType.startsWith("tinyint")) {
|
38848
|
+
changedType = "tinyint";
|
38856
38849
|
}
|
38857
38850
|
let onUpdate = void 0;
|
38858
38851
|
if (columnType.startsWith("timestamp") && typeof columnExtra !== "undefined" && columnExtra.includes("on update CURRENT_TIMESTAMP")) {
|
@@ -40092,7 +40085,7 @@ var pgSuggestions = async (db, statements) => {
|
|
40092
40085
|
}
|
40093
40086
|
}
|
40094
40087
|
}
|
40095
|
-
const stmnt = fromJson([statement], "postgresql");
|
40088
|
+
const stmnt = fromJson([statement], "postgresql", "push");
|
40096
40089
|
if (typeof stmnt !== "undefined") {
|
40097
40090
|
statementsToExecute.push(...stmnt);
|
40098
40091
|
}
|
package/api.mjs
CHANGED
@@ -8096,6 +8096,16 @@ var init_pgSchema = __esm({
|
|
8096
8096
|
squashPolicyPush: (policy4) => {
|
8097
8097
|
return `${policy4.name}--${policy4.as}--${policy4.for}--${policy4.to?.join(",")}--${policy4.on}`;
|
8098
8098
|
},
|
8099
|
+
unsquashPolicyPush: (policy4) => {
|
8100
|
+
const splitted = policy4.split("--");
|
8101
|
+
return {
|
8102
|
+
name: splitted[0],
|
8103
|
+
as: splitted[1],
|
8104
|
+
for: splitted[2],
|
8105
|
+
to: splitted[3].split(","),
|
8106
|
+
on: splitted[4] !== "undefined" ? splitted[4] : void 0
|
8107
|
+
};
|
8108
|
+
},
|
8099
8109
|
squashPK: (pk) => {
|
8100
8110
|
return `${pk.columns.join(",")};${pk.name}`;
|
8101
8111
|
},
|
@@ -12058,9 +12068,9 @@ var init_sqlgenerator = __esm({
|
|
12058
12068
|
can(statement, dialect4) {
|
12059
12069
|
return statement.type === "alter_policy" && dialect4 === "postgresql";
|
12060
12070
|
}
|
12061
|
-
convert(statement) {
|
12062
|
-
const newPolicy = PgSquasher.unsquashPolicy(statement.newData);
|
12063
|
-
const oldPolicy = PgSquasher.unsquashPolicy(statement.oldData);
|
12071
|
+
convert(statement, _dialect, action) {
|
12072
|
+
const newPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(statement.newData) : PgSquasher.unsquashPolicy(statement.newData);
|
12073
|
+
const oldPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(statement.oldData) : PgSquasher.unsquashPolicy(statement.oldData);
|
12064
12074
|
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
12065
12075
|
const usingPart = newPolicy.using ? ` USING (${newPolicy.using})` : oldPolicy.using ? ` USING (${oldPolicy.using})` : "";
|
12066
12076
|
const withCheckPart = newPolicy.withCheck ? ` WITH CHECK (${newPolicy.withCheck})` : oldPolicy.withCheck ? ` WITH CHECK (${oldPolicy.withCheck})` : "";
|
@@ -12780,7 +12790,7 @@ WITH ${withCheckOption} CHECK OPTION` : "";
|
|
12780
12790
|
can(statement, dialect4) {
|
12781
12791
|
return statement.type === "drop_table" && dialect4 === "postgresql";
|
12782
12792
|
}
|
12783
|
-
convert(statement) {
|
12793
|
+
convert(statement, _d5, action) {
|
12784
12794
|
const { tableName, schema: schema4, policies } = statement;
|
12785
12795
|
const tableNameWithSchema = schema4 ? `"${schema4}"."${tableName}"` : `"${tableName}"`;
|
12786
12796
|
const dropPolicyConvertor = new PgDropPolicyConvertor();
|
@@ -12788,7 +12798,7 @@ WITH ${withCheckOption} CHECK OPTION` : "";
|
|
12788
12798
|
return dropPolicyConvertor.convert({
|
12789
12799
|
type: "drop_policy",
|
12790
12800
|
tableName,
|
12791
|
-
data: PgSquasher.unsquashPolicy(p),
|
12801
|
+
data: action === "push" ? PgSquasher.unsquashPolicyPush(p) : PgSquasher.unsquashPolicy(p),
|
12792
12802
|
schema: schema4
|
12793
12803
|
});
|
12794
12804
|
}) ?? [];
|
@@ -16775,8 +16785,10 @@ var init_snapshotsDiffer = __esm({
|
|
16775
16785
|
const { renamed, created: created2, deleted: deleted2 } = await policyResolver2({
|
16776
16786
|
tableName: entry.name,
|
16777
16787
|
schema: entry.schema,
|
16778
|
-
deleted: entry.policies.deleted.map(
|
16779
|
-
|
16788
|
+
deleted: entry.policies.deleted.map(
|
16789
|
+
action === "push" ? PgSquasher.unsquashPolicyPush : PgSquasher.unsquashPolicy
|
16790
|
+
),
|
16791
|
+
created: entry.policies.added.map(action === "push" ? PgSquasher.unsquashPolicyPush : PgSquasher.unsquashPolicy)
|
16780
16792
|
});
|
16781
16793
|
if (created2.length > 0) {
|
16782
16794
|
policyCreates.push({
|
@@ -16816,7 +16828,7 @@ var init_snapshotsDiffer = __esm({
|
|
16816
16828
|
(policyKey, policy4) => {
|
16817
16829
|
const rens = policyRenamesDict[`${tableValue.schema || "public"}.${tableValue.name}`] || [];
|
16818
16830
|
const newName = columnChangeFor(policyKey, rens);
|
16819
|
-
const unsquashedPolicy = PgSquasher.unsquashPolicy(policy4);
|
16831
|
+
const unsquashedPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(policy4) : PgSquasher.unsquashPolicy(policy4);
|
16820
16832
|
unsquashedPolicy.name = newName;
|
16821
16833
|
policy4 = PgSquasher.squashPolicy(unsquashedPolicy);
|
16822
16834
|
return newName;
|
@@ -16830,8 +16842,12 @@ var init_snapshotsDiffer = __esm({
|
|
16830
16842
|
const indPolicyCreates = [];
|
16831
16843
|
const indPolicyDeletes = [];
|
16832
16844
|
const { renamed: indPolicyRenames, created, deleted } = await indPolicyResolver2({
|
16833
|
-
deleted: indPolicyRes.deleted.map(
|
16834
|
-
|
16845
|
+
deleted: indPolicyRes.deleted.map(
|
16846
|
+
(t) => action === "push" ? PgSquasher.unsquashPolicyPush(t.values) : PgSquasher.unsquashPolicy(t.values)
|
16847
|
+
),
|
16848
|
+
created: indPolicyRes.added.map(
|
16849
|
+
(t) => action === "push" ? PgSquasher.unsquashPolicyPush(t.values) : PgSquasher.unsquashPolicy(t.values)
|
16850
|
+
)
|
16835
16851
|
});
|
16836
16852
|
if (created.length > 0) {
|
16837
16853
|
indPolicyCreates.push({
|
@@ -17106,9 +17122,9 @@ var init_snapshotsDiffer = __esm({
|
|
17106
17122
|
);
|
17107
17123
|
}
|
17108
17124
|
typedResult.alteredPolicies.forEach(({ values }) => {
|
17109
|
-
const policy4 = PgSquasher.unsquashPolicy(values);
|
17110
|
-
const newPolicy = PgSquasher.unsquashPolicy(json22.policies[policy4.name].values);
|
17111
|
-
const oldPolicy = PgSquasher.unsquashPolicy(json1.policies[policy4.name].values);
|
17125
|
+
const policy4 = action === "push" ? PgSquasher.unsquashPolicyPush(values) : PgSquasher.unsquashPolicy(values);
|
17126
|
+
const newPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(json22.policies[policy4.name].values) : PgSquasher.unsquashPolicy(json22.policies[policy4.name].values);
|
17127
|
+
const oldPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(json22.policies[policy4.name].values) : PgSquasher.unsquashPolicy(json1.policies[policy4.name].values);
|
17112
17128
|
if (newPolicy.as !== oldPolicy.as) {
|
17113
17129
|
jsonDropIndPoliciesStatements.push(
|
17114
17130
|
...prepareDropIndPolicyJsons(
|
@@ -17167,8 +17183,8 @@ var init_snapshotsDiffer = __esm({
|
|
17167
17183
|
}
|
17168
17184
|
alteredTables.forEach((it) => {
|
17169
17185
|
Object.keys(it.alteredPolicies).forEach((policyName) => {
|
17170
|
-
const newPolicy = PgSquasher.unsquashPolicy(it.alteredPolicies[policyName].__new);
|
17171
|
-
const oldPolicy = PgSquasher.unsquashPolicy(it.alteredPolicies[policyName].__old);
|
17186
|
+
const newPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(it.alteredPolicies[policyName].__new) : PgSquasher.unsquashPolicy(it.alteredPolicies[policyName].__new);
|
17187
|
+
const oldPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(it.alteredPolicies[policyName].__old) : PgSquasher.unsquashPolicy(it.alteredPolicies[policyName].__old);
|
17172
17188
|
if (newPolicy.as !== oldPolicy.as) {
|
17173
17189
|
jsonDropPoliciesStatements.push(
|
17174
17190
|
...prepareDropPolicyJsons(
|
@@ -17222,7 +17238,8 @@ var init_snapshotsDiffer = __esm({
|
|
17222
17238
|
if (policiesInPreviousState.length > 0 && policiesInCurrentState.length === 0 && !table4.isRLSEnabled) {
|
17223
17239
|
jsonDisableRLSStatements.push({ type: "disable_rls", tableName: table4.name, schema: table4.schema });
|
17224
17240
|
}
|
17225
|
-
|
17241
|
+
const wasRlsEnabled = tableInPreviousState ? tableInPreviousState.isRLSEnabled : false;
|
17242
|
+
if (table4.isRLSEnabled !== wasRlsEnabled) {
|
17226
17243
|
if (table4.isRLSEnabled) {
|
17227
17244
|
jsonEnableRLSStatements.push({ type: "enable_rls", tableName: table4.name, schema: table4.schema });
|
17228
17245
|
} else if (!table4.isRLSEnabled && policiesInCurrentState.length === 0) {
|
@@ -17349,7 +17366,11 @@ var init_snapshotsDiffer = __esm({
|
|
17349
17366
|
});
|
17350
17367
|
jsonCreatePoliciesStatements.push(...[].concat(
|
17351
17368
|
...createdTables.map(
|
17352
|
-
(it) => prepareCreatePolicyJsons(
|
17369
|
+
(it) => prepareCreatePolicyJsons(
|
17370
|
+
it.name,
|
17371
|
+
it.schema,
|
17372
|
+
Object.values(it.policies).map(action === "push" ? PgSquasher.unsquashPolicyPush : PgSquasher.unsquashPolicy)
|
17373
|
+
)
|
17353
17374
|
)
|
17354
17375
|
));
|
17355
17376
|
const createViews = [];
|
@@ -17564,7 +17585,7 @@ var init_snapshotsDiffer = __esm({
|
|
17564
17585
|
}
|
17565
17586
|
return true;
|
17566
17587
|
});
|
17567
|
-
const sqlStatements = fromJson(filteredEnumsJsonStatements, "postgresql");
|
17588
|
+
const sqlStatements = fromJson(filteredEnumsJsonStatements, "postgresql", action);
|
17568
17589
|
const uniqueSqlStatements = [];
|
17569
17590
|
sqlStatements.forEach((ss) => {
|
17570
17591
|
if (!uniqueSqlStatements.includes(ss)) {
|
@@ -34684,7 +34705,7 @@ var init_datetime = __esm({
|
|
34684
34705
|
// ../drizzle-orm/dist/mysql-core/columns/decimal.js
|
34685
34706
|
function decimal(a, b = {}) {
|
34686
34707
|
const { name: name2, config } = getColumnNameAndConfig(a, b);
|
34687
|
-
return new MySqlDecimalBuilder(name2, config);
|
34708
|
+
return new MySqlDecimalBuilder(name2, config.precision, config.scale);
|
34688
34709
|
}
|
34689
34710
|
var _a259, _b182, MySqlDecimalBuilder, _a260, _b183, MySqlDecimal;
|
34690
34711
|
var init_decimal = __esm({
|
@@ -34694,11 +34715,10 @@ var init_decimal = __esm({
|
|
34694
34715
|
init_utils2();
|
34695
34716
|
init_common4();
|
34696
34717
|
MySqlDecimalBuilder = class extends (_b182 = MySqlColumnBuilderWithAutoIncrement, _a259 = entityKind, _b182) {
|
34697
|
-
constructor(name2,
|
34718
|
+
constructor(name2, precision, scale) {
|
34698
34719
|
super(name2, "string", "MySqlDecimal");
|
34699
|
-
this.config.precision =
|
34700
|
-
this.config.scale =
|
34701
|
-
this.config.unsigned = config?.unsigned;
|
34720
|
+
this.config.precision = precision;
|
34721
|
+
this.config.scale = scale;
|
34702
34722
|
}
|
34703
34723
|
/** @internal */
|
34704
34724
|
build(table4) {
|
@@ -34714,19 +34734,15 @@ var init_decimal = __esm({
|
|
34714
34734
|
super(...arguments);
|
34715
34735
|
__publicField(this, "precision", this.config.precision);
|
34716
34736
|
__publicField(this, "scale", this.config.scale);
|
34717
|
-
__publicField(this, "unsigned", this.config.unsigned);
|
34718
34737
|
}
|
34719
34738
|
getSQLType() {
|
34720
|
-
let type = "";
|
34721
34739
|
if (this.precision !== void 0 && this.scale !== void 0) {
|
34722
|
-
|
34740
|
+
return `decimal(${this.precision},${this.scale})`;
|
34723
34741
|
} else if (this.precision === void 0) {
|
34724
|
-
|
34742
|
+
return "decimal";
|
34725
34743
|
} else {
|
34726
|
-
|
34744
|
+
return `decimal(${this.precision})`;
|
34727
34745
|
}
|
34728
|
-
type = type === "decimal(10,0)" || type === "decimal(10)" ? "decimal" : type;
|
34729
|
-
return this.unsigned ? `${type} unsigned` : type;
|
34730
34746
|
}
|
34731
34747
|
};
|
34732
34748
|
__publicField(MySqlDecimal, _a260, "MySqlDecimal");
|
@@ -34750,7 +34766,6 @@ var init_double = __esm({
|
|
34750
34766
|
super(name2, "number", "MySqlDouble");
|
34751
34767
|
this.config.precision = config?.precision;
|
34752
34768
|
this.config.scale = config?.scale;
|
34753
|
-
this.config.unsigned = config?.unsigned;
|
34754
34769
|
}
|
34755
34770
|
/** @internal */
|
34756
34771
|
build(table4) {
|
@@ -34763,18 +34778,15 @@ var init_double = __esm({
|
|
34763
34778
|
super(...arguments);
|
34764
34779
|
__publicField(this, "precision", this.config.precision);
|
34765
34780
|
__publicField(this, "scale", this.config.scale);
|
34766
|
-
__publicField(this, "unsigned", this.config.unsigned);
|
34767
34781
|
}
|
34768
34782
|
getSQLType() {
|
34769
|
-
let type = "";
|
34770
34783
|
if (this.precision !== void 0 && this.scale !== void 0) {
|
34771
|
-
|
34784
|
+
return `double(${this.precision},${this.scale})`;
|
34772
34785
|
} else if (this.precision === void 0) {
|
34773
|
-
|
34786
|
+
return "double";
|
34774
34787
|
} else {
|
34775
|
-
|
34788
|
+
return `double(${this.precision})`;
|
34776
34789
|
}
|
34777
|
-
return this.unsigned ? `${type} unsigned` : type;
|
34778
34790
|
}
|
34779
34791
|
};
|
34780
34792
|
__publicField(MySqlDouble, _a262, "MySqlDouble");
|
@@ -34824,23 +34836,18 @@ var init_enum2 = __esm({
|
|
34824
34836
|
});
|
34825
34837
|
|
34826
34838
|
// ../drizzle-orm/dist/mysql-core/columns/float.js
|
34827
|
-
function float(
|
34828
|
-
|
34829
|
-
return new MySqlFloatBuilder(name2, config);
|
34839
|
+
function float(name2) {
|
34840
|
+
return new MySqlFloatBuilder(name2 ?? "");
|
34830
34841
|
}
|
34831
34842
|
var _a265, _b188, MySqlFloatBuilder, _a266, _b189, MySqlFloat;
|
34832
34843
|
var init_float = __esm({
|
34833
34844
|
"../drizzle-orm/dist/mysql-core/columns/float.js"() {
|
34834
34845
|
"use strict";
|
34835
34846
|
init_entity();
|
34836
|
-
init_utils2();
|
34837
34847
|
init_common4();
|
34838
34848
|
MySqlFloatBuilder = class extends (_b188 = MySqlColumnBuilderWithAutoIncrement, _a265 = entityKind, _b188) {
|
34839
|
-
constructor(name2
|
34849
|
+
constructor(name2) {
|
34840
34850
|
super(name2, "number", "MySqlFloat");
|
34841
|
-
this.config.precision = config?.precision;
|
34842
|
-
this.config.scale = config?.scale;
|
34843
|
-
this.config.unsigned = config?.unsigned;
|
34844
34851
|
}
|
34845
34852
|
/** @internal */
|
34846
34853
|
build(table4) {
|
@@ -34849,22 +34856,8 @@ var init_float = __esm({
|
|
34849
34856
|
};
|
34850
34857
|
__publicField(MySqlFloatBuilder, _a265, "MySqlFloatBuilder");
|
34851
34858
|
MySqlFloat = class extends (_b189 = MySqlColumnWithAutoIncrement, _a266 = entityKind, _b189) {
|
34852
|
-
constructor() {
|
34853
|
-
super(...arguments);
|
34854
|
-
__publicField(this, "precision", this.config.precision);
|
34855
|
-
__publicField(this, "scale", this.config.scale);
|
34856
|
-
__publicField(this, "unsigned", this.config.unsigned);
|
34857
|
-
}
|
34858
34859
|
getSQLType() {
|
34859
|
-
|
34860
|
-
if (this.precision !== void 0 && this.scale !== void 0) {
|
34861
|
-
type += `float(${this.precision},${this.scale})`;
|
34862
|
-
} else if (this.precision === void 0) {
|
34863
|
-
type += "float";
|
34864
|
-
} else {
|
34865
|
-
type += `float(${this.precision})`;
|
34866
|
-
}
|
34867
|
-
return this.unsigned ? `${type} unsigned` : type;
|
34860
|
+
return "float";
|
34868
34861
|
}
|
34869
34862
|
};
|
34870
34863
|
__publicField(MySqlFloat, _a266, "MySqlFloat");
|
@@ -38856,8 +38849,8 @@ ${withStyle.errorWarning(
|
|
38856
38849
|
changedType = columnType.replace("bigint unsigned", "serial");
|
38857
38850
|
}
|
38858
38851
|
}
|
38859
|
-
if (columnType.
|
38860
|
-
changedType =
|
38852
|
+
if (columnType.startsWith("tinyint")) {
|
38853
|
+
changedType = "tinyint";
|
38861
38854
|
}
|
38862
38855
|
let onUpdate = void 0;
|
38863
38856
|
if (columnType.startsWith("timestamp") && typeof columnExtra !== "undefined" && columnExtra.includes("on update CURRENT_TIMESTAMP")) {
|
@@ -40083,7 +40076,7 @@ var pgSuggestions = async (db, statements) => {
|
|
40083
40076
|
}
|
40084
40077
|
}
|
40085
40078
|
}
|
40086
|
-
const stmnt = fromJson([statement], "postgresql");
|
40079
|
+
const stmnt = fromJson([statement], "postgresql", "push");
|
40087
40080
|
if (typeof stmnt !== "undefined") {
|
40088
40081
|
statementsToExecute.push(...stmnt);
|
40089
40082
|
}
|