@prisma-next/target-postgres 0.13.0-dev.34 → 0.13.0-dev.36

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 (83) hide show
  1. package/dist/contract-free.d.mts +147 -14
  2. package/dist/contract-free.d.mts.map +1 -1
  3. package/dist/contract-free.mjs +3 -16
  4. package/dist/contract-free.mjs.map +1 -1
  5. package/dist/control.mjs +2 -2
  6. package/dist/ddl-QDyOSeLc.mjs +251 -0
  7. package/dist/ddl-QDyOSeLc.mjs.map +1 -0
  8. package/dist/{issue-planner-DsjB7xDj.mjs → issue-planner-CoI_0uM1.mjs} +9 -119
  9. package/dist/issue-planner-CoI_0uM1.mjs.map +1 -0
  10. package/dist/issue-planner.d.mts +2 -2
  11. package/dist/issue-planner.d.mts.map +1 -1
  12. package/dist/issue-planner.mjs +1 -1
  13. package/dist/migration.d.mts +4 -80
  14. package/dist/migration.d.mts.map +1 -1
  15. package/dist/migration.mjs +3 -3
  16. package/dist/{op-factory-call-CjR846f7.mjs → op-factory-call-B1bXWtfa.mjs} +551 -241
  17. package/dist/op-factory-call-B1bXWtfa.mjs.map +1 -0
  18. package/dist/{op-factory-call-CdtMyrlU.d.mts → op-factory-call-DmQEc3XV.d.mts} +111 -20
  19. package/dist/op-factory-call-DmQEc3XV.d.mts.map +1 -0
  20. package/dist/op-factory-call.d.mts +1 -1
  21. package/dist/op-factory-call.mjs +1 -1
  22. package/dist/{planner-_FOL4I21.mjs → planner-DS5XBhmi.mjs} +4 -4
  23. package/dist/{planner-_FOL4I21.mjs.map → planner-DS5XBhmi.mjs.map} +1 -1
  24. package/dist/{planner-produced-postgres-migration-BmCpyWLJ.mjs → planner-produced-postgres-migration-DTwCCek_.mjs} +2 -2
  25. package/dist/{planner-produced-postgres-migration-BmCpyWLJ.mjs.map → planner-produced-postgres-migration-DTwCCek_.mjs.map} +1 -1
  26. package/dist/{planner-produced-postgres-migration-wLhnJMMA.d.mts → planner-produced-postgres-migration-QqHa2C2l.d.mts} +2 -2
  27. package/dist/{planner-produced-postgres-migration-wLhnJMMA.d.mts.map → planner-produced-postgres-migration-QqHa2C2l.d.mts.map} +1 -1
  28. package/dist/planner-produced-postgres-migration.d.mts +1 -1
  29. package/dist/planner-produced-postgres-migration.mjs +1 -1
  30. package/dist/planner-sql-checks-jqUUGyQR.mjs +152 -0
  31. package/dist/planner-sql-checks-jqUUGyQR.mjs.map +1 -0
  32. package/dist/planner-sql-checks.d.mts +1 -47
  33. package/dist/planner-sql-checks.d.mts.map +1 -1
  34. package/dist/planner-sql-checks.mjs +2 -2
  35. package/dist/planner.d.mts +1 -1
  36. package/dist/planner.mjs +1 -1
  37. package/dist/{postgres-contract-serializer-CyAe8ZFv.mjs → postgres-contract-serializer-E92REOFk.mjs} +3 -3
  38. package/dist/postgres-contract-serializer-E92REOFk.mjs.map +1 -0
  39. package/dist/postgres-migration-Y4YBJqkS.d.mts +181 -0
  40. package/dist/postgres-migration-Y4YBJqkS.d.mts.map +1 -0
  41. package/dist/postgres-migration-otiaw3Ru.mjs +145 -0
  42. package/dist/postgres-migration-otiaw3Ru.mjs.map +1 -0
  43. package/dist/{postgres-schema-CTKYiTHu.mjs → postgres-schema-COGZ1ark.mjs} +71 -29
  44. package/dist/postgres-schema-COGZ1ark.mjs.map +1 -0
  45. package/dist/runtime.mjs +1 -1
  46. package/dist/table-source-BvFo7gVs.d.mts +15 -0
  47. package/dist/table-source-BvFo7gVs.d.mts.map +1 -0
  48. package/dist/types.d.mts +28 -8
  49. package/dist/types.d.mts.map +1 -1
  50. package/dist/types.mjs +1 -1
  51. package/package.json +17 -17
  52. package/src/contract-free/checks.ts +363 -0
  53. package/src/core/migrations/op-factory-call.ts +417 -94
  54. package/src/core/migrations/operations/columns.ts +175 -140
  55. package/src/core/migrations/operations/constraints.ts +79 -108
  56. package/src/core/migrations/operations/dependencies.ts +16 -14
  57. package/src/core/migrations/operations/indexes.ts +31 -28
  58. package/src/core/migrations/operations/shared.ts +2 -2
  59. package/src/core/migrations/operations/tables.ts +13 -14
  60. package/src/core/migrations/planner-recipes.ts +42 -33
  61. package/src/core/migrations/planner-sql-checks.ts +1 -172
  62. package/src/core/migrations/planner-strategies.ts +25 -73
  63. package/src/core/migrations/postgres-migration.ts +272 -7
  64. package/src/core/postgres-contract-serializer.ts +1 -1
  65. package/src/core/postgres-schema.ts +70 -52
  66. package/src/exports/contract-free.ts +21 -0
  67. package/src/exports/migration.ts +1 -22
  68. package/src/exports/planner-sql-checks.ts +0 -7
  69. package/dist/ddl-DY2R_Yqz.mjs +0 -45
  70. package/dist/ddl-DY2R_Yqz.mjs.map +0 -1
  71. package/dist/issue-planner-DsjB7xDj.mjs.map +0 -1
  72. package/dist/op-factory-call-CdtMyrlU.d.mts.map +0 -1
  73. package/dist/op-factory-call-CjR846f7.mjs.map +0 -1
  74. package/dist/planner-sql-checks-CJJtPfDH.mjs +0 -272
  75. package/dist/planner-sql-checks-CJJtPfDH.mjs.map +0 -1
  76. package/dist/postgres-contract-serializer-CyAe8ZFv.mjs.map +0 -1
  77. package/dist/postgres-migration-DLXL0GBf.d.mts +0 -77
  78. package/dist/postgres-migration-DLXL0GBf.d.mts.map +0 -1
  79. package/dist/postgres-migration-dG-J0aI8.mjs +0 -75
  80. package/dist/postgres-migration-dG-J0aI8.mjs.map +0 -1
  81. package/dist/postgres-schema-CTKYiTHu.mjs.map +0 -1
  82. package/dist/shared-jcsbXxiW.d.mts +0 -25
  83. package/dist/shared-jcsbXxiW.d.mts.map +0 -1
@@ -1,75 +0,0 @@
1
- import { l as CreateSchemaCall, n as AddColumnCall, u as CreateTableCall } from "./op-factory-call-CjR846f7.mjs";
2
- import { t as errorPostgresMigrationStackMissing } from "./errors-CUk87ByX.mjs";
3
- import { t as dataTransform } from "./data-transform-BOWpliq8.mjs";
4
- import { UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir";
5
- import { Migration } from "@prisma-next/family-sql/migration";
6
- //#region src/core/migrations/postgres-migration.ts
7
- /**
8
- * Target-owned base class for Postgres migrations.
9
- *
10
- * Fixes the `SqlMigration` generic to `PostgresPlanTargetDetails` and the
11
- * abstract `targetId` to the Postgres target-id string literal, so both
12
- * user-authored migrations and renderer-generated scaffolds (the output of
13
- * `renderCallsToTypeScript`) can extend `PostgresMigration` directly without
14
- * redeclaring target-local identity.
15
- *
16
- * Mirrors `MongoMigration` in `@prisma-next/family-mongo`: the renderer
17
- * emits `extends Migration` against a facade re-export of this class
18
- * from `@prisma-next/postgres/migration`, keeping the authoring surface
19
- * target-scoped rather than family-scoped.
20
- *
21
- * The constructor materializes a single Postgres `SqlControlAdapter` from
22
- * `stack.adapter.create(stack)` and stores it; the protected `dataTransform`
23
- * instance method forwards to the free `dataTransform` factory with that
24
- * stored adapter, so user migrations can write `this.dataTransform(...)`
25
- * without threading the adapter through every call.
26
- */
27
- var PostgresMigration = class extends Migration {
28
- targetId = "postgres";
29
- /**
30
- * Materialized Postgres control adapter, created once per migration
31
- * instance from the injected stack. `undefined` only when the migration
32
- * was instantiated without a stack (test fixtures); `dataTransform`
33
- * throws in that case to surface the misuse.
34
- */
35
- controlAdapter;
36
- constructor(stack) {
37
- super(stack);
38
- this.controlAdapter = stack?.adapter ? stack.adapter.create(stack) : void 0;
39
- }
40
- /**
41
- * Instance-method wrapper around the free `dataTransform` factory that
42
- * supplies the stored control adapter. Authors call this from inside
43
- * `get operations()`; the adapter argument is hidden from the call site.
44
- */
45
- dataTransform(contract, name, options) {
46
- if (!this.controlAdapter) throw errorPostgresMigrationStackMissing();
47
- return dataTransform(contract, name, options, this.controlAdapter);
48
- }
49
- /**
50
- * Emit a `CREATE TABLE` migration operation. Builds a typed DDL node from
51
- * the supplied options and lowers it through the stored control adapter.
52
- * Throws if no adapter is present (i.e. migration instantiated without a stack).
53
- */
54
- createTable(options) {
55
- if (!this.controlAdapter) throw errorPostgresMigrationStackMissing();
56
- return new CreateTableCall(options.schema ?? UNBOUND_NAMESPACE_ID, options.table, options.columns, options.constraints).toOp(this.controlAdapter);
57
- }
58
- /**
59
- * Emit a `CREATE SCHEMA` migration operation. Builds a typed DDL node from
60
- * the supplied options and lowers it through the stored control adapter.
61
- * Throws if no adapter is present (i.e. migration instantiated without a stack).
62
- */
63
- createSchema(options) {
64
- if (!this.controlAdapter) throw errorPostgresMigrationStackMissing();
65
- return new CreateSchemaCall(options.schema).toOp(this.controlAdapter);
66
- }
67
- addColumn(options) {
68
- if (!this.controlAdapter) throw errorPostgresMigrationStackMissing();
69
- return new AddColumnCall(options.schema ?? UNBOUND_NAMESPACE_ID, options.table, options.column).toOp(this.controlAdapter);
70
- }
71
- };
72
- //#endregion
73
- export { PostgresMigration as t };
74
-
75
- //# sourceMappingURL=postgres-migration-dG-J0aI8.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"postgres-migration-dG-J0aI8.mjs","names":["SqlMigration"],"sources":["../src/core/migrations/postgres-migration.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { SqlControlAdapter } from '@prisma-next/family-sql/control-adapter';\nimport { Migration as SqlMigration } from '@prisma-next/family-sql/migration';\nimport type { ControlStack } from '@prisma-next/framework-components/control';\nimport { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { DdlColumn, DdlTableConstraint } from '@prisma-next/sql-relational-core/ast';\nimport { errorPostgresMigrationStackMissing } from '../errors';\nimport { AddColumnCall, CreateSchemaCall, CreateTableCall } from './op-factory-call';\nimport { type DataTransformOptions, dataTransform } from './operations/data-transform';\nimport type { PostgresPlanTargetDetails } from './planner-target-details';\n\n/**\n * Target-owned base class for Postgres migrations.\n *\n * Fixes the `SqlMigration` generic to `PostgresPlanTargetDetails` and the\n * abstract `targetId` to the Postgres target-id string literal, so both\n * user-authored migrations and renderer-generated scaffolds (the output of\n * `renderCallsToTypeScript`) can extend `PostgresMigration` directly without\n * redeclaring target-local identity.\n *\n * Mirrors `MongoMigration` in `@prisma-next/family-mongo`: the renderer\n * emits `extends Migration` against a facade re-export of this class\n * from `@prisma-next/postgres/migration`, keeping the authoring surface\n * target-scoped rather than family-scoped.\n *\n * The constructor materializes a single Postgres `SqlControlAdapter` from\n * `stack.adapter.create(stack)` and stores it; the protected `dataTransform`\n * instance method forwards to the free `dataTransform` factory with that\n * stored adapter, so user migrations can write `this.dataTransform(...)`\n * without threading the adapter through every call.\n */\nexport abstract class PostgresMigration extends SqlMigration<\n PostgresPlanTargetDetails,\n 'postgres'\n> {\n readonly targetId = 'postgres' as const;\n\n /**\n * Materialized Postgres control adapter, created once per migration\n * instance from the injected stack. `undefined` only when the migration\n * was instantiated without a stack (test fixtures); `dataTransform`\n * throws in that case to surface the misuse.\n */\n protected readonly controlAdapter: SqlControlAdapter<'postgres'> | undefined;\n\n constructor(stack?: ControlStack<'sql', 'postgres'>) {\n super(stack);\n // The descriptor `create()` is typed as the wider `ControlAdapterInstance`;\n // the Postgres descriptor concretely returns a `SqlControlAdapter<'postgres'>`,\n // so the cast holds for any Postgres-target stack assembled at runtime.\n this.controlAdapter = stack?.adapter\n ? (stack.adapter.create(stack) as SqlControlAdapter<'postgres'>)\n : undefined;\n }\n\n /**\n * Instance-method wrapper around the free `dataTransform` factory that\n * supplies the stored control adapter. Authors call this from inside\n * `get operations()`; the adapter argument is hidden from the call site.\n */\n protected dataTransform<TContract extends Contract<SqlStorage>>(\n contract: TContract,\n name: string,\n options: DataTransformOptions,\n ): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return dataTransform(contract, name, options, this.controlAdapter);\n }\n\n /**\n * Emit a `CREATE TABLE` migration operation. Builds a typed DDL node from\n * the supplied options and lowers it through the stored control adapter.\n * Throws if no adapter is present (i.e. migration instantiated without a stack).\n */\n protected createTable(options: {\n readonly schema?: string;\n readonly table: string;\n readonly ifNotExists?: boolean;\n readonly columns: readonly DdlColumn[];\n readonly constraints?: readonly DdlTableConstraint[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new CreateTableCall(\n options.schema ?? UNBOUND_NAMESPACE_ID,\n options.table,\n options.columns,\n options.constraints,\n ).toOp(this.controlAdapter);\n }\n\n /**\n * Emit a `CREATE SCHEMA` migration operation. Builds a typed DDL node from\n * the supplied options and lowers it through the stored control adapter.\n * Throws if no adapter is present (i.e. migration instantiated without a stack).\n */\n protected createSchema(options: {\n readonly schema: string;\n readonly ifNotExists?: boolean;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new CreateSchemaCall(options.schema).toOp(this.controlAdapter);\n }\n\n protected addColumn(options: {\n readonly schema?: string;\n readonly table: string;\n readonly column: DdlColumn;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new AddColumnCall(\n options.schema ?? UNBOUND_NAMESPACE_ID,\n options.table,\n options.column,\n ).toOp(this.controlAdapter);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,IAAsB,oBAAtB,cAAgDA,UAG9C;CACA,WAAoB;;;;;;;CAQpB;CAEA,YAAY,OAAyC;EACnD,MAAM,KAAK;EAIX,KAAK,iBAAiB,OAAO,UACxB,MAAM,QAAQ,OAAO,KAAK,IAC3B,KAAA;CACN;;;;;;CAOA,cACE,UACA,MACA,SAC+D;EAC/D,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,cAAc,UAAU,MAAM,SAAS,KAAK,cAAc;CACnE;;;;;;CAOA,YAAsB,SAM4C;EAChE,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,IAAI,gBACT,QAAQ,UAAU,sBAClB,QAAQ,OACR,QAAQ,SACR,QAAQ,WACV,CAAC,CAAC,KAAK,KAAK,cAAc;CAC5B;;;;;;CAOA,aAAuB,SAG2C;EAChE,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,IAAI,iBAAiB,QAAQ,MAAM,CAAC,CAAC,KAAK,KAAK,cAAc;CACtE;CAEA,UAAoB,SAI8C;EAChE,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,IAAI,cACT,QAAQ,UAAU,sBAClB,QAAQ,OACR,QAAQ,MACV,CAAC,CAAC,KAAK,KAAK,cAAc;CAC5B;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"postgres-schema-CTKYiTHu.mjs","names":[],"sources":["../src/core/postgres-schema.ts"],"sourcesContent":["import {\n freezeNode,\n NamespaceBase,\n UNBOUND_NAMESPACE_ID,\n} from '@prisma-next/framework-components/ir';\nimport {\n type SqlNamespaceTablesInput,\n type SqlStorage,\n StorageTable,\n type StorageTableInput,\n StorageValueSet,\n type StorageValueSetInput,\n} from '@prisma-next/sql-contract/types';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { escapeLiteral } from './sql-utils';\n\nexport interface PostgresSchemaInput {\n readonly id: string;\n readonly entries: Readonly<Record<string, Readonly<Record<string, unknown>>>>;\n}\n\n/**\n * Postgres target `Namespace` concretion — a Postgres schema (`CREATE\n * SCHEMA …`). Each Postgres `SqlStorage` carries a\n * `namespaces: Record<NamespaceId, PostgresSchema>` map populated by\n * the Postgres PSL interpreter from `namespace { … }` AST buckets.\n *\n * `entries` holds entity-kind maps (`table`, `valueSet`). Qualifier\n * emission is the rendering seam: DDL / SQL emission asks the namespace\n * for its qualifier (`\"<schema>\"`) or for a qualified table name\n * (`\"<schema>\".\"<table>\"`) and consumes the result polymorphically.\n * The unbound singleton below overrides these methods to elide the\n * prefix entirely — call sites stay polymorphic and never branch on\n * `id === UNBOUND_NAMESPACE_ID`.\n */\nexport class PostgresSchema extends NamespaceBase {\n /**\n * Stable singleton reference for the late-bound slot. Materialised\n * lazily below the singleton subclass declaration so the static\n * initialiser sees the subclass before assigning. Consumers always\n * reach for `PostgresSchema.unbound` (or `PostgresUnboundSchema.instance`\n * — same identity).\n */\n static unbound: PostgresUnboundSchema;\n\n declare readonly kind: 'schema';\n readonly id: string;\n readonly entries: Readonly<Record<string, Readonly<Record<string, unknown>>>>;\n\n constructor(input: PostgresSchemaInput) {\n super();\n this.id = input.id;\n\n const carried: Record<string, Readonly<Record<string, unknown>>> = {};\n let table: Readonly<Record<string, StorageTable>> = Object.freeze({});\n let valueSet: Readonly<Record<string, StorageValueSet>> | undefined;\n for (const [kind, rawMap] of Object.entries(input.entries)) {\n if (kind === 'table') {\n const tableMap: Record<string, StorageTable> = {};\n for (const [name, v] of Object.entries(\n blindCast<\n Record<string, StorageTableInput>,\n 'entries[table] holds StorageTableInput by construction'\n >(rawMap),\n )) {\n tableMap[name] = new StorageTable(v);\n }\n table = Object.freeze(tableMap);\n } else if (kind === 'valueSet') {\n const vsMap: Record<string, StorageValueSet> = {};\n for (const [name, v] of Object.entries(\n blindCast<\n Record<string, StorageValueSetInput>,\n 'entries[valueSet] holds StorageValueSetInput by construction'\n >(rawMap),\n )) {\n vsMap[name] = new StorageValueSet(v);\n }\n if (Object.keys(vsMap).length > 0) {\n valueSet = Object.freeze(vsMap);\n }\n } else {\n carried[kind] = Object.freeze(rawMap);\n }\n }\n\n this.entries = Object.freeze({\n ...carried,\n table,\n ...ifDefined('valueSet', valueSet),\n });\n Object.defineProperty(this, 'kind', {\n value: 'schema',\n writable: false,\n enumerable: false,\n configurable: true,\n });\n freezeNode(this);\n }\n\n get table(): Readonly<Record<string, StorageTable>> {\n return this.entries['table'] ?? Object.freeze({});\n }\n\n get valueSet(): Readonly<Record<string, StorageValueSet>> | undefined {\n return this.entries['valueSet'] as Readonly<Record<string, StorageValueSet>> | undefined;\n }\n\n /**\n * The bare schema qualifier as it would appear in a rendered SQL\n * fragment (already quoted). The unbound-schema singleton overrides\n * this to return `''`.\n */\n qualifier(): string {\n return `\"${this.id}\"`;\n }\n\n /**\n * Qualify a table name with the schema prefix\n * (`\"<schema>\".\"<table>\"`). The unbound-schema singleton overrides\n * this to emit just `\"<table>\"` so the resolved DDL is unqualified\n * and `search_path` decides where the object lands at runtime.\n */\n qualifyTable(tableName: string): string {\n return `\"${this.id}\".\"${tableName}\"`;\n }\n\n /**\n * Render a SQL string-literal containing the qualified-name form\n * suitable for `to_regclass(...)` arguments (e.g. `'\"public\".\"user\"'`).\n * The unbound singleton overrides this to elide the schema prefix\n * (`'\"user\"'`) so `search_path` resolves the object at runtime.\n */\n regclassLiteral(name: string): string {\n return `'${escapeLiteral(this.qualifyTable(name))}'`;\n }\n\n /**\n * Render a SQL expression that evaluates to this namespace's schema\n * name at runtime, ready to drop into a `WHERE table_schema = …` /\n * `WHERE n.nspname = …` clause. Named schemas emit a quoted SQL\n * literal (`'public'`); the unbound singleton overrides this to emit\n * `current_schema()` so catalog queries match whichever schema the\n * connection's `search_path` resolved at runtime.\n */\n schemaSqlExpression(): string {\n return `'${escapeLiteral(this.id)}'`;\n }\n\n /**\n * The bare schema name a DDL planner should target when emitting\n * statements that need to identify this namespace in the live\n * database (e.g. `CREATE TABLE \"<ddlSchemaName>\".\"<table>\" …`,\n * catalog filters, planner conflict lookups). Named schemas resolve\n * to their own id. The `PostgresUnboundSchema` singleton inherits\n * this and returns `UNBOUND_NAMESPACE_ID` — callers that dispatch\n * through `qualifyTableName` / `toRegclassLiteral` route through the\n * polymorphic `PostgresUnboundSchema` overrides and produce\n * unqualified (search-path-resolved) output automatically.\n */\n ddlSchemaName(_storage: SqlStorage): string {\n return this.id;\n }\n}\n\n/**\n * Singleton subclass for the reserved sentinel namespace id\n * (`UNBOUND_NAMESPACE_ID`) — the late-bound Postgres slot whose binding\n * the connection's `search_path` resolves at runtime. Overrides\n * qualifier emission to elide the schema prefix; call sites that consume\n * `qualifier()` / `qualifyTable()` get unqualified output without\n * branching on the namespace id.\n *\n * This is the target-side materialization of \"the framework provides\n * affordances; targets implement specifics\": the framework names the\n * sentinel; Postgres decides what late-bound means here (the table\n * name, naked — the schema is supplied by the live connection's\n * `search_path`).\n *\n * `ddlSchemaName` is inherited from `PostgresSchema` and returns\n * `UNBOUND_NAMESPACE_ID`. Downstream helpers (`qualifyTableName`,\n * `toRegclassLiteral`) route through the polymorphic factory and\n * produce unqualified output automatically.\n */\nexport class PostgresUnboundSchema extends PostgresSchema {\n static readonly instance: PostgresUnboundSchema = new PostgresUnboundSchema();\n\n constructor(input?: PostgresSchemaInput) {\n super(input ?? { id: UNBOUND_NAMESPACE_ID, entries: { table: {} } });\n }\n\n override qualifier(): string {\n return '';\n }\n\n override qualifyTable(tableName: string): string {\n return `\"${tableName}\"`;\n }\n\n override schemaSqlExpression(): string {\n return 'current_schema()';\n }\n}\n\nPostgresSchema.unbound = PostgresUnboundSchema.instance;\n\n/**\n * Narrow an arbitrary namespace (or `undefined`) to `PostgresSchema`\n * so callers can dispatch to the polymorphic emission methods without\n * branching at the call site. Uses the structural `kind` discriminator\n * (`'schema'`) rather than `instanceof` so the check survives realm /\n * bundle / hot-reload boundaries — matching the rest of the IR's\n * narrowing convention. `PostgresUnboundSchema` passes through because\n * it inherits the same `kind: 'schema'` from `PostgresSchema`.\n */\nexport function isPostgresSchema(ns: unknown): ns is PostgresSchema {\n return (ns as { kind?: unknown } | null | undefined)?.kind === 'schema';\n}\n\n/**\n * Target-supplied `Namespace` factory the Postgres target plumbs\n * through `defineContract({ createNamespace })` and the SQL PSL\n * interpreter. Returns the unbound singleton for the framework\n * sentinel and a fresh `PostgresSchema` for any other coordinate.\n *\n * The factory has no per-call state — every named id deterministically\n * maps to a distinct schema instance — so callers can pass it through\n * by reference and trust the resulting `SqlStorage.namespaces` map to\n * be value-stable for a given input set.\n */\nexport function postgresCreateNamespace(input: SqlNamespaceTablesInput): PostgresSchema {\n const schemaInput: PostgresSchemaInput = {\n id: input.id,\n entries: {\n ...input.entries,\n table: input.entries['table'] ?? {},\n },\n };\n if (input.id === UNBOUND_NAMESPACE_ID) {\n return new PostgresUnboundSchema(schemaInput);\n }\n return new PostgresSchema(schemaInput);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoCA,IAAa,iBAAb,cAAoC,cAAc;;;;;;;;CAQhD,OAAO;CAGP;CACA;CAEA,YAAY,OAA4B;EACtC,MAAM;EACN,KAAK,KAAK,MAAM;EAEhB,MAAM,UAA6D,CAAC;EACpE,IAAI,QAAgD,OAAO,OAAO,CAAC,CAAC;EACpE,IAAI;EACJ,KAAK,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,MAAM,OAAO,GACvD,IAAI,SAAS,SAAS;GACpB,MAAM,WAAyC,CAAC;GAChD,KAAK,MAAM,CAAC,MAAM,MAAM,OAAO,QAC7B,UAGE,MAAM,CACV,GACE,SAAS,QAAQ,IAAI,aAAa,CAAC;GAErC,QAAQ,OAAO,OAAO,QAAQ;EAChC,OAAO,IAAI,SAAS,YAAY;GAC9B,MAAM,QAAyC,CAAC;GAChD,KAAK,MAAM,CAAC,MAAM,MAAM,OAAO,QAC7B,UAGE,MAAM,CACV,GACE,MAAM,QAAQ,IAAI,gBAAgB,CAAC;GAErC,IAAI,OAAO,KAAK,KAAK,CAAC,CAAC,SAAS,GAC9B,WAAW,OAAO,OAAO,KAAK;EAElC,OACE,QAAQ,QAAQ,OAAO,OAAO,MAAM;EAIxC,KAAK,UAAU,OAAO,OAAO;GAC3B,GAAG;GACH;GACA,GAAG,UAAU,YAAY,QAAQ;EACnC,CAAC;EACD,OAAO,eAAe,MAAM,QAAQ;GAClC,OAAO;GACP,UAAU;GACV,YAAY;GACZ,cAAc;EAChB,CAAC;EACD,WAAW,IAAI;CACjB;CAEA,IAAI,QAAgD;EAClD,OAAO,KAAK,QAAQ,YAAY,OAAO,OAAO,CAAC,CAAC;CAClD;CAEA,IAAI,WAAkE;EACpE,OAAO,KAAK,QAAQ;CACtB;;;;;;CAOA,YAAoB;EAClB,OAAO,IAAI,KAAK,GAAG;CACrB;;;;;;;CAQA,aAAa,WAA2B;EACtC,OAAO,IAAI,KAAK,GAAG,KAAK,UAAU;CACpC;;;;;;;CAQA,gBAAgB,MAAsB;EACpC,OAAO,IAAI,cAAc,KAAK,aAAa,IAAI,CAAC,EAAE;CACpD;;;;;;;;;CAUA,sBAA8B;EAC5B,OAAO,IAAI,cAAc,KAAK,EAAE,EAAE;CACpC;;;;;;;;;;;;CAaA,cAAc,UAA8B;EAC1C,OAAO,KAAK;CACd;AACF;;;;;;;;;;;;;;;;;;;;AAqBA,IAAa,wBAAb,MAAa,8BAA8B,eAAe;CACxD,OAAgB,WAAkC,IAAI,sBAAsB;CAE5E,YAAY,OAA6B;EACvC,MAAM,SAAS;GAAE,IAAI;GAAsB,SAAS,EAAE,OAAO,CAAC,EAAE;EAAE,CAAC;CACrE;CAEA,YAA6B;EAC3B,OAAO;CACT;CAEA,aAAsB,WAA2B;EAC/C,OAAO,IAAI,UAAU;CACvB;CAEA,sBAAuC;EACrC,OAAO;CACT;AACF;AAEA,eAAe,UAAU,sBAAsB;;;;;;;;;;AAW/C,SAAgB,iBAAiB,IAAmC;CAClE,OAAQ,IAA8C,SAAS;AACjE;;;;;;;;;;;;AAaA,SAAgB,wBAAwB,OAAgD;CACtF,MAAM,cAAmC;EACvC,IAAI,MAAM;EACV,SAAS;GACP,GAAG,MAAM;GACT,OAAO,MAAM,QAAQ,YAAY,CAAC;EACpC;CACF;CACA,IAAI,MAAM,OAAO,sBACf,OAAO,IAAI,sBAAsB,WAAW;CAE9C,OAAO,IAAI,eAAe,WAAW;AACvC"}
@@ -1,25 +0,0 @@
1
- import { t as PostgresPlanTargetDetails } from "./planner-target-details-CIY6tLeo.mjs";
2
- import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
3
- import { ReferentialAction } from "@prisma-next/sql-contract/types";
4
-
5
- //#region src/core/migrations/operations/shared.d.ts
6
- type Op = SqlMigrationPlanOperation<PostgresPlanTargetDetails>;
7
- /**
8
- * Literal-args shape for a foreign key definition. `references.schema`
9
- * carries the target table's namespace (schema) coordinate so the rendered
10
- * DDL qualifies the REFERENCES clause correctly for cross-schema FKs.
11
- */
12
- interface ForeignKeySpec {
13
- readonly name: string;
14
- readonly columns: readonly string[];
15
- readonly references: {
16
- readonly schema: string;
17
- readonly table: string;
18
- readonly columns: readonly string[];
19
- };
20
- readonly onDelete?: ReferentialAction;
21
- readonly onUpdate?: ReferentialAction;
22
- }
23
- //#endregion
24
- export { Op as n, ForeignKeySpec as t };
25
- //# sourceMappingURL=shared-jcsbXxiW.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shared-jcsbXxiW.d.mts","names":[],"sources":["../src/core/migrations/operations/shared.ts"],"mappings":";;;;;KAMY,EAAA,GAAK,yBAAyB,CAAC,yBAAA;;;;AAmCJ;;UATtB,cAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;EAAA,SACA,UAAA;IAAA,SACE,MAAA;IAAA,SACA,KAAA;IAAA,SACA,OAAA;EAAA;EAAA,SAEF,QAAA,GAAW,iBAAA;EAAA,SACX,QAAA,GAAW,iBAAiB;AAAA"}