drizzle-kit 0.27.0 → 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 +41 -20
- package/api.mjs +41 -20
- package/bin.cjs +42 -21
- package/package.json +1 -1
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 = [];
|
@@ -17520,6 +17541,7 @@ var init_snapshotsDiffer = __esm({
|
|
17520
17541
|
jsonStatements.push(...jsonCreatedCheckConstraints);
|
17521
17542
|
jsonStatements.push(...jsonAlteredUniqueConstraints);
|
17522
17543
|
jsonStatements.push(...jsonAlterEnumsWithDroppedValues);
|
17544
|
+
jsonStatements.push(...createViews);
|
17523
17545
|
jsonStatements.push(...jsonRenamePoliciesStatements);
|
17524
17546
|
jsonStatements.push(...jsonDropPoliciesStatements);
|
17525
17547
|
jsonStatements.push(...jsonCreatePoliciesStatements);
|
@@ -17528,7 +17550,6 @@ var init_snapshotsDiffer = __esm({
|
|
17528
17550
|
jsonStatements.push(...jsonDropIndPoliciesStatements);
|
17529
17551
|
jsonStatements.push(...jsonCreateIndPoliciesStatements);
|
17530
17552
|
jsonStatements.push(...jsonAlterIndPoliciesStatements);
|
17531
|
-
jsonStatements.push(...createViews);
|
17532
17553
|
jsonStatements.push(...dropEnums);
|
17533
17554
|
jsonStatements.push(...dropSequences);
|
17534
17555
|
jsonStatements.push(...dropSchemas);
|
@@ -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)) {
|
@@ -40064,7 +40085,7 @@ var pgSuggestions = async (db, statements) => {
|
|
40064
40085
|
}
|
40065
40086
|
}
|
40066
40087
|
}
|
40067
|
-
const stmnt = fromJson([statement], "postgresql");
|
40088
|
+
const stmnt = fromJson([statement], "postgresql", "push");
|
40068
40089
|
if (typeof stmnt !== "undefined") {
|
40069
40090
|
statementsToExecute.push(...stmnt);
|
40070
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 = [];
|
@@ -17525,6 +17546,7 @@ var init_snapshotsDiffer = __esm({
|
|
17525
17546
|
jsonStatements.push(...jsonCreatedCheckConstraints);
|
17526
17547
|
jsonStatements.push(...jsonAlteredUniqueConstraints);
|
17527
17548
|
jsonStatements.push(...jsonAlterEnumsWithDroppedValues);
|
17549
|
+
jsonStatements.push(...createViews);
|
17528
17550
|
jsonStatements.push(...jsonRenamePoliciesStatements);
|
17529
17551
|
jsonStatements.push(...jsonDropPoliciesStatements);
|
17530
17552
|
jsonStatements.push(...jsonCreatePoliciesStatements);
|
@@ -17533,7 +17555,6 @@ var init_snapshotsDiffer = __esm({
|
|
17533
17555
|
jsonStatements.push(...jsonDropIndPoliciesStatements);
|
17534
17556
|
jsonStatements.push(...jsonCreateIndPoliciesStatements);
|
17535
17557
|
jsonStatements.push(...jsonAlterIndPoliciesStatements);
|
17536
|
-
jsonStatements.push(...createViews);
|
17537
17558
|
jsonStatements.push(...dropEnums);
|
17538
17559
|
jsonStatements.push(...dropSequences);
|
17539
17560
|
jsonStatements.push(...dropSchemas);
|
@@ -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)) {
|
@@ -40055,7 +40076,7 @@ var pgSuggestions = async (db, statements) => {
|
|
40055
40076
|
}
|
40056
40077
|
}
|
40057
40078
|
}
|
40058
|
-
const stmnt = fromJson([statement], "postgresql");
|
40079
|
+
const stmnt = fromJson([statement], "postgresql", "push");
|
40059
40080
|
if (typeof stmnt !== "undefined") {
|
40060
40081
|
statementsToExecute.push(...stmnt);
|
40061
40082
|
}
|
package/bin.cjs
CHANGED
@@ -6381,6 +6381,16 @@ var init_pgSchema = __esm({
|
|
6381
6381
|
var _a;
|
6382
6382
|
return `${policy4.name}--${policy4.as}--${policy4.for}--${(_a = policy4.to) == null ? void 0 : _a.join(",")}--${policy4.on}`;
|
6383
6383
|
},
|
6384
|
+
unsquashPolicyPush: (policy4) => {
|
6385
|
+
const splitted = policy4.split("--");
|
6386
|
+
return {
|
6387
|
+
name: splitted[0],
|
6388
|
+
as: splitted[1],
|
6389
|
+
for: splitted[2],
|
6390
|
+
to: splitted[3].split(","),
|
6391
|
+
on: splitted[4] !== "undefined" ? splitted[4] : void 0
|
6392
|
+
};
|
6393
|
+
},
|
6384
6394
|
squashPK: (pk) => {
|
6385
6395
|
return `${pk.columns.join(",")};${pk.name}`;
|
6386
6396
|
},
|
@@ -24729,9 +24739,9 @@ var init_sqlgenerator = __esm({
|
|
24729
24739
|
can(statement, dialect4) {
|
24730
24740
|
return statement.type === "alter_policy" && dialect4 === "postgresql";
|
24731
24741
|
}
|
24732
|
-
convert(statement) {
|
24733
|
-
const newPolicy = PgSquasher.unsquashPolicy(statement.newData);
|
24734
|
-
const oldPolicy = PgSquasher.unsquashPolicy(statement.oldData);
|
24742
|
+
convert(statement, _dialect, action) {
|
24743
|
+
const newPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(statement.newData) : PgSquasher.unsquashPolicy(statement.newData);
|
24744
|
+
const oldPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(statement.oldData) : PgSquasher.unsquashPolicy(statement.oldData);
|
24735
24745
|
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
24736
24746
|
const usingPart = newPolicy.using ? ` USING (${newPolicy.using})` : oldPolicy.using ? ` USING (${oldPolicy.using})` : "";
|
24737
24747
|
const withCheckPart = newPolicy.withCheck ? ` WITH CHECK (${newPolicy.withCheck})` : oldPolicy.withCheck ? ` WITH CHECK (${oldPolicy.withCheck})` : "";
|
@@ -25458,7 +25468,7 @@ WITH ${withCheckOption} CHECK OPTION` : "";
|
|
25458
25468
|
can(statement, dialect4) {
|
25459
25469
|
return statement.type === "drop_table" && dialect4 === "postgresql";
|
25460
25470
|
}
|
25461
|
-
convert(statement) {
|
25471
|
+
convert(statement, _d, action) {
|
25462
25472
|
const { tableName, schema: schema5, policies } = statement;
|
25463
25473
|
const tableNameWithSchema = schema5 ? `"${schema5}"."${tableName}"` : `"${tableName}"`;
|
25464
25474
|
const dropPolicyConvertor = new PgDropPolicyConvertor();
|
@@ -25466,7 +25476,7 @@ WITH ${withCheckOption} CHECK OPTION` : "";
|
|
25466
25476
|
return dropPolicyConvertor.convert({
|
25467
25477
|
type: "drop_policy",
|
25468
25478
|
tableName,
|
25469
|
-
data: PgSquasher.unsquashPolicy(p2),
|
25479
|
+
data: action === "push" ? PgSquasher.unsquashPolicyPush(p2) : PgSquasher.unsquashPolicy(p2),
|
25470
25480
|
schema: schema5
|
25471
25481
|
});
|
25472
25482
|
})) ?? [];
|
@@ -29434,8 +29444,10 @@ var init_snapshotsDiffer = __esm({
|
|
29434
29444
|
const { renamed, created: created2, deleted: deleted2 } = await policyResolver2({
|
29435
29445
|
tableName: entry.name,
|
29436
29446
|
schema: entry.schema,
|
29437
|
-
deleted: entry.policies.deleted.map(
|
29438
|
-
|
29447
|
+
deleted: entry.policies.deleted.map(
|
29448
|
+
action === "push" ? PgSquasher.unsquashPolicyPush : PgSquasher.unsquashPolicy
|
29449
|
+
),
|
29450
|
+
created: entry.policies.added.map(action === "push" ? PgSquasher.unsquashPolicyPush : PgSquasher.unsquashPolicy)
|
29439
29451
|
});
|
29440
29452
|
if (created2.length > 0) {
|
29441
29453
|
policyCreates.push({
|
@@ -29475,7 +29487,7 @@ var init_snapshotsDiffer = __esm({
|
|
29475
29487
|
(policyKey, policy4) => {
|
29476
29488
|
const rens = policyRenamesDict[`${tableValue.schema || "public"}.${tableValue.name}`] || [];
|
29477
29489
|
const newName = columnChangeFor(policyKey, rens);
|
29478
|
-
const unsquashedPolicy = PgSquasher.unsquashPolicy(policy4);
|
29490
|
+
const unsquashedPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(policy4) : PgSquasher.unsquashPolicy(policy4);
|
29479
29491
|
unsquashedPolicy.name = newName;
|
29480
29492
|
policy4 = PgSquasher.squashPolicy(unsquashedPolicy);
|
29481
29493
|
return newName;
|
@@ -29489,8 +29501,12 @@ var init_snapshotsDiffer = __esm({
|
|
29489
29501
|
const indPolicyCreates = [];
|
29490
29502
|
const indPolicyDeletes = [];
|
29491
29503
|
const { renamed: indPolicyRenames, created, deleted } = await indPolicyResolver2({
|
29492
|
-
deleted: indPolicyRes.deleted.map(
|
29493
|
-
|
29504
|
+
deleted: indPolicyRes.deleted.map(
|
29505
|
+
(t2) => action === "push" ? PgSquasher.unsquashPolicyPush(t2.values) : PgSquasher.unsquashPolicy(t2.values)
|
29506
|
+
),
|
29507
|
+
created: indPolicyRes.added.map(
|
29508
|
+
(t2) => action === "push" ? PgSquasher.unsquashPolicyPush(t2.values) : PgSquasher.unsquashPolicy(t2.values)
|
29509
|
+
)
|
29494
29510
|
});
|
29495
29511
|
if (created.length > 0) {
|
29496
29512
|
indPolicyCreates.push({
|
@@ -29766,9 +29782,9 @@ var init_snapshotsDiffer = __esm({
|
|
29766
29782
|
);
|
29767
29783
|
}
|
29768
29784
|
typedResult.alteredPolicies.forEach(({ values }) => {
|
29769
|
-
const policy4 = PgSquasher.unsquashPolicy(values);
|
29770
|
-
const newPolicy = PgSquasher.unsquashPolicy(json2.policies[policy4.name].values);
|
29771
|
-
const oldPolicy = PgSquasher.unsquashPolicy(json1.policies[policy4.name].values);
|
29785
|
+
const policy4 = action === "push" ? PgSquasher.unsquashPolicyPush(values) : PgSquasher.unsquashPolicy(values);
|
29786
|
+
const newPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(json2.policies[policy4.name].values) : PgSquasher.unsquashPolicy(json2.policies[policy4.name].values);
|
29787
|
+
const oldPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(json2.policies[policy4.name].values) : PgSquasher.unsquashPolicy(json1.policies[policy4.name].values);
|
29772
29788
|
if (newPolicy.as !== oldPolicy.as) {
|
29773
29789
|
jsonDropIndPoliciesStatements.push(
|
29774
29790
|
...prepareDropIndPolicyJsons(
|
@@ -29827,8 +29843,8 @@ var init_snapshotsDiffer = __esm({
|
|
29827
29843
|
}
|
29828
29844
|
alteredTables.forEach((it) => {
|
29829
29845
|
Object.keys(it.alteredPolicies).forEach((policyName) => {
|
29830
|
-
const newPolicy = PgSquasher.unsquashPolicy(it.alteredPolicies[policyName].__new);
|
29831
|
-
const oldPolicy = PgSquasher.unsquashPolicy(it.alteredPolicies[policyName].__old);
|
29846
|
+
const newPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(it.alteredPolicies[policyName].__new) : PgSquasher.unsquashPolicy(it.alteredPolicies[policyName].__new);
|
29847
|
+
const oldPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(it.alteredPolicies[policyName].__old) : PgSquasher.unsquashPolicy(it.alteredPolicies[policyName].__old);
|
29832
29848
|
if (newPolicy.as !== oldPolicy.as) {
|
29833
29849
|
jsonDropPoliciesStatements.push(
|
29834
29850
|
...prepareDropPolicyJsons(
|
@@ -29882,7 +29898,8 @@ var init_snapshotsDiffer = __esm({
|
|
29882
29898
|
if (policiesInPreviousState.length > 0 && policiesInCurrentState.length === 0 && !table4.isRLSEnabled) {
|
29883
29899
|
jsonDisableRLSStatements.push({ type: "disable_rls", tableName: table4.name, schema: table4.schema });
|
29884
29900
|
}
|
29885
|
-
|
29901
|
+
const wasRlsEnabled = tableInPreviousState ? tableInPreviousState.isRLSEnabled : false;
|
29902
|
+
if (table4.isRLSEnabled !== wasRlsEnabled) {
|
29886
29903
|
if (table4.isRLSEnabled) {
|
29887
29904
|
jsonEnableRLSStatements.push({ type: "enable_rls", tableName: table4.name, schema: table4.schema });
|
29888
29905
|
} else if (!table4.isRLSEnabled && policiesInCurrentState.length === 0) {
|
@@ -30009,7 +30026,11 @@ var init_snapshotsDiffer = __esm({
|
|
30009
30026
|
});
|
30010
30027
|
jsonCreatePoliciesStatements.push(...[].concat(
|
30011
30028
|
...createdTables.map(
|
30012
|
-
(it) => prepareCreatePolicyJsons(
|
30029
|
+
(it) => prepareCreatePolicyJsons(
|
30030
|
+
it.name,
|
30031
|
+
it.schema,
|
30032
|
+
Object.values(it.policies).map(action === "push" ? PgSquasher.unsquashPolicyPush : PgSquasher.unsquashPolicy)
|
30033
|
+
)
|
30013
30034
|
)
|
30014
30035
|
));
|
30015
30036
|
const createViews = [];
|
@@ -30185,6 +30206,7 @@ var init_snapshotsDiffer = __esm({
|
|
30185
30206
|
jsonStatements.push(...jsonCreatedCheckConstraints);
|
30186
30207
|
jsonStatements.push(...jsonAlteredUniqueConstraints);
|
30187
30208
|
jsonStatements.push(...jsonAlterEnumsWithDroppedValues);
|
30209
|
+
jsonStatements.push(...createViews);
|
30188
30210
|
jsonStatements.push(...jsonRenamePoliciesStatements);
|
30189
30211
|
jsonStatements.push(...jsonDropPoliciesStatements);
|
30190
30212
|
jsonStatements.push(...jsonCreatePoliciesStatements);
|
@@ -30193,7 +30215,6 @@ var init_snapshotsDiffer = __esm({
|
|
30193
30215
|
jsonStatements.push(...jsonDropIndPoliciesStatements);
|
30194
30216
|
jsonStatements.push(...jsonCreateIndPoliciesStatements);
|
30195
30217
|
jsonStatements.push(...jsonAlterIndPoliciesStatements);
|
30196
|
-
jsonStatements.push(...createViews);
|
30197
30218
|
jsonStatements.push(...dropEnums);
|
30198
30219
|
jsonStatements.push(...dropSequences);
|
30199
30220
|
jsonStatements.push(...dropSchemas);
|
@@ -30224,7 +30245,7 @@ var init_snapshotsDiffer = __esm({
|
|
30224
30245
|
}
|
30225
30246
|
return true;
|
30226
30247
|
});
|
30227
|
-
const sqlStatements = fromJson(filteredEnumsJsonStatements, "postgresql");
|
30248
|
+
const sqlStatements = fromJson(filteredEnumsJsonStatements, "postgresql", action);
|
30228
30249
|
const uniqueSqlStatements = [];
|
30229
30250
|
sqlStatements.forEach((ss) => {
|
30230
30251
|
if (!uniqueSqlStatements.includes(ss)) {
|
@@ -81253,7 +81274,7 @@ var init_pgPushUtils = __esm({
|
|
81253
81274
|
}
|
81254
81275
|
}
|
81255
81276
|
}
|
81256
|
-
const stmnt = fromJson([statement], "postgresql");
|
81277
|
+
const stmnt = fromJson([statement], "postgresql", "push");
|
81257
81278
|
if (typeof stmnt !== "undefined") {
|
81258
81279
|
statementsToExecute.push(...stmnt);
|
81259
81280
|
}
|
@@ -88963,7 +88984,7 @@ init_utils2();
|
|
88963
88984
|
var version2 = async () => {
|
88964
88985
|
const { npmVersion } = await ormCoreVersions();
|
88965
88986
|
const ormVersion = npmVersion ? `drizzle-orm: v${npmVersion}` : "";
|
88966
|
-
const envVersion = "0.27.
|
88987
|
+
const envVersion = "0.27.1-2293cf4";
|
88967
88988
|
const kitVersion = envVersion ? `v${envVersion}` : "--";
|
88968
88989
|
const versions = `drizzle-kit: ${kitVersion}
|
88969
88990
|
${ormVersion}`;
|