@prisma/orm-target-postgres 8.0.0-rc.22-dev.7 → 8.0.0-rc.22-dev.9

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.
Files changed (61) hide show
  1. package/dist/{control-policy-RIiGtzLL-dMGUsj7L.mjs → control-policy-K52VpMX0-CateWffI.mjs} +7 -3
  2. package/dist/control-policy-K52VpMX0-CateWffI.mjs.map +1 -0
  3. package/dist/{diff-database-schema-CvA43-eB-BVodpxgx.mjs → diff-database-schema-D_vOsC7_-CtLt0OwZ.mjs} +3 -3
  4. package/dist/{diff-database-schema-CvA43-eB-BVodpxgx.mjs.map → diff-database-schema-D_vOsC7_-CtLt0OwZ.mjs.map} +1 -1
  5. package/dist/{issue-planner-BUo9S9Ge.d.mts → issue-planner-CbixMGS1.d.mts} +2 -2
  6. package/dist/{issue-planner-BUo9S9Ge.d.mts.map → issue-planner-CbixMGS1.d.mts.map} +1 -1
  7. package/dist/migration-Be_iuIpn.mjs.map +1 -1
  8. package/dist/{migration-Drs_EeiM.d.mts → migration-XqRvlRWn.d.mts} +2 -2
  9. package/dist/{migration-Drs_EeiM.d.mts.map → migration-XqRvlRWn.d.mts.map} +1 -1
  10. package/dist/op-factory-call-DO-2Ul_8.d.mts +1 -0
  11. package/dist/{op-factory-call-Ek2u4dEh-CIUcdOdr.mjs → op-factory-call-DQW9c0ec-C3qv_STE.mjs} +478 -38
  12. package/dist/op-factory-call-DQW9c0ec-C3qv_STE.mjs.map +1 -0
  13. package/dist/{op-factory-call-L1gqYhhk-DMnspvjf.d.mts → op-factory-call-fPC4Yzy6-B6JHyh7J.d.mts} +80 -9
  14. package/dist/op-factory-call-fPC4Yzy6-B6JHyh7J.d.mts.map +1 -0
  15. package/dist/{pack-ClOo5FU_.d.mts → pack-BhLR51a_.d.mts} +2 -2
  16. package/dist/{pack-ClOo5FU_.d.mts.map → pack-BhLR51a_.d.mts.map} +1 -1
  17. package/dist/{planner-CXGxEHRs-DnblCRvf.mjs → planner-BsSEbzfm-BrBEb_M1.mjs} +87 -68
  18. package/dist/planner-BsSEbzfm-BrBEb_M1.mjs.map +1 -0
  19. package/dist/{planner-Bl3kIyMG.d.mts → planner-Cw5KV0_B.d.mts} +2 -2
  20. package/dist/{planner-Bl3kIyMG.d.mts.map → planner-Cw5KV0_B.d.mts.map} +1 -1
  21. package/dist/planner-produced-postgres-migration-CoX6OBqo.d.mts +1 -0
  22. package/dist/{planner-produced-postgres-migration-Cx9bERx3-DRNnR16E.d.mts → planner-produced-postgres-migration-DgUtdqVh-DEhVIDmO.d.mts} +3 -3
  23. package/dist/planner-produced-postgres-migration-DgUtdqVh-DEhVIDmO.d.mts.map +1 -0
  24. package/dist/{planner-produced-postgres-migration-rvb49AcU-Cg2CikBV.mjs → planner-produced-postgres-migration-bn60skNP-CKjpb3S_.mjs} +4 -4
  25. package/dist/{planner-produced-postgres-migration-rvb49AcU-Cg2CikBV.mjs.map → planner-produced-postgres-migration-bn60skNP-CKjpb3S_.mjs.map} +1 -1
  26. package/dist/{postgres-migration-D0tEWVZ9-tr0Nt3a2.mjs → postgres-migration-CVWCygKt-DEXT0FE_.mjs} +48 -8
  27. package/dist/postgres-migration-CVWCygKt-DEXT0FE_.mjs.map +1 -0
  28. package/dist/{postgres-migration-DNnmFBsR-BJU9865a.d.mts → postgres-migration-MVAsm-Co-CcN0UJd7.d.mts} +53 -3
  29. package/dist/postgres-migration-MVAsm-Co-CcN0UJd7.d.mts.map +1 -0
  30. package/dist/{prisma7-binding-Bb8yzr_1.d.mts → prisma7-binding-DixgLN05.d.mts} +2 -2
  31. package/dist/{prisma7-binding-Bb8yzr_1.d.mts.map → prisma7-binding-DixgLN05.d.mts.map} +1 -1
  32. package/dist/{render-ops-B0eNPFAw-BgUftmhY.mjs → render-ops-BKDfKgOJ-DmoHztdY.mjs} +3 -3
  33. package/dist/{render-ops-B0eNPFAw-BgUftmhY.mjs.map → render-ops-BKDfKgOJ-DmoHztdY.mjs.map} +1 -1
  34. package/dist/target.d.mts +11 -11
  35. package/dist/target.mjs +8 -8
  36. package/dist/target__control.mjs +30 -32
  37. package/dist/target__control.mjs.map +1 -1
  38. package/dist/target__diff-database-schema.mjs +1 -1
  39. package/dist/target__issue-planner.d.mts +1 -1
  40. package/dist/target__issue-planner.mjs +1 -1
  41. package/dist/target__migration.d.mts +2 -2
  42. package/dist/target__migration.mjs +2 -2
  43. package/dist/target__op-factory-call.d.mts +3 -3
  44. package/dist/target__op-factory-call.mjs +2 -2
  45. package/dist/target__pack.d.mts +1 -1
  46. package/dist/target__planner-produced-postgres-migration.d.mts +2 -2
  47. package/dist/target__planner-produced-postgres-migration.mjs +1 -1
  48. package/dist/target__planner.d.mts +1 -1
  49. package/dist/target__planner.mjs +2 -2
  50. package/dist/target__prisma7-binding.d.mts +1 -1
  51. package/dist/target__render-ops.mjs +1 -1
  52. package/package.json +10 -10
  53. package/dist/control-policy-RIiGtzLL-dMGUsj7L.mjs.map +0 -1
  54. package/dist/op-factory-call-D2HXLJQJ.d.mts +0 -1
  55. package/dist/op-factory-call-Ek2u4dEh-CIUcdOdr.mjs.map +0 -1
  56. package/dist/op-factory-call-L1gqYhhk-DMnspvjf.d.mts.map +0 -1
  57. package/dist/planner-CXGxEHRs-DnblCRvf.mjs.map +0 -1
  58. package/dist/planner-produced-postgres-migration-Cx9bERx3-DRNnR16E.d.mts.map +0 -1
  59. package/dist/planner-produced-postgres-migration-DRPVY4iL.d.mts +0 -1
  60. package/dist/postgres-migration-D0tEWVZ9-tr0Nt3a2.mjs.map +0 -1
  61. package/dist/postgres-migration-DNnmFBsR-BJU9865a.d.mts.map +0 -1
@@ -14,11 +14,11 @@ import { t as postgresTargetDescriptorMeta } from "./descriptor-meta-DDydgB82-Cv
14
14
  import { a as postgresDiffSubjectEntityKind, o as postgresDiffSubjectGranularity } from "./postgres-table-schema-node-nY6II-Uv-Bj-lgmSi.mjs";
15
15
  import { t as PostgresDatabaseSchemaNode } from "./postgres-role-schema-node-DuljIQWp-D6Q5JyEs.mjs";
16
16
  import { i as qualifyTableName } from "./planner-sql-checks-RKQqd_b5-CesTHuGH.mjs";
17
- import { $ as schemaContentsOf, Q as schemaBlockingObjects, et as schemaObjectsSummary, q as dropCheckConstraintId, z as SCHEMA_OBJECTS_SQL } from "./op-factory-call-Ek2u4dEh-CIUcdOdr.mjs";
18
- import { r as diffPostgresSchema } from "./diff-database-schema-CvA43-eB-BVodpxgx.mjs";
17
+ import { Q as holdingStoredValue, U as SCHEMA_OBJECTS_SQL, Z as dropCheckConstraintId, at as schemaObjectsSummary, it as schemaContentsOf, rt as schemaBlockingObjects } from "./op-factory-call-DQW9c0ec-C3qv_STE.mjs";
18
+ import { r as diffPostgresSchema } from "./diff-database-schema-D_vOsC7_-CtLt0OwZ.mjs";
19
19
  import { t as PostgresContractSerializer } from "./postgres-contract-view-pS-iTnm--BIKbQbBd.mjs";
20
- import { o as postgresContractToSchema } from "./postgres-migration-D0tEWVZ9-tr0Nt3a2.mjs";
21
- import { n as keepRowsEdit, t as createPostgresMigrationPlanner } from "./planner-CXGxEHRs-DnblCRvf.mjs";
20
+ import { o as postgresContractToSchema } from "./postgres-migration-CVWCygKt-DEXT0FE_.mjs";
21
+ import { n as postgresMarkedRemoval, r as postgresStoredValueCallClasses, t as createPostgresMigrationPlanner } from "./planner-BsSEbzfm-BrBEb_M1.mjs";
22
22
  import { n as MARKER_LOCK_SQL, t as MARKER_LOCK_KEY } from "./marker-lock-DFc1Tfv5-BkBKBRE3.mjs";
23
23
  import { _ as positionalArg, a as buildFullTextIndexAttribute, c as buildModelConstraintAttribute, f as inferPostgresPslContract, g as parseDefaultAttributeString, i as buildExtensionBlock, l as buildNativeEnumBlock, n as buildAttribute, o as buildIndexAttribute, p as namedArg, r as buildCheckAttribute, s as buildMapAttribute, t as SYNTHETIC_SPAN, v as typeArgument } from "./infer-psl-contract-Bn0Qzy4d-D9RlEL5y.mjs";
24
24
  import { dataTypeParams, requiredParamKeys, validateCodecTypeParams } from "@prisma/orm-framework/components/codec";
@@ -36,7 +36,7 @@ import { authoringTypeConstructorArguments, findAuthoringTypeConstructorCall, ge
36
36
  import { NAME_THE_PSL_SOURCE_LOSES, isPslIdentifier } from "@prisma/orm-framework/psl-parser";
37
37
  import { printSqlExpressionLiteral, sqlTextsReadBack } from "@prisma/orm-family-sql/contract/sql-expression";
38
38
  import { generatorCallsFor, inferredTypeConstructors, mapDefault, writtenTypeChoiceCall } from "@prisma/orm-family-sql/family/psl-build";
39
- import { convertedColumnOf, requiredColumnOf, requiredColumnsOfMigration, rowsHoldingValueOf, rowsHoldingValueSummary, rowsWithoutValueFailure, runnerFailure, runnerSuccess, unconvertedFieldOf } from "@prisma/orm-family-sql/family/control";
39
+ import { convertedColumnOf, keepRowsEdit, removalsOfMigration, requiredColumnOf, requiredColumnsOfMigration, rowsHoldingValueFailure, rowsHoldingValueOf, rowsWithoutValueFailure, runnerFailure, runnerSuccess, unconvertedFieldOf } from "@prisma/orm-family-sql/family/control";
40
40
  import { notOk, ok, okVoid } from "@prisma/orm-framework/utils/result";
41
41
  import { SqlSchemaVerifierBase } from "@prisma/orm-family-sql/family/ir";
42
42
  import { effectiveControlPolicy } from "@prisma/orm-framework/contract/types";
@@ -387,12 +387,12 @@ var PostgresMigrationRunner = class {
387
387
  description: step.description,
388
388
  ...ifDefined("expectation", step.expectation)
389
389
  };
390
- const holding = phase === "precheck" ? await this.rowsHoldingValue(driver, step, operation, plan.operationIndex) : void 0;
390
+ const holding = phase === "precheck" ? await this.rowsHoldingValue(driver, step, operation, plan) : void 0;
391
391
  if (holding !== void 0) return runnerFailure(code, holding.summary, {
392
392
  why: failed,
393
393
  meta: {
394
394
  failedCheck,
395
- rowsHoldingValue: holding.report
395
+ rowsHoldingValue: holding.reports
396
396
  }
397
397
  });
398
398
  return runnerFailure(code, rowsWithoutValue?.summary ?? failed, {
@@ -408,34 +408,32 @@ var PostgresMigrationRunner = class {
408
408
  }
409
409
  /**
410
410
  * Counts the rows that hold the stored value a removal check guards, as `rowsHoldingValueMeta`
411
- * marks the check. A count that fails leaves the failure without it.
411
+ * marks the check, then those of every other removal of its migration whose check fails. A count
412
+ * of the failed check that fails leaves the failure without it.
412
413
  */
413
- async rowsHoldingValue(driver, step, operation, operationIndex) {
414
+ rowsHoldingValue(driver, step, operation, plan) {
414
415
  const mark = rowsHoldingValueOf(step);
415
- const details = operation.target.details;
416
- const stored = step.params?.[0];
417
- if (mark === void 0 || details?.table === void 0) return void 0;
418
- if (typeof stored !== "string" && typeof stored !== "number") return void 0;
419
- const { table } = details;
420
- let rows;
421
- try {
422
- rows = (await driver.query(`SELECT COUNT(*)::int AS rows FROM ${qualifyTableName(details.schema, table)} WHERE ${quoteIdentifier(details.name)} = $1`, [stored])).rows[0]?.rows ?? 0;
423
- } catch {
424
- return;
425
- }
426
- return {
427
- summary: rowsHoldingValueSummary(table, details.name, stored, rows),
428
- report: {
429
- enumValue: mark.enumValue,
430
- value: stored,
431
- rows,
432
- operationIndex,
433
- keepDataEdit: keepRowsEdit({
434
- ...details,
435
- table
436
- }, mark)
437
- }
416
+ if (mark === void 0) return Promise.resolve(void 0);
417
+ const schemaOf = (marked) => {
418
+ const schema = marked.target.details?.schema;
419
+ if (schema === void 0) throw new InternalError("A stored value removal names the schema of its table");
420
+ return schema;
438
421
  };
422
+ return rowsHoldingValueFailure({
423
+ failed: {
424
+ operation,
425
+ operationIndex: plan.operationIndex,
426
+ check: step,
427
+ mark
428
+ },
429
+ others: removalsOfMigration(plan.operations, plan.edges, plan.operationIndex),
430
+ checkFails: async ({ check }) => !this.stepResultIsTrue((await driver.query(check.sql, check.params ?? [])).rows),
431
+ count: async ({ operation: counted, mark: { table, column, storedValue, path } }) => {
432
+ const holding = holdingStoredValue(column, storedValue, path);
433
+ return (await driver.query(`SELECT COUNT(*)::int AS rows FROM ${qualifyTableName(schemaOf(counted), table)} WHERE ${holding.condition}`, holding.params)).rows[0]?.rows ?? 0;
434
+ },
435
+ keepDataEdit: ({ operation: kept, mark: keptMark }) => keepRowsEdit(postgresMarkedRemoval(schemaOf(kept), keptMark), keptMark, postgresStoredValueCallClasses)
436
+ });
439
437
  }
440
438
  /**
441
439
  * Counts the rows the failed step's column has no value in, then those of every other column the