@prisma-next/target-postgres 0.16.0-dev.2 → 0.16.0

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 (49) hide show
  1. package/dist/{control-policy-CZKdMztu.mjs → control-policy-42vVVpTL.mjs} +2 -2
  2. package/dist/{control-policy-CZKdMztu.mjs.map → control-policy-42vVVpTL.mjs.map} +1 -1
  3. package/dist/control.mjs +13 -13
  4. package/dist/control.mjs.map +1 -1
  5. package/dist/data-transform-BOWpliq8.mjs.map +1 -1
  6. package/dist/{diff-database-schema-C-hnJ5mr.mjs → diff-database-schema-CrYO0j4_.mjs} +2 -2
  7. package/dist/{diff-database-schema-C-hnJ5mr.mjs.map → diff-database-schema-CrYO0j4_.mjs.map} +1 -1
  8. package/dist/diff-database-schema.mjs +1 -1
  9. package/dist/{errors-ByDS0xJL.mjs → errors-DO-w0EUS.mjs} +6 -6
  10. package/dist/errors-DO-w0EUS.mjs.map +1 -0
  11. package/dist/errors.d.mts +3 -4
  12. package/dist/errors.d.mts.map +1 -1
  13. package/dist/errors.mjs +1 -1
  14. package/dist/issue-planner.d.mts +1 -1
  15. package/dist/issue-planner.mjs +1 -1
  16. package/dist/migration.d.mts +2 -2
  17. package/dist/migration.mjs +2 -2
  18. package/dist/{op-factory-call-DT7kdjVP.d.mts → op-factory-call-MOWnyFor.d.mts} +2 -2
  19. package/dist/{op-factory-call-DT7kdjVP.d.mts.map → op-factory-call-MOWnyFor.d.mts.map} +1 -1
  20. package/dist/{op-factory-call-DuRj7WXX.mjs → op-factory-call-rCP7TXTh.mjs} +3 -3
  21. package/dist/op-factory-call-rCP7TXTh.mjs.map +1 -0
  22. package/dist/op-factory-call.d.mts +1 -1
  23. package/dist/op-factory-call.mjs +1 -1
  24. package/dist/{planner-DPGxFcXo.mjs → planner-Bj7MTEeR.mjs} +5 -5
  25. package/dist/{planner-DPGxFcXo.mjs.map → planner-Bj7MTEeR.mjs.map} +1 -1
  26. package/dist/{planner-produced-postgres-migration-C-dwGdb2.d.mts → planner-produced-postgres-migration-DnMRtO7t.d.mts} +2 -2
  27. package/dist/planner-produced-postgres-migration-DnMRtO7t.d.mts.map +1 -0
  28. package/dist/{planner-produced-postgres-migration-CFDpqWWE.mjs → planner-produced-postgres-migration-iHdZVN5i.mjs} +2 -2
  29. package/dist/planner-produced-postgres-migration-iHdZVN5i.mjs.map +1 -0
  30. package/dist/planner-produced-postgres-migration.d.mts +1 -1
  31. package/dist/planner-produced-postgres-migration.mjs +1 -1
  32. package/dist/planner.d.mts +1 -1
  33. package/dist/planner.mjs +2 -2
  34. package/dist/{postgres-migration-DLIvzHjX.d.mts → postgres-migration-CjnEdWxh.d.mts} +4 -4
  35. package/dist/{postgres-migration-DLIvzHjX.d.mts.map → postgres-migration-CjnEdWxh.d.mts.map} +1 -1
  36. package/dist/{postgres-migration-C_OPFhIF.mjs → postgres-migration-fxgsblW1.mjs} +5 -5
  37. package/dist/postgres-migration-fxgsblW1.mjs.map +1 -0
  38. package/package.json +20 -20
  39. package/src/core/errors.ts +5 -5
  40. package/src/core/migrations/op-factory-call.ts +2 -2
  41. package/src/core/migrations/operations/data-transform.ts +1 -1
  42. package/src/core/migrations/planner-produced-postgres-migration.ts +1 -1
  43. package/src/core/migrations/postgres-migration.ts +2 -2
  44. package/src/core/migrations/runner.ts +11 -12
  45. package/dist/errors-ByDS0xJL.mjs.map +0 -1
  46. package/dist/op-factory-call-DuRj7WXX.mjs.map +0 -1
  47. package/dist/planner-produced-postgres-migration-C-dwGdb2.d.mts.map +0 -1
  48. package/dist/planner-produced-postgres-migration-CFDpqWWE.mjs.map +0 -1
  49. package/dist/postgres-migration-C_OPFhIF.mjs.map +0 -1
package/dist/control.mjs CHANGED
@@ -2,10 +2,10 @@ import { n as postgresResolveDefault } from "./default-normalizer-B9ZUiyUE.mjs";
2
2
  import { t as postgresTargetDescriptorMeta } from "./descriptor-meta-qubYaxQA.mjs";
3
3
  import { a as postgresDiffSubjectGranularity, i as postgresDiffSubjectEntityKind } from "./postgres-table-schema-node-D6LvInCe.mjs";
4
4
  import { i as PostgresDatabaseSchemaNode } from "./postgres-role-schema-node-bg32e7I-.mjs";
5
- import { n as diffPostgresSchema, r as contractToPostgresDatabaseSchemaNode } from "./diff-database-schema-C-hnJ5mr.mjs";
5
+ import { n as diffPostgresSchema, r as contractToPostgresDatabaseSchemaNode } from "./diff-database-schema-CrYO0j4_.mjs";
6
6
  import { r as renderDefaultLiteral } from "./planner-ddl-builders-BKlmGDJl.mjs";
7
7
  import { n as PostgresContractSerializer } from "./postgres-contract-view-DebHMqGR.mjs";
8
- import { t as createPostgresMigrationPlanner } from "./planner-DPGxFcXo.mjs";
8
+ import { t as createPostgresMigrationPlanner } from "./planner-Bj7MTEeR.mjs";
9
9
  import { UNBOUND_NAMESPACE_ID, coordinateKey, elementCoordinates } from "@prisma-next/framework-components/ir";
10
10
  import { blindCast } from "@prisma-next/utils/casts";
11
11
  import { buildNativeTypeExpander, runnerFailure, runnerSuccess } from "@prisma-next/family-sql/control";
@@ -88,7 +88,7 @@ var PostgresMigrationRunner = class {
88
88
  strict: options.strictVerification ?? true,
89
89
  frameworkComponents: options.frameworkComponents
90
90
  });
91
- if (!schemaVerifyResult.ok) return runnerFailure("MIGRATION.SCHEMA_VERIFY_FAILED", schemaVerifyResult.summary, {
91
+ if (!schemaVerifyResult.ok) return runnerFailure("SCHEMA_VERIFY_FAILED", schemaVerifyResult.summary, {
92
92
  why: "The resulting database schema does not satisfy the destination contract.",
93
93
  meta: { issues: schemaVerifyResult.schema.issues }
94
94
  });
@@ -192,7 +192,7 @@ var PostgresMigrationRunner = class {
192
192
  if (result.rows.length === 0) return okVoid();
193
193
  const columns = new Set(result.rows.map((row) => row.column_name));
194
194
  if (columns.has("space")) return okVoid();
195
- return runnerFailure("MIGRATION.LEGACY_MARKER_SHAPE", "Legacy marker-table shape detected on prisma_contract.marker (no `space` column). Prisma Next is in pre-1.0; the previous transitional auto-migration to the per-space-row schema has been removed. Drop `prisma_contract.marker` and re-run `dbInit` to reinitialise from a clean baseline.", { meta: {
195
+ return runnerFailure("LEGACY_MARKER_SHAPE", "Legacy marker-table shape detected on prisma_contract.marker (no `space` column). Prisma Next is in pre-1.0; the previous transitional auto-migration to the per-space-row schema has been removed. Drop `prisma_contract.marker` and re-run `dbInit` to reinitialise from a clean baseline.", { meta: {
196
196
  table: "prisma_contract.marker",
197
197
  columns: [...columns].sort()
198
198
  } });
@@ -200,7 +200,7 @@ var PostgresMigrationRunner = class {
200
200
  async runExpectationSteps(driver, steps, operation, phase) {
201
201
  for (const step of steps) {
202
202
  const result = await driver.query(step.sql, step.params ?? []);
203
- if (!this.stepResultIsTrue(result.rows)) return runnerFailure(phase === "precheck" ? "MIGRATION.PRECHECK_FAILED" : "MIGRATION.POSTCHECK_FAILED", `Operation ${operation.id} failed during ${phase}: ${step.description}`, { meta: {
203
+ if (!this.stepResultIsTrue(result.rows)) return runnerFailure(phase === "precheck" ? "PRECHECK_FAILED" : "POSTCHECK_FAILED", `Operation ${operation.id} failed during ${phase}: ${step.description}`, { meta: {
204
204
  operationId: operation.id,
205
205
  phase,
206
206
  stepDescription: step.description
@@ -212,7 +212,7 @@ var PostgresMigrationRunner = class {
212
212
  for (const step of steps) try {
213
213
  await driver.query(step.sql, step.params ?? []);
214
214
  } catch (error) {
215
- if (SqlQueryError.is(error)) return runnerFailure("MIGRATION.EXECUTION_FAILED", `Operation ${operation.id} failed during execution: ${step.description}`, {
215
+ if (SqlQueryError.is(error)) return runnerFailure("EXECUTION_FAILED", `Operation ${operation.id} failed during execution: ${step.description}`, {
216
216
  why: error.message,
217
217
  meta: {
218
218
  operationId: operation.id,
@@ -282,7 +282,7 @@ var PostgresMigrationRunner = class {
282
282
  }
283
283
  enforcePolicyCompatibility(policy, operations) {
284
284
  const allowedClasses = new Set(policy.allowedOperationClasses);
285
- for (const operation of operations) if (!allowedClasses.has(operation.operationClass)) return runnerFailure("MIGRATION.POLICY_VIOLATION", `Operation ${operation.id} has class "${operation.operationClass}" which is not allowed by policy.`, {
285
+ for (const operation of operations) if (!allowedClasses.has(operation.operationClass)) return runnerFailure("POLICY_VIOLATION", `Operation ${operation.id} has class "${operation.operationClass}" which is not allowed by policy.`, {
286
286
  why: `Policy only allows: ${policy.allowedOperationClasses.join(", ")}.`,
287
287
  meta: {
288
288
  operationId: operation.id,
@@ -295,23 +295,23 @@ var PostgresMigrationRunner = class {
295
295
  ensureMarkerCompatibility(marker, plan) {
296
296
  const origin = plan.origin ?? null;
297
297
  if (!origin) return okVoid();
298
- if (!marker) return runnerFailure("MIGRATION.MARKER_ORIGIN_MISMATCH", `Missing contract marker: expected origin storage hash ${origin.storageHash}.`, { meta: { expectedOriginStorageHash: origin.storageHash } });
299
- if (marker.storageHash !== origin.storageHash) return runnerFailure("MIGRATION.MARKER_ORIGIN_MISMATCH", `Existing contract marker (${marker.storageHash}) does not match plan origin (${origin.storageHash}).`, { meta: {
298
+ if (!marker) return runnerFailure("MARKER_ORIGIN_MISMATCH", `Missing contract marker: expected origin storage hash ${origin.storageHash}.`, { meta: { expectedOriginStorageHash: origin.storageHash } });
299
+ if (marker.storageHash !== origin.storageHash) return runnerFailure("MARKER_ORIGIN_MISMATCH", `Existing contract marker (${marker.storageHash}) does not match plan origin (${origin.storageHash}).`, { meta: {
300
300
  markerStorageHash: marker.storageHash,
301
301
  expectedOriginStorageHash: origin.storageHash
302
302
  } });
303
- if (origin.profileHash && marker.profileHash !== origin.profileHash) return runnerFailure("MIGRATION.MARKER_ORIGIN_MISMATCH", `Existing contract marker profile hash (${marker.profileHash}) does not match plan origin profile hash (${origin.profileHash}).`, { meta: {
303
+ if (origin.profileHash && marker.profileHash !== origin.profileHash) return runnerFailure("MARKER_ORIGIN_MISMATCH", `Existing contract marker profile hash (${marker.profileHash}) does not match plan origin profile hash (${origin.profileHash}).`, { meta: {
304
304
  markerProfileHash: marker.profileHash,
305
305
  expectedOriginProfileHash: origin.profileHash
306
306
  } });
307
307
  return okVoid();
308
308
  }
309
309
  ensurePlanMatchesDestinationContract(destination, contract) {
310
- if (destination.storageHash !== contract.storage.storageHash) return runnerFailure("MIGRATION.DESTINATION_CONTRACT_MISMATCH", `Plan destination storage hash (${destination.storageHash}) does not match provided contract storage hash (${contract.storage.storageHash}).`, { meta: {
310
+ if (destination.storageHash !== contract.storage.storageHash) return runnerFailure("DESTINATION_CONTRACT_MISMATCH", `Plan destination storage hash (${destination.storageHash}) does not match provided contract storage hash (${contract.storage.storageHash}).`, { meta: {
311
311
  planStorageHash: destination.storageHash,
312
312
  contractStorageHash: contract.storage.storageHash
313
313
  } });
314
- if (destination.profileHash && contract.profileHash && destination.profileHash !== contract.profileHash) return runnerFailure("MIGRATION.DESTINATION_CONTRACT_MISMATCH", `Plan destination profile hash (${destination.profileHash}) does not match provided contract profile hash (${contract.profileHash}).`, { meta: {
314
+ if (destination.profileHash && contract.profileHash && destination.profileHash !== contract.profileHash) return runnerFailure("DESTINATION_CONTRACT_MISMATCH", `Plan destination profile hash (${destination.profileHash}) does not match provided contract profile hash (${contract.profileHash}).`, { meta: {
315
315
  planProfileHash: destination.profileHash,
316
316
  contractProfileHash: contract.profileHash
317
317
  } });
@@ -336,7 +336,7 @@ var PostgresMigrationRunner = class {
336
336
  space,
337
337
  expectedFrom: existingMarker.storageHash,
338
338
  destination
339
- })) return runnerFailure("MIGRATION.MARKER_CAS_FAILURE", "Marker was modified by another process during migration execution.", { meta: {
339
+ })) return runnerFailure("MARKER_CAS_FAILURE", "Marker was modified by another process during migration execution.", { meta: {
340
340
  space,
341
341
  expectedStorageHash: existingMarker.storageHash,
342
342
  destinationStorageHash: options.plan.destination.storageHash