@prisma-next/target-postgres 0.14.0-dev.55 → 0.14.0-dev.56

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 (117) hide show
  1. package/dist/{authoring-BBIGcFZM.mjs → authoring-WkqG_MkU.mjs} +38 -6
  2. package/dist/authoring-WkqG_MkU.mjs.map +1 -0
  3. package/dist/contract-free.d.mts +27 -2
  4. package/dist/contract-free.d.mts.map +1 -1
  5. package/dist/contract-free.mjs +3 -3
  6. package/dist/{control-policy-DievMCOV.mjs → control-policy-BtOZBVxL.mjs} +38 -13
  7. package/dist/control-policy-BtOZBVxL.mjs.map +1 -0
  8. package/dist/control.mjs +6 -6
  9. package/dist/{ddl-D5j4JiAB.mjs → ddl-B-krEXY1.mjs} +18 -4
  10. package/dist/{ddl-D5j4JiAB.mjs.map → ddl-B-krEXY1.mjs.map} +1 -1
  11. package/dist/ddl.d.mts +2 -2
  12. package/dist/ddl.mjs +2 -2
  13. package/dist/{descriptor-meta-C-tyS25s.mjs → descriptor-meta-BOcKPaLE.mjs} +4 -3
  14. package/dist/descriptor-meta-BOcKPaLE.mjs.map +1 -0
  15. package/dist/{diff-database-schema-ff3ioNtK.mjs → diff-database-schema-CWb-jeLy.mjs} +19 -11
  16. package/dist/diff-database-schema-CWb-jeLy.mjs.map +1 -0
  17. package/dist/diff-database-schema.d.mts +1 -1
  18. package/dist/diff-database-schema.d.mts.map +1 -1
  19. package/dist/diff-database-schema.mjs +1 -1
  20. package/dist/issue-planner.d.mts +1 -1
  21. package/dist/issue-planner.d.mts.map +1 -1
  22. package/dist/issue-planner.mjs +1 -1
  23. package/dist/migration.d.mts +2 -2
  24. package/dist/migration.mjs +2 -2
  25. package/dist/{nodes-Dh__NS58.mjs → nodes-B815pj_X.mjs} +34 -2
  26. package/dist/{nodes-Dh__NS58.mjs.map → nodes-B815pj_X.mjs.map} +1 -1
  27. package/dist/{nodes-CSkPX3rI.d.mts → nodes-BtQyZha6.d.mts} +29 -3
  28. package/dist/nodes-BtQyZha6.d.mts.map +1 -0
  29. package/dist/{op-factory-call-Dt-Jx5JS.d.mts → op-factory-call-D6_7-7Vc.d.mts} +24 -2
  30. package/dist/{op-factory-call-Dt-Jx5JS.d.mts.map → op-factory-call-D6_7-7Vc.d.mts.map} +1 -1
  31. package/dist/{op-factory-call-DZWTTjKM.mjs → op-factory-call-DxNNKUeZ.mjs} +99 -4
  32. package/dist/op-factory-call-DxNNKUeZ.mjs.map +1 -0
  33. package/dist/op-factory-call.d.mts +1 -1
  34. package/dist/op-factory-call.mjs +1 -1
  35. package/dist/pack.d.mts +29 -2
  36. package/dist/pack.d.mts.map +1 -1
  37. package/dist/pack.mjs +1 -1
  38. package/dist/{planner-DWQYPxP8.mjs → planner-BryLk0Ie.mjs} +80 -24
  39. package/dist/planner-BryLk0Ie.mjs.map +1 -0
  40. package/dist/{planner-produced-postgres-migration-Ch1L8RiV.mjs → planner-produced-postgres-migration-BLJH1zIc.mjs} +2 -2
  41. package/dist/{planner-produced-postgres-migration-Ch1L8RiV.mjs.map → planner-produced-postgres-migration-BLJH1zIc.mjs.map} +1 -1
  42. package/dist/{planner-produced-postgres-migration-C0a7I1-e.d.mts → planner-produced-postgres-migration-CGifB6VH.d.mts} +2 -2
  43. package/dist/{planner-produced-postgres-migration-C0a7I1-e.d.mts.map → planner-produced-postgres-migration-CGifB6VH.d.mts.map} +1 -1
  44. package/dist/planner-produced-postgres-migration.d.mts +1 -1
  45. package/dist/planner-produced-postgres-migration.mjs +1 -1
  46. package/dist/{planner-sql-checks-D8Q5ck4o.mjs → planner-sql-checks-AXoxB1Jl.mjs} +2 -2
  47. package/dist/{planner-sql-checks-D8Q5ck4o.mjs.map → planner-sql-checks-AXoxB1Jl.mjs.map} +1 -1
  48. package/dist/planner-sql-checks.mjs +1 -1
  49. package/dist/planner.d.mts +23 -6
  50. package/dist/planner.d.mts.map +1 -1
  51. package/dist/planner.mjs +2 -2
  52. package/dist/{postgres-contract-view-C-By7rOB.mjs → postgres-contract-view-Dg-N7KA7.mjs} +4 -3
  53. package/dist/postgres-contract-view-Dg-N7KA7.mjs.map +1 -0
  54. package/dist/{postgres-database-schema-node-UpzA0Ug5.d.mts → postgres-database-schema-node-CfdTY-Qs.d.mts} +18 -3
  55. package/dist/postgres-database-schema-node-CfdTY-Qs.d.mts.map +1 -0
  56. package/dist/{postgres-migration-D3XACWKM.mjs → postgres-migration-BahMHTbj.mjs} +3 -3
  57. package/dist/{postgres-migration-D3XACWKM.mjs.map → postgres-migration-BahMHTbj.mjs.map} +1 -1
  58. package/dist/{postgres-migration-DFaxuRyI.d.mts → postgres-migration-cyBe2Ee0.d.mts} +2 -2
  59. package/dist/{postgres-migration-DFaxuRyI.d.mts.map → postgres-migration-cyBe2Ee0.d.mts.map} +1 -1
  60. package/dist/{postgres-table-schema-node-BZWWEo7B.mjs → postgres-role-schema-node-BiSTCTNg.mjs} +4 -69
  61. package/dist/postgres-role-schema-node-BiSTCTNg.mjs.map +1 -0
  62. package/dist/{postgres-schema-9vFZLwGo.d.mts → postgres-schema-CU4gF6QZ.d.mts} +30 -2
  63. package/dist/postgres-schema-CU4gF6QZ.d.mts.map +1 -0
  64. package/dist/{postgres-schema-DcG72fcT.mjs → postgres-schema-DTLA_aRi.mjs} +41 -2
  65. package/dist/postgres-schema-DTLA_aRi.mjs.map +1 -0
  66. package/dist/postgres-table-schema-node-9FCtCUz2.mjs +153 -0
  67. package/dist/postgres-table-schema-node-9FCtCUz2.mjs.map +1 -0
  68. package/dist/{resolve-ddl-schema-BOtCoeKV.mjs → resolve-ddl-schema-Ca88Tg6W.mjs} +2 -2
  69. package/dist/{resolve-ddl-schema-BOtCoeKV.mjs.map → resolve-ddl-schema-Ca88Tg6W.mjs.map} +1 -1
  70. package/dist/rls-canonicalize.d.mts +19 -1
  71. package/dist/rls-canonicalize.d.mts.map +1 -0
  72. package/dist/rls-canonicalize.mjs +2 -2
  73. package/dist/runtime.d.mts.map +1 -1
  74. package/dist/runtime.mjs +1 -1
  75. package/dist/schema-ir-annotations.mjs +1 -1
  76. package/dist/types.d.mts +3 -3
  77. package/dist/types.mjs +4 -3
  78. package/dist/{canonicalize-Bn3BM1Cn.mjs → wire-name-rHHtr1h0.mjs} +31 -2
  79. package/dist/wire-name-rHHtr1h0.mjs.map +1 -0
  80. package/package.json +20 -20
  81. package/src/contract-free/ddl.ts +26 -0
  82. package/src/core/authoring.ts +44 -1
  83. package/src/core/ddl/nodes.ts +48 -1
  84. package/src/core/descriptor-meta.ts +2 -0
  85. package/src/core/entity-kinds.ts +11 -0
  86. package/src/core/migrations/contract-to-postgres-database-schema-node.ts +9 -0
  87. package/src/core/migrations/control-policy.ts +31 -1
  88. package/src/core/migrations/diff-database-schema.ts +1 -0
  89. package/src/core/migrations/issue-planner.ts +49 -4
  90. package/src/core/migrations/op-factory-call.ts +81 -1
  91. package/src/core/migrations/operations/rls.ts +82 -1
  92. package/src/core/migrations/planner.ts +110 -26
  93. package/src/core/postgres-contract-serializer.ts +7 -1
  94. package/src/core/postgres-rls-enablement.ts +34 -0
  95. package/src/core/postgres-schema.ts +19 -3
  96. package/src/core/postgres-validators.ts +6 -0
  97. package/src/core/rls/wire-name.ts +33 -0
  98. package/src/core/schema-ir/postgres-table-schema-node.ts +25 -3
  99. package/src/exports/contract-free.ts +4 -0
  100. package/src/exports/ddl.ts +2 -0
  101. package/src/exports/rls-canonicalize.ts +1 -0
  102. package/src/exports/types.ts +4 -0
  103. package/dist/authoring-BBIGcFZM.mjs.map +0 -1
  104. package/dist/canonicalize-Bn3BM1Cn.mjs.map +0 -1
  105. package/dist/control-policy-DievMCOV.mjs.map +0 -1
  106. package/dist/descriptor-meta-C-tyS25s.mjs.map +0 -1
  107. package/dist/diff-database-schema-ff3ioNtK.mjs.map +0 -1
  108. package/dist/nodes-CSkPX3rI.d.mts.map +0 -1
  109. package/dist/op-factory-call-DZWTTjKM.mjs.map +0 -1
  110. package/dist/planner-DWQYPxP8.mjs.map +0 -1
  111. package/dist/postgres-contract-view-C-By7rOB.mjs.map +0 -1
  112. package/dist/postgres-database-schema-node-UpzA0Ug5.d.mts.map +0 -1
  113. package/dist/postgres-schema-9vFZLwGo.d.mts.map +0 -1
  114. package/dist/postgres-schema-DcG72fcT.mjs.map +0 -1
  115. package/dist/postgres-table-schema-node-BZWWEo7B.mjs.map +0 -1
  116. package/dist/schema-node-kinds-ClScchhi.mjs +0 -76
  117. package/dist/schema-node-kinds-ClScchhi.mjs.map +0 -1
package/dist/control.mjs CHANGED
@@ -1,11 +1,11 @@
1
1
  import { t as PostgresNativeEnum } from "./postgres-native-enum-xdiqmBf_.mjs";
2
- import { t as postgresTargetDescriptorMeta } from "./descriptor-meta-C-tyS25s.mjs";
3
- import { n as postgresDiffSubjectEntityKind, r as postgresDiffSubjectGranularity } from "./schema-node-kinds-ClScchhi.mjs";
4
- import { a as PostgresDatabaseSchemaNode } from "./postgres-table-schema-node-BZWWEo7B.mjs";
5
- import { n as diffPostgresSchema, r as contractToPostgresDatabaseSchemaNode } from "./diff-database-schema-ff3ioNtK.mjs";
2
+ import { t as postgresTargetDescriptorMeta } from "./descriptor-meta-BOcKPaLE.mjs";
3
+ import { i as postgresDiffSubjectGranularity, r as postgresDiffSubjectEntityKind } from "./postgres-table-schema-node-9FCtCUz2.mjs";
4
+ import { i as PostgresDatabaseSchemaNode } from "./postgres-role-schema-node-BiSTCTNg.mjs";
5
+ import { n as diffPostgresSchema, r as contractToPostgresDatabaseSchemaNode } from "./diff-database-schema-CWb-jeLy.mjs";
6
6
  import { r as renderDefaultLiteral } from "./planner-ddl-builders-B8Nn6nHN.mjs";
7
- import { n as PostgresContractSerializer } from "./postgres-contract-view-C-By7rOB.mjs";
8
- import { t as createPostgresMigrationPlanner } from "./planner-DWQYPxP8.mjs";
7
+ import { n as PostgresContractSerializer } from "./postgres-contract-view-Dg-N7KA7.mjs";
8
+ import { t as createPostgresMigrationPlanner } from "./planner-BryLk0Ie.mjs";
9
9
  import { UNBOUND_NAMESPACE_ID, coordinateKey, elementCoordinates, isPlainRecord } 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";
@@ -1,6 +1,6 @@
1
1
  import { v as PG_TEXT_CODEC_ID } from "./codec-ids-C_-Hj6bL.mjs";
2
- import { c as PostgresTableSource, i as postgresCreateNamespace } from "./postgres-schema-DcG72fcT.mjs";
3
- import { a as PostgresCreateSchema, c as PostgresDropPolicy, i as PostgresCreatePolicy, n as DropDefaultAction, o as PostgresCreateTable, r as PostgresAlterTable, t as AddColumnAction } from "./nodes-Dh__NS58.mjs";
2
+ import { i as postgresCreateNamespace, l as PostgresTableSource } from "./postgres-schema-DTLA_aRi.mjs";
3
+ import { a as PostgresCreatePolicy, i as PostgresAlterTable, l as PostgresDisableRowLevelSecurity, n as DropDefaultAction, o as PostgresCreateSchema, r as PostgresAlterPolicyRename, s as PostgresCreateTable, t as AddColumnAction, u as PostgresDropPolicy } from "./nodes-B815pj_X.mjs";
4
4
  import { cfExpr, cfTable, exprSelect } from "@prisma-next/sql-relational-core/contract-free";
5
5
  //#region src/contract-free/checks.ts
6
6
  /**
@@ -302,7 +302,21 @@ function createPolicy(options) {
302
302
  function dropPolicy(options) {
303
303
  return new PostgresDropPolicy(options);
304
304
  }
305
+ /**
306
+ * Build a Postgres `ALTER POLICY … RENAME TO` DDL node.
307
+ * Identifiers (`schema`, `table`, `name`, `newName`) are quoted by the renderer.
308
+ */
309
+ function alterPolicyRename(options) {
310
+ return new PostgresAlterPolicyRename(options);
311
+ }
312
+ /**
313
+ * Build a Postgres `ALTER TABLE … DISABLE ROW LEVEL SECURITY` DDL node.
314
+ * Identifiers (`schema`, `table`) are quoted by the renderer.
315
+ */
316
+ function disableRowLevelSecurity(options) {
317
+ return new PostgresDisableRowLevelSecurity(options);
318
+ }
305
319
  //#endregion
306
- export { rlsPolicyExistsAst as _, createTable as a, tablePrimaryKeyAst as b, columnDefaultAst as c, columnTypeAst as d, constraintExistsAst as f, rlsEnabledAst as g, noNullValuesAst as h, createSchema as i, columnExistsAst as l, indexExistsAst as m, alterTable as n, dropDefaultAction as o, extensionExistsAst as p, createPolicy as r, dropPolicy as s, addColumnAction as t, columnNullabilityAst as u, tableExistsAst as v, toRegclass as x, tableIsEmptyAst as y };
320
+ export { toRegclass as C, tablePrimaryKeyAst as S, noNullValuesAst as _, createSchema as a, tableExistsAst as b, dropDefaultAction as c, columnExistsAst as d, columnNullabilityAst as f, indexExistsAst as g, extensionExistsAst as h, createPolicy as i, dropPolicy as l, constraintExistsAst as m, alterPolicyRename as n, createTable as o, columnTypeAst as p, alterTable as r, disableRowLevelSecurity as s, addColumnAction as t, columnDefaultAst as u, rlsEnabledAst as v, tableIsEmptyAst as x, rlsPolicyExistsAst as y };
307
321
 
308
- //# sourceMappingURL=ddl-D5j4JiAB.mjs.map
322
+ //# sourceMappingURL=ddl-B-krEXY1.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ddl-D5j4JiAB.mjs","names":[],"sources":["../src/contract-free/checks.ts","../src/contract-free/ddl.ts"],"sourcesContent":["import type { SelectAst } from '@prisma-next/sql-relational-core/ast';\nimport {\n type CfExpr,\n type CfExprSelectQuery,\n cfExpr,\n cfTable,\n exprSelect,\n} from '@prisma-next/sql-relational-core/contract-free';\nimport { PostgresTableSource } from '../core/ast/table-source';\nimport { PG_TEXT_CODEC_ID } from '../core/codec-ids';\nimport { postgresCreateNamespace } from '../core/postgres-schema';\n\n/**\n * `to_regclass($1)` with the qualified table name bound as a text parameter.\n * Thin vocabulary wrapper over the core `cfExpr.fn` helper — the target\n * supplies only the template and the codec'd operand.\n */\nexport function toRegclass(qualifiedName: string): CfExpr {\n return cfExpr.fn({\n method: 'to_regclass',\n template: 'to_regclass({{self}})',\n self: cfExpr.param(qualifiedName, PG_TEXT_CODEC_ID),\n returns: { codecId: PG_TEXT_CODEC_ID, nullable: true },\n });\n}\n\nexport interface TableExistsCheckBuilder {\n tableAbsent(): SelectAst;\n tablePresent(): SelectAst;\n}\n\n/**\n * Typed builder for the migration planner's table-existence checks. Produces\n * FROM-less `SELECT to_regclass($1) IS [NOT] NULL AS \"result\"` ASTs with the\n * qualified table name bound as a text parameter — never inlined into the SQL.\n *\n * `schema` is a namespace coordinate: the framework `__unbound__` sentinel\n * elides the qualifier (search_path decides at runtime); any other id\n * qualifies as `\"schema\".\"table\"`.\n */\nexport function tableExistsAst(schema: string, table: string): TableExistsCheckBuilder {\n const qualified = postgresCreateNamespace({ id: schema, entries: { table: {} } }).qualifyTable(\n table,\n );\n const regclass = toRegclass(qualified);\n return {\n tableAbsent: () => exprSelect().project('result', regclass.isNull()).build(),\n tablePresent: () => exprSelect().project('result', regclass.isNotNull()).build(),\n };\n}\n\nexport interface ConstraintExistsCheckBuilder {\n constraintPresent(): SelectAst;\n constraintAbsent(): SelectAst;\n}\n\n/**\n * Typed builder for the migration planner's constraint-existence checks.\n * Produces `SELECT [NOT ]EXISTS (SELECT 1 FROM pg_constraint c JOIN\n * pg_namespace n ON n.oid = c.connamespace WHERE c.conname = $1 AND\n * n.nspname = $2 [AND c.conrelid = to_regclass($3)]) AS \"result\"` with the\n * constraint name, schema name, and qualified table name bound as text\n * parameters.\n *\n * When `table` is omitted the check matches by name + schema across all\n * tables. Pass `table` to scope the check to a single table (prevents false\n * matches on identically-named constraints in different tables). `schema`\n * is a namespace coordinate: the `__unbound__` sentinel compares `nspname`\n * against `current_schema()` instead of a bound parameter.\n */\nexport function constraintExistsAst(options: {\n readonly constraintName: string;\n readonly schema: string;\n readonly table?: string;\n}): ConstraintExistsCheckBuilder {\n const namespace = postgresCreateNamespace({ id: options.schema, entries: { table: {} } });\n const conditions = [\n cfExpr.columnRef('c', 'conname').eqParam(options.constraintName, PG_TEXT_CODEC_ID),\n cfExpr.columnRef('n', 'nspname').eqExpr(namespace.schemaFilterExpression()),\n ];\n if (options.table !== undefined) {\n conditions.push(\n cfExpr.columnRef('c', 'conrelid').eqExpr(toRegclass(namespace.qualifyTable(options.table))),\n );\n }\n const inner = (): CfExprSelectQuery =>\n exprSelect()\n .from(cfTable('pg_constraint', 'c'))\n .join(\n cfTable('pg_namespace', 'n'),\n cfExpr.columnRef('n', 'oid').eqExpr(cfExpr.columnRef('c', 'connamespace')),\n )\n .project('one', cfExpr.lit(1))\n .where(cfExpr.allOf(conditions));\n return {\n constraintPresent: () => exprSelect().project('result', cfExpr.exists(inner())).build(),\n constraintAbsent: () => exprSelect().project('result', cfExpr.notExists(inner())).build(),\n };\n}\n\nfunction checkNamespace(schema: string) {\n return postgresCreateNamespace({ id: schema, entries: { table: {} } });\n}\n\nfunction informationSchemaColumns(): PostgresTableSource {\n return new PostgresTableSource({ schema: 'information_schema', name: 'columns' });\n}\n\nfunction infoSchemaColumnConditions(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n}): CfExpr[] {\n return [\n cfExpr\n .identifierRef('table_schema')\n .eqExpr(checkNamespace(options.schema).schemaFilterExpression()),\n cfExpr.identifierRef('table_name').eqParam(options.table, PG_TEXT_CODEC_ID),\n cfExpr.identifierRef('column_name').eqParam(options.column, PG_TEXT_CODEC_ID),\n ];\n}\n\nfunction infoSchemaColumnQuery(conditions: ReadonlyArray<CfExpr>): CfExprSelectQuery {\n return exprSelect()\n .from(informationSchemaColumns())\n .project('one', cfExpr.lit(1))\n .where(cfExpr.allOf(conditions));\n}\n\nexport interface ColumnExistsCheckBuilder {\n columnPresent(): SelectAst;\n columnAbsent(): SelectAst;\n}\n\n/**\n * Typed builder for column-existence checks over\n * `information_schema.columns`, with schema, table, and column names bound\n * as text parameters.\n */\nexport function columnExistsAst(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n}): ColumnExistsCheckBuilder {\n const inner = () => infoSchemaColumnQuery(infoSchemaColumnConditions(options));\n return {\n columnPresent: () => exprSelect().project('result', cfExpr.exists(inner())).build(),\n columnAbsent: () => exprSelect().project('result', cfExpr.notExists(inner())).build(),\n };\n}\n\n/**\n * Typed nullability check: EXISTS over `information_schema.columns` with\n * `is_nullable` compared against the bound `'YES'` / `'NO'` marker.\n */\nexport function columnNullabilityAst(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n readonly nullable: boolean;\n}): SelectAst {\n const conditions = [\n ...infoSchemaColumnConditions(options),\n cfExpr.identifierRef('is_nullable').eqParam(options.nullable ? 'YES' : 'NO', PG_TEXT_CODEC_ID),\n ];\n return exprSelect()\n .project('result', cfExpr.exists(infoSchemaColumnQuery(conditions)))\n .build();\n}\n\nexport interface ColumnDefaultCheckBuilder {\n defaultPresent(): SelectAst;\n defaultAbsent(): SelectAst;\n noDefault(): SelectAst;\n}\n\n/**\n * Typed default-presence checks over `information_schema.columns`.\n * `defaultPresent` / `defaultAbsent` assert the column row exists with a\n * non-null / null `column_default`; `noDefault` is the NOT EXISTS variant\n * (also true when the column row is missing entirely).\n */\nexport function columnDefaultAst(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n}): ColumnDefaultCheckBuilder {\n const withDefault = () =>\n infoSchemaColumnQuery([\n ...infoSchemaColumnConditions(options),\n cfExpr.identifierRef('column_default').isNotNull(),\n ]);\n const withoutDefault = () =>\n infoSchemaColumnQuery([\n ...infoSchemaColumnConditions(options),\n cfExpr.identifierRef('column_default').isNull(),\n ]);\n return {\n defaultPresent: () => exprSelect().project('result', cfExpr.exists(withDefault())).build(),\n defaultAbsent: () => exprSelect().project('result', cfExpr.exists(withoutDefault())).build(),\n noDefault: () => exprSelect().project('result', cfExpr.notExists(withDefault())).build(),\n };\n}\n\n/**\n * Typed column-type check: EXISTS over `pg_attribute` joined to `pg_class`\n * and `pg_namespace`, comparing `format_type(a.atttypid, a.atttypmod)`\n * against the bound expected display type and excluding dropped columns.\n */\nexport function columnTypeAst(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n readonly expectedType: string;\n}): SelectAst {\n const formatType = cfExpr.fn({\n method: 'format_type',\n template: 'format_type({{self}}, {{arg0}})',\n self: cfExpr.columnRef('a', 'atttypid'),\n args: [cfExpr.columnRef('a', 'atttypmod')],\n returns: { codecId: PG_TEXT_CODEC_ID, nullable: false },\n });\n const inner = exprSelect()\n .from(cfTable('pg_attribute', 'a'))\n .join(\n cfTable('pg_class', 'c'),\n cfExpr.columnRef('c', 'oid').eqExpr(cfExpr.columnRef('a', 'attrelid')),\n )\n .join(\n cfTable('pg_namespace', 'n'),\n cfExpr.columnRef('n', 'oid').eqExpr(cfExpr.columnRef('c', 'relnamespace')),\n )\n .project('one', cfExpr.lit(1))\n .where(\n cfExpr.allOf([\n cfExpr\n .columnRef('n', 'nspname')\n .eqExpr(checkNamespace(options.schema).schemaFilterExpression()),\n cfExpr.columnRef('c', 'relname').eqParam(options.table, PG_TEXT_CODEC_ID),\n cfExpr.columnRef('a', 'attname').eqParam(options.column, PG_TEXT_CODEC_ID),\n formatType.eqParam(options.expectedType, PG_TEXT_CODEC_ID),\n cfExpr.columnRef('a', 'attisdropped').not(),\n ]),\n );\n return exprSelect().project('result', cfExpr.exists(inner)).build();\n}\n\nexport interface TablePrimaryKeyCheckBuilder {\n pkPresent(): SelectAst;\n pkAbsent(): SelectAst;\n}\n\n/**\n * Typed primary-key existence check over `pg_index` joined to `pg_class`\n * and `pg_namespace`, with a LEFT JOIN on the index relation so an\n * optional `constraintName` can scope the match to a named constraint.\n */\nexport function tablePrimaryKeyAst(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraintName?: string;\n}): TablePrimaryKeyCheckBuilder {\n const conditions = [\n cfExpr\n .columnRef('n', 'nspname')\n .eqExpr(checkNamespace(options.schema).schemaFilterExpression()),\n cfExpr.columnRef('c', 'relname').eqParam(options.table, PG_TEXT_CODEC_ID),\n cfExpr.columnRef('i', 'indisprimary'),\n ];\n if (options.constraintName !== undefined) {\n conditions.push(\n cfExpr.columnRef('c2', 'relname').eqParam(options.constraintName, PG_TEXT_CODEC_ID),\n );\n }\n const inner = () =>\n exprSelect()\n .from(cfTable('pg_index', 'i'))\n .join(\n cfTable('pg_class', 'c'),\n cfExpr.columnRef('c', 'oid').eqExpr(cfExpr.columnRef('i', 'indrelid')),\n )\n .join(\n cfTable('pg_namespace', 'n'),\n cfExpr.columnRef('n', 'oid').eqExpr(cfExpr.columnRef('c', 'relnamespace')),\n )\n .leftJoin(\n cfTable('pg_class', 'c2'),\n cfExpr.columnRef('c2', 'oid').eqExpr(cfExpr.columnRef('i', 'indexrelid')),\n )\n .project('one', cfExpr.lit(1))\n .where(cfExpr.allOf(conditions));\n return {\n pkPresent: () => exprSelect().project('result', cfExpr.exists(inner())).build(),\n pkAbsent: () => exprSelect().project('result', cfExpr.notExists(inner())).build(),\n };\n}\n\n/**\n * Typed emptiness check: NOT EXISTS over the user table itself with\n * `LIMIT 1`. The table is addressed through the namespace's polymorphic\n * `tableSource` (qualified for named schemas, bare for the unbound slot).\n */\nexport function tableIsEmptyAst(schema: string, table: string): SelectAst {\n const inner = exprSelect()\n .from(checkNamespace(schema).tableSource(table))\n .project('one', cfExpr.lit(1))\n .limit(1);\n return exprSelect().project('result', cfExpr.notExists(inner)).build();\n}\n\n/**\n * Typed no-NULL-values data check used by `SET NOT NULL` prechecks:\n * NOT EXISTS over the user table where the column IS NULL.\n */\nexport function noNullValuesAst(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n}): SelectAst {\n const inner = exprSelect()\n .from(checkNamespace(options.schema).tableSource(options.table))\n .project('one', cfExpr.lit(1))\n .where(cfExpr.identifierRef(options.column).isNull());\n return exprSelect().project('result', cfExpr.notExists(inner)).build();\n}\n\nexport interface ExtensionExistsCheckBuilder {\n extensionPresent(): SelectAst;\n extensionAbsent(): SelectAst;\n}\n\n/**\n * Typed extension existence check over `pg_extension`, with the extension\n * name bound as a text parameter.\n */\nexport function extensionExistsAst(extensionName: string): ExtensionExistsCheckBuilder {\n const inner = () =>\n exprSelect()\n .from(cfTable('pg_extension'))\n .project('one', cfExpr.lit(1))\n .where(cfExpr.identifierRef('extname').eqParam(extensionName, PG_TEXT_CODEC_ID));\n return {\n extensionPresent: () => exprSelect().project('result', cfExpr.exists(inner())).build(),\n extensionAbsent: () => exprSelect().project('result', cfExpr.notExists(inner())).build(),\n };\n}\n\nexport interface RlsPolicyExistsCheckBuilder {\n policyPresent(): SelectAst;\n policyAbsent(): SelectAst;\n}\n\n/**\n * Typed RLS-policy existence check over `pg_policies`, with schema, table,\n * and policy names bound as text parameters (never inlined). The `schema`\n * coordinate is the resolved live-database schema name (e.g. `'public'`),\n * compared against `pg_policies.schemaname` as a bound parameter.\n */\nexport function rlsPolicyExistsAst(options: {\n readonly schema: string;\n readonly table: string;\n readonly policyName: string;\n}): RlsPolicyExistsCheckBuilder {\n const inner = () =>\n exprSelect()\n .from(cfTable('pg_policies'))\n .project('one', cfExpr.lit(1))\n .where(\n cfExpr.allOf([\n cfExpr.identifierRef('schemaname').eqParam(options.schema, PG_TEXT_CODEC_ID),\n cfExpr.identifierRef('tablename').eqParam(options.table, PG_TEXT_CODEC_ID),\n cfExpr.identifierRef('policyname').eqParam(options.policyName, PG_TEXT_CODEC_ID),\n ]),\n );\n return {\n policyPresent: () => exprSelect().project('result', cfExpr.exists(inner())).build(),\n policyAbsent: () => exprSelect().project('result', cfExpr.notExists(inner())).build(),\n };\n}\n\nexport interface RlsEnabledCheckBuilder {\n rlsEnabled(): SelectAst;\n rlsDisabled(): SelectAst;\n}\n\n/**\n * Typed row-level-security enabled check over `pg_class` joined to\n * `pg_namespace`, comparing `pg_class.relrowsecurity` against the expected\n * boolean. Schema and table names are bound as text parameters.\n */\nexport function rlsEnabledAst(schema: string, table: string): RlsEnabledCheckBuilder {\n const inner = (enabled: boolean) =>\n exprSelect()\n .from(cfTable('pg_class', 'c'))\n .join(\n cfTable('pg_namespace', 'n'),\n cfExpr.columnRef('n', 'oid').eqExpr(cfExpr.columnRef('c', 'relnamespace')),\n )\n .project('one', cfExpr.lit(1))\n .where(\n cfExpr.allOf([\n cfExpr.columnRef('n', 'nspname').eqParam(schema, PG_TEXT_CODEC_ID),\n cfExpr.columnRef('c', 'relname').eqParam(table, PG_TEXT_CODEC_ID),\n enabled\n ? cfExpr.columnRef('c', 'relrowsecurity')\n : cfExpr.columnRef('c', 'relrowsecurity').not(),\n ]),\n );\n return {\n rlsEnabled: () =>\n exprSelect()\n .project('result', cfExpr.exists(inner(true)))\n .build(),\n rlsDisabled: () =>\n exprSelect()\n .project('result', cfExpr.exists(inner(false)))\n .build(),\n };\n}\n\nexport interface IndexExistsCheckBuilder {\n indexPresent(): SelectAst;\n indexAbsent(): SelectAst;\n}\n\n/**\n * Typed index existence check riding the same `to_regclass` vocabulary as\n * `tableExistsAst`, with the qualified index name bound as a text parameter.\n */\nexport function indexExistsAst(schema: string, indexName: string): IndexExistsCheckBuilder {\n const regclass = toRegclass(checkNamespace(schema).qualifyTable(indexName));\n return {\n indexPresent: () => exprSelect().project('result', regclass.isNotNull()).build(),\n indexAbsent: () => exprSelect().project('result', regclass.isNull()).build(),\n };\n}\n","import type { DdlColumn, DdlTableConstraint } from '@prisma-next/sql-relational-core/ast';\nimport {\n AddColumnAction,\n type AnyAlterTableAction,\n DropDefaultAction,\n PostgresAlterTable,\n PostgresCreatePolicy,\n PostgresCreateSchema,\n PostgresCreateTable,\n PostgresDropPolicy,\n type RlsPolicyOperation,\n} from '../core/ddl/nodes';\n\n/**\n * Build a Postgres `CREATE TABLE` query node.\n *\n * Pass `constraints` for table-level composite primary keys, foreign keys, and\n * unique constraints — use the {@link PrimaryKeyConstraint}, {@link ForeignKeyConstraint},\n * and {@link UniqueConstraint} classes from `@prisma-next/sql-relational-core/ast`.\n *\n * Precondition: identifiers (`table`, `schema`, column names/types) are\n * emitted to SQL verbatim — they are not quoted or escaped, so callers must\n * pass pre-trusted values (e.g. fixed control-plane identifiers). String-literal\n * default values, by contrast, are single-quote-escaped (embedded `'` doubled)\n * by the renderer. Identifier quoting for untrusted identifiers is added when\n * the migration planner adopts this lowering path.\n */\nexport function createTable(options: {\n readonly table: string;\n readonly schema?: string;\n readonly ifNotExists?: boolean;\n readonly columns: readonly DdlColumn[];\n readonly constraints?: readonly DdlTableConstraint[];\n}): PostgresCreateTable {\n return new PostgresCreateTable(options);\n}\n\n/**\n * Build a Postgres `CREATE SCHEMA` query node. See {@link createTable} for the\n * pre-trusted-identifier precondition.\n */\nexport function createSchema(options: {\n readonly schema: string;\n readonly ifNotExists?: boolean;\n}): PostgresCreateSchema {\n return new PostgresCreateSchema(options);\n}\n\n/**\n * Build an `ADD COLUMN` action for use inside {@link alterTable}.\n * The column is a structured `DdlColumn` so codec-encoded defaults flow\n * through the adapter's `pgRenderDdlColumn` → `pgRenderDdlColumnDefault` path.\n */\nexport function addColumnAction(column: DdlColumn): AddColumnAction {\n return new AddColumnAction(column);\n}\n\n/**\n * Build a `DROP DEFAULT` action (`ALTER COLUMN \"<name>\" DROP DEFAULT`) for\n * use inside {@link alterTable}. The renderer quotes the column name.\n */\nexport function dropDefaultAction(columnName: string): DropDefaultAction {\n return new DropDefaultAction(columnName);\n}\n\n/**\n * Build a Postgres `ALTER TABLE` query node carrying one or more actions.\n * See {@link addColumnAction} / {@link dropDefaultAction} for building actions.\n */\nexport function alterTable(options: {\n readonly table: string;\n readonly schema?: string;\n readonly actions: readonly AnyAlterTableAction[];\n}): PostgresAlterTable {\n return new PostgresAlterTable(options);\n}\n\n/**\n * Build a Postgres `CREATE POLICY` DDL node.\n *\n * Identifiers (`schema`, `table`, `name`) are quoted by the renderer.\n * `using` and `withCheck` are emitted verbatim as predicate SQL — callers\n * must supply safe, pre-validated SQL expressions.\n */\nexport function createPolicy(options: {\n readonly schema: string;\n readonly table: string;\n readonly name: string;\n readonly permissive: boolean;\n readonly operation: RlsPolicyOperation;\n readonly roles: readonly string[];\n readonly using?: string;\n readonly withCheck?: string;\n}): PostgresCreatePolicy {\n return new PostgresCreatePolicy(options);\n}\n\n/**\n * Build a Postgres `DROP POLICY` DDL node.\n * Identifiers (`schema`, `table`, `name`) are quoted by the renderer.\n */\nexport function dropPolicy(options: {\n readonly schema: string;\n readonly table: string;\n readonly name: string;\n}): PostgresDropPolicy {\n return new PostgresDropPolicy(options);\n}\n"],"mappings":";;;;;;;;;;AAiBA,SAAgB,WAAW,eAA+B;CACxD,OAAO,OAAO,GAAG;EACf,QAAQ;EACR,UAAU;EACV,MAAM,OAAO,MAAM,eAAe,gBAAgB;EAClD,SAAS;GAAE,SAAS;GAAkB,UAAU;EAAK;CACvD,CAAC;AACH;;;;;;;;;;AAgBA,SAAgB,eAAe,QAAgB,OAAwC;CAIrF,MAAM,WAAW,WAHC,wBAAwB;EAAE,IAAI;EAAQ,SAAS,EAAE,OAAO,CAAC,EAAE;CAAE,CAAC,CAAC,CAAC,aAChF,KAEkC,CAAC;CACrC,OAAO;EACL,mBAAmB,WAAW,CAAC,CAAC,QAAQ,UAAU,SAAS,OAAO,CAAC,CAAC,CAAC,MAAM;EAC3E,oBAAoB,WAAW,CAAC,CAAC,QAAQ,UAAU,SAAS,UAAU,CAAC,CAAC,CAAC,MAAM;CACjF;AACF;;;;;;;;;;;;;;;AAqBA,SAAgB,oBAAoB,SAIH;CAC/B,MAAM,YAAY,wBAAwB;EAAE,IAAI,QAAQ;EAAQ,SAAS,EAAE,OAAO,CAAC,EAAE;CAAE,CAAC;CACxF,MAAM,aAAa,CACjB,OAAO,UAAU,KAAK,SAAS,CAAC,CAAC,QAAQ,QAAQ,gBAAgB,gBAAgB,GACjF,OAAO,UAAU,KAAK,SAAS,CAAC,CAAC,OAAO,UAAU,uBAAuB,CAAC,CAC5E;CACA,IAAI,QAAQ,UAAU,KAAA,GACpB,WAAW,KACT,OAAO,UAAU,KAAK,UAAU,CAAC,CAAC,OAAO,WAAW,UAAU,aAAa,QAAQ,KAAK,CAAC,CAAC,CAC5F;CAEF,MAAM,cACJ,WAAW,CAAC,CACT,KAAK,QAAQ,iBAAiB,GAAG,CAAC,CAAC,CACnC,KACC,QAAQ,gBAAgB,GAAG,GAC3B,OAAO,UAAU,KAAK,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;;;AASA,SAAgB,aAAa,SASJ;CACvB,OAAO,IAAI,qBAAqB,OAAO;AACzC;;;;;AAMA,SAAgB,WAAW,SAIJ;CACrB,OAAO,IAAI,mBAAmB,OAAO;AACvC"}
1
+ {"version":3,"file":"ddl-B-krEXY1.mjs","names":[],"sources":["../src/contract-free/checks.ts","../src/contract-free/ddl.ts"],"sourcesContent":["import type { SelectAst } from '@prisma-next/sql-relational-core/ast';\nimport {\n type CfExpr,\n type CfExprSelectQuery,\n cfExpr,\n cfTable,\n exprSelect,\n} from '@prisma-next/sql-relational-core/contract-free';\nimport { PostgresTableSource } from '../core/ast/table-source';\nimport { PG_TEXT_CODEC_ID } from '../core/codec-ids';\nimport { postgresCreateNamespace } from '../core/postgres-schema';\n\n/**\n * `to_regclass($1)` with the qualified table name bound as a text parameter.\n * Thin vocabulary wrapper over the core `cfExpr.fn` helper — the target\n * supplies only the template and the codec'd operand.\n */\nexport function toRegclass(qualifiedName: string): CfExpr {\n return cfExpr.fn({\n method: 'to_regclass',\n template: 'to_regclass({{self}})',\n self: cfExpr.param(qualifiedName, PG_TEXT_CODEC_ID),\n returns: { codecId: PG_TEXT_CODEC_ID, nullable: true },\n });\n}\n\nexport interface TableExistsCheckBuilder {\n tableAbsent(): SelectAst;\n tablePresent(): SelectAst;\n}\n\n/**\n * Typed builder for the migration planner's table-existence checks. Produces\n * FROM-less `SELECT to_regclass($1) IS [NOT] NULL AS \"result\"` ASTs with the\n * qualified table name bound as a text parameter — never inlined into the SQL.\n *\n * `schema` is a namespace coordinate: the framework `__unbound__` sentinel\n * elides the qualifier (search_path decides at runtime); any other id\n * qualifies as `\"schema\".\"table\"`.\n */\nexport function tableExistsAst(schema: string, table: string): TableExistsCheckBuilder {\n const qualified = postgresCreateNamespace({ id: schema, entries: { table: {} } }).qualifyTable(\n table,\n );\n const regclass = toRegclass(qualified);\n return {\n tableAbsent: () => exprSelect().project('result', regclass.isNull()).build(),\n tablePresent: () => exprSelect().project('result', regclass.isNotNull()).build(),\n };\n}\n\nexport interface ConstraintExistsCheckBuilder {\n constraintPresent(): SelectAst;\n constraintAbsent(): SelectAst;\n}\n\n/**\n * Typed builder for the migration planner's constraint-existence checks.\n * Produces `SELECT [NOT ]EXISTS (SELECT 1 FROM pg_constraint c JOIN\n * pg_namespace n ON n.oid = c.connamespace WHERE c.conname = $1 AND\n * n.nspname = $2 [AND c.conrelid = to_regclass($3)]) AS \"result\"` with the\n * constraint name, schema name, and qualified table name bound as text\n * parameters.\n *\n * When `table` is omitted the check matches by name + schema across all\n * tables. Pass `table` to scope the check to a single table (prevents false\n * matches on identically-named constraints in different tables). `schema`\n * is a namespace coordinate: the `__unbound__` sentinel compares `nspname`\n * against `current_schema()` instead of a bound parameter.\n */\nexport function constraintExistsAst(options: {\n readonly constraintName: string;\n readonly schema: string;\n readonly table?: string;\n}): ConstraintExistsCheckBuilder {\n const namespace = postgresCreateNamespace({ id: options.schema, entries: { table: {} } });\n const conditions = [\n cfExpr.columnRef('c', 'conname').eqParam(options.constraintName, PG_TEXT_CODEC_ID),\n cfExpr.columnRef('n', 'nspname').eqExpr(namespace.schemaFilterExpression()),\n ];\n if (options.table !== undefined) {\n conditions.push(\n cfExpr.columnRef('c', 'conrelid').eqExpr(toRegclass(namespace.qualifyTable(options.table))),\n );\n }\n const inner = (): CfExprSelectQuery =>\n exprSelect()\n .from(cfTable('pg_constraint', 'c'))\n .join(\n cfTable('pg_namespace', 'n'),\n cfExpr.columnRef('n', 'oid').eqExpr(cfExpr.columnRef('c', 'connamespace')),\n )\n .project('one', cfExpr.lit(1))\n .where(cfExpr.allOf(conditions));\n return {\n constraintPresent: () => exprSelect().project('result', cfExpr.exists(inner())).build(),\n constraintAbsent: () => exprSelect().project('result', cfExpr.notExists(inner())).build(),\n };\n}\n\nfunction checkNamespace(schema: string) {\n return postgresCreateNamespace({ id: schema, entries: { table: {} } });\n}\n\nfunction informationSchemaColumns(): PostgresTableSource {\n return new PostgresTableSource({ schema: 'information_schema', name: 'columns' });\n}\n\nfunction infoSchemaColumnConditions(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n}): CfExpr[] {\n return [\n cfExpr\n .identifierRef('table_schema')\n .eqExpr(checkNamespace(options.schema).schemaFilterExpression()),\n cfExpr.identifierRef('table_name').eqParam(options.table, PG_TEXT_CODEC_ID),\n cfExpr.identifierRef('column_name').eqParam(options.column, PG_TEXT_CODEC_ID),\n ];\n}\n\nfunction infoSchemaColumnQuery(conditions: ReadonlyArray<CfExpr>): CfExprSelectQuery {\n return exprSelect()\n .from(informationSchemaColumns())\n .project('one', cfExpr.lit(1))\n .where(cfExpr.allOf(conditions));\n}\n\nexport interface ColumnExistsCheckBuilder {\n columnPresent(): SelectAst;\n columnAbsent(): SelectAst;\n}\n\n/**\n * Typed builder for column-existence checks over\n * `information_schema.columns`, with schema, table, and column names bound\n * as text parameters.\n */\nexport function columnExistsAst(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n}): ColumnExistsCheckBuilder {\n const inner = () => infoSchemaColumnQuery(infoSchemaColumnConditions(options));\n return {\n columnPresent: () => exprSelect().project('result', cfExpr.exists(inner())).build(),\n columnAbsent: () => exprSelect().project('result', cfExpr.notExists(inner())).build(),\n };\n}\n\n/**\n * Typed nullability check: EXISTS over `information_schema.columns` with\n * `is_nullable` compared against the bound `'YES'` / `'NO'` marker.\n */\nexport function columnNullabilityAst(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n readonly nullable: boolean;\n}): SelectAst {\n const conditions = [\n ...infoSchemaColumnConditions(options),\n cfExpr.identifierRef('is_nullable').eqParam(options.nullable ? 'YES' : 'NO', PG_TEXT_CODEC_ID),\n ];\n return exprSelect()\n .project('result', cfExpr.exists(infoSchemaColumnQuery(conditions)))\n .build();\n}\n\nexport interface ColumnDefaultCheckBuilder {\n defaultPresent(): SelectAst;\n defaultAbsent(): SelectAst;\n noDefault(): SelectAst;\n}\n\n/**\n * Typed default-presence checks over `information_schema.columns`.\n * `defaultPresent` / `defaultAbsent` assert the column row exists with a\n * non-null / null `column_default`; `noDefault` is the NOT EXISTS variant\n * (also true when the column row is missing entirely).\n */\nexport function columnDefaultAst(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n}): ColumnDefaultCheckBuilder {\n const withDefault = () =>\n infoSchemaColumnQuery([\n ...infoSchemaColumnConditions(options),\n cfExpr.identifierRef('column_default').isNotNull(),\n ]);\n const withoutDefault = () =>\n infoSchemaColumnQuery([\n ...infoSchemaColumnConditions(options),\n cfExpr.identifierRef('column_default').isNull(),\n ]);\n return {\n defaultPresent: () => exprSelect().project('result', cfExpr.exists(withDefault())).build(),\n defaultAbsent: () => exprSelect().project('result', cfExpr.exists(withoutDefault())).build(),\n noDefault: () => exprSelect().project('result', cfExpr.notExists(withDefault())).build(),\n };\n}\n\n/**\n * Typed column-type check: EXISTS over `pg_attribute` joined to `pg_class`\n * and `pg_namespace`, comparing `format_type(a.atttypid, a.atttypmod)`\n * against the bound expected display type and excluding dropped columns.\n */\nexport function columnTypeAst(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n readonly expectedType: string;\n}): SelectAst {\n const formatType = cfExpr.fn({\n method: 'format_type',\n template: 'format_type({{self}}, {{arg0}})',\n self: cfExpr.columnRef('a', 'atttypid'),\n args: [cfExpr.columnRef('a', 'atttypmod')],\n returns: { codecId: PG_TEXT_CODEC_ID, nullable: false },\n });\n const inner = exprSelect()\n .from(cfTable('pg_attribute', 'a'))\n .join(\n cfTable('pg_class', 'c'),\n cfExpr.columnRef('c', 'oid').eqExpr(cfExpr.columnRef('a', 'attrelid')),\n )\n .join(\n cfTable('pg_namespace', 'n'),\n cfExpr.columnRef('n', 'oid').eqExpr(cfExpr.columnRef('c', 'relnamespace')),\n )\n .project('one', cfExpr.lit(1))\n .where(\n cfExpr.allOf([\n cfExpr\n .columnRef('n', 'nspname')\n .eqExpr(checkNamespace(options.schema).schemaFilterExpression()),\n cfExpr.columnRef('c', 'relname').eqParam(options.table, PG_TEXT_CODEC_ID),\n cfExpr.columnRef('a', 'attname').eqParam(options.column, PG_TEXT_CODEC_ID),\n formatType.eqParam(options.expectedType, PG_TEXT_CODEC_ID),\n cfExpr.columnRef('a', 'attisdropped').not(),\n ]),\n );\n return exprSelect().project('result', cfExpr.exists(inner)).build();\n}\n\nexport interface TablePrimaryKeyCheckBuilder {\n pkPresent(): SelectAst;\n pkAbsent(): SelectAst;\n}\n\n/**\n * Typed primary-key existence check over `pg_index` joined to `pg_class`\n * and `pg_namespace`, with a LEFT JOIN on the index relation so an\n * optional `constraintName` can scope the match to a named constraint.\n */\nexport function tablePrimaryKeyAst(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraintName?: string;\n}): TablePrimaryKeyCheckBuilder {\n const conditions = [\n cfExpr\n .columnRef('n', 'nspname')\n .eqExpr(checkNamespace(options.schema).schemaFilterExpression()),\n cfExpr.columnRef('c', 'relname').eqParam(options.table, PG_TEXT_CODEC_ID),\n cfExpr.columnRef('i', 'indisprimary'),\n ];\n if (options.constraintName !== undefined) {\n conditions.push(\n cfExpr.columnRef('c2', 'relname').eqParam(options.constraintName, PG_TEXT_CODEC_ID),\n );\n }\n const inner = () =>\n exprSelect()\n .from(cfTable('pg_index', 'i'))\n .join(\n cfTable('pg_class', 'c'),\n cfExpr.columnRef('c', 'oid').eqExpr(cfExpr.columnRef('i', 'indrelid')),\n )\n .join(\n cfTable('pg_namespace', 'n'),\n cfExpr.columnRef('n', 'oid').eqExpr(cfExpr.columnRef('c', 'relnamespace')),\n )\n .leftJoin(\n cfTable('pg_class', 'c2'),\n cfExpr.columnRef('c2', 'oid').eqExpr(cfExpr.columnRef('i', 'indexrelid')),\n )\n .project('one', cfExpr.lit(1))\n .where(cfExpr.allOf(conditions));\n return {\n pkPresent: () => exprSelect().project('result', cfExpr.exists(inner())).build(),\n pkAbsent: () => exprSelect().project('result', cfExpr.notExists(inner())).build(),\n };\n}\n\n/**\n * Typed emptiness check: NOT EXISTS over the user table itself with\n * `LIMIT 1`. The table is addressed through the namespace's polymorphic\n * `tableSource` (qualified for named schemas, bare for the unbound slot).\n */\nexport function tableIsEmptyAst(schema: string, table: string): SelectAst {\n const inner = exprSelect()\n .from(checkNamespace(schema).tableSource(table))\n .project('one', cfExpr.lit(1))\n .limit(1);\n return exprSelect().project('result', cfExpr.notExists(inner)).build();\n}\n\n/**\n * Typed no-NULL-values data check used by `SET NOT NULL` prechecks:\n * NOT EXISTS over the user table where the column IS NULL.\n */\nexport function noNullValuesAst(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n}): SelectAst {\n const inner = exprSelect()\n .from(checkNamespace(options.schema).tableSource(options.table))\n .project('one', cfExpr.lit(1))\n .where(cfExpr.identifierRef(options.column).isNull());\n return exprSelect().project('result', cfExpr.notExists(inner)).build();\n}\n\nexport interface ExtensionExistsCheckBuilder {\n extensionPresent(): SelectAst;\n extensionAbsent(): SelectAst;\n}\n\n/**\n * Typed extension existence check over `pg_extension`, with the extension\n * name bound as a text parameter.\n */\nexport function extensionExistsAst(extensionName: string): ExtensionExistsCheckBuilder {\n const inner = () =>\n exprSelect()\n .from(cfTable('pg_extension'))\n .project('one', cfExpr.lit(1))\n .where(cfExpr.identifierRef('extname').eqParam(extensionName, PG_TEXT_CODEC_ID));\n return {\n extensionPresent: () => exprSelect().project('result', cfExpr.exists(inner())).build(),\n extensionAbsent: () => exprSelect().project('result', cfExpr.notExists(inner())).build(),\n };\n}\n\nexport interface RlsPolicyExistsCheckBuilder {\n policyPresent(): SelectAst;\n policyAbsent(): SelectAst;\n}\n\n/**\n * Typed RLS-policy existence check over `pg_policies`, with schema, table,\n * and policy names bound as text parameters (never inlined). The `schema`\n * coordinate is the resolved live-database schema name (e.g. `'public'`),\n * compared against `pg_policies.schemaname` as a bound parameter.\n */\nexport function rlsPolicyExistsAst(options: {\n readonly schema: string;\n readonly table: string;\n readonly policyName: string;\n}): RlsPolicyExistsCheckBuilder {\n const inner = () =>\n exprSelect()\n .from(cfTable('pg_policies'))\n .project('one', cfExpr.lit(1))\n .where(\n cfExpr.allOf([\n cfExpr.identifierRef('schemaname').eqParam(options.schema, PG_TEXT_CODEC_ID),\n cfExpr.identifierRef('tablename').eqParam(options.table, PG_TEXT_CODEC_ID),\n cfExpr.identifierRef('policyname').eqParam(options.policyName, PG_TEXT_CODEC_ID),\n ]),\n );\n return {\n policyPresent: () => exprSelect().project('result', cfExpr.exists(inner())).build(),\n policyAbsent: () => exprSelect().project('result', cfExpr.notExists(inner())).build(),\n };\n}\n\nexport interface RlsEnabledCheckBuilder {\n rlsEnabled(): SelectAst;\n rlsDisabled(): SelectAst;\n}\n\n/**\n * Typed row-level-security enabled check over `pg_class` joined to\n * `pg_namespace`, comparing `pg_class.relrowsecurity` against the expected\n * boolean. Schema and table names are bound as text parameters.\n */\nexport function rlsEnabledAst(schema: string, table: string): RlsEnabledCheckBuilder {\n const inner = (enabled: boolean) =>\n exprSelect()\n .from(cfTable('pg_class', 'c'))\n .join(\n cfTable('pg_namespace', 'n'),\n cfExpr.columnRef('n', 'oid').eqExpr(cfExpr.columnRef('c', 'relnamespace')),\n )\n .project('one', cfExpr.lit(1))\n .where(\n cfExpr.allOf([\n cfExpr.columnRef('n', 'nspname').eqParam(schema, PG_TEXT_CODEC_ID),\n cfExpr.columnRef('c', 'relname').eqParam(table, PG_TEXT_CODEC_ID),\n enabled\n ? cfExpr.columnRef('c', 'relrowsecurity')\n : cfExpr.columnRef('c', 'relrowsecurity').not(),\n ]),\n );\n return {\n rlsEnabled: () =>\n exprSelect()\n .project('result', cfExpr.exists(inner(true)))\n .build(),\n rlsDisabled: () =>\n exprSelect()\n .project('result', cfExpr.exists(inner(false)))\n .build(),\n };\n}\n\nexport interface IndexExistsCheckBuilder {\n indexPresent(): SelectAst;\n indexAbsent(): SelectAst;\n}\n\n/**\n * Typed index existence check riding the same `to_regclass` vocabulary as\n * `tableExistsAst`, with the qualified index name bound as a text parameter.\n */\nexport function indexExistsAst(schema: string, indexName: string): IndexExistsCheckBuilder {\n const regclass = toRegclass(checkNamespace(schema).qualifyTable(indexName));\n return {\n indexPresent: () => exprSelect().project('result', regclass.isNotNull()).build(),\n indexAbsent: () => exprSelect().project('result', regclass.isNull()).build(),\n };\n}\n","import type { DdlColumn, DdlTableConstraint } from '@prisma-next/sql-relational-core/ast';\nimport {\n AddColumnAction,\n type AnyAlterTableAction,\n DropDefaultAction,\n PostgresAlterPolicyRename,\n PostgresAlterTable,\n PostgresCreatePolicy,\n PostgresCreateSchema,\n PostgresCreateTable,\n PostgresDisableRowLevelSecurity,\n PostgresDropPolicy,\n type RlsPolicyOperation,\n} from '../core/ddl/nodes';\n\n/**\n * Build a Postgres `CREATE TABLE` query node.\n *\n * Pass `constraints` for table-level composite primary keys, foreign keys, and\n * unique constraints — use the {@link PrimaryKeyConstraint}, {@link ForeignKeyConstraint},\n * and {@link UniqueConstraint} classes from `@prisma-next/sql-relational-core/ast`.\n *\n * Precondition: identifiers (`table`, `schema`, column names/types) are\n * emitted to SQL verbatim — they are not quoted or escaped, so callers must\n * pass pre-trusted values (e.g. fixed control-plane identifiers). String-literal\n * default values, by contrast, are single-quote-escaped (embedded `'` doubled)\n * by the renderer. Identifier quoting for untrusted identifiers is added when\n * the migration planner adopts this lowering path.\n */\nexport function createTable(options: {\n readonly table: string;\n readonly schema?: string;\n readonly ifNotExists?: boolean;\n readonly columns: readonly DdlColumn[];\n readonly constraints?: readonly DdlTableConstraint[];\n}): PostgresCreateTable {\n return new PostgresCreateTable(options);\n}\n\n/**\n * Build a Postgres `CREATE SCHEMA` query node. See {@link createTable} for the\n * pre-trusted-identifier precondition.\n */\nexport function createSchema(options: {\n readonly schema: string;\n readonly ifNotExists?: boolean;\n}): PostgresCreateSchema {\n return new PostgresCreateSchema(options);\n}\n\n/**\n * Build an `ADD COLUMN` action for use inside {@link alterTable}.\n * The column is a structured `DdlColumn` so codec-encoded defaults flow\n * through the adapter's `pgRenderDdlColumn` → `pgRenderDdlColumnDefault` path.\n */\nexport function addColumnAction(column: DdlColumn): AddColumnAction {\n return new AddColumnAction(column);\n}\n\n/**\n * Build a `DROP DEFAULT` action (`ALTER COLUMN \"<name>\" DROP DEFAULT`) for\n * use inside {@link alterTable}. The renderer quotes the column name.\n */\nexport function dropDefaultAction(columnName: string): DropDefaultAction {\n return new DropDefaultAction(columnName);\n}\n\n/**\n * Build a Postgres `ALTER TABLE` query node carrying one or more actions.\n * See {@link addColumnAction} / {@link dropDefaultAction} for building actions.\n */\nexport function alterTable(options: {\n readonly table: string;\n readonly schema?: string;\n readonly actions: readonly AnyAlterTableAction[];\n}): PostgresAlterTable {\n return new PostgresAlterTable(options);\n}\n\n/**\n * Build a Postgres `CREATE POLICY` DDL node.\n *\n * Identifiers (`schema`, `table`, `name`) are quoted by the renderer.\n * `using` and `withCheck` are emitted verbatim as predicate SQL — callers\n * must supply safe, pre-validated SQL expressions.\n */\nexport function createPolicy(options: {\n readonly schema: string;\n readonly table: string;\n readonly name: string;\n readonly permissive: boolean;\n readonly operation: RlsPolicyOperation;\n readonly roles: readonly string[];\n readonly using?: string;\n readonly withCheck?: string;\n}): PostgresCreatePolicy {\n return new PostgresCreatePolicy(options);\n}\n\n/**\n * Build a Postgres `DROP POLICY` DDL node.\n * Identifiers (`schema`, `table`, `name`) are quoted by the renderer.\n */\nexport function dropPolicy(options: {\n readonly schema: string;\n readonly table: string;\n readonly name: string;\n}): PostgresDropPolicy {\n return new PostgresDropPolicy(options);\n}\n\n/**\n * Build a Postgres `ALTER POLICY … RENAME TO` DDL node.\n * Identifiers (`schema`, `table`, `name`, `newName`) are quoted by the renderer.\n */\nexport function alterPolicyRename(options: {\n readonly schema: string;\n readonly table: string;\n readonly name: string;\n readonly newName: string;\n}): PostgresAlterPolicyRename {\n return new PostgresAlterPolicyRename(options);\n}\n\n/**\n * Build a Postgres `ALTER TABLE … DISABLE ROW LEVEL SECURITY` DDL node.\n * Identifiers (`schema`, `table`) are quoted by the renderer.\n */\nexport function disableRowLevelSecurity(options: {\n readonly schema: string;\n readonly table: string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IAAI,qBAAqB,OAAO;AACzC;;;;;AAMA,SAAgB,WAAW,SAIJ;CACrB,OAAO,IAAI,mBAAmB,OAAO;AACvC;;;;;AAMA,SAAgB,kBAAkB,SAKJ;CAC5B,OAAO,IAAI,0BAA0B,OAAO;AAC9C;;;;;AAMA,SAAgB,wBAAwB,SAGJ;CAClC,OAAO,IAAI,gCAAgC,OAAO;AACpD"}
package/dist/ddl.d.mts CHANGED
@@ -1,3 +1,3 @@
1
1
  import { n as RlsPolicyOperation } from "./canonicalize-CAbXtVtB.mjs";
2
- import { a as DropDefaultAction, c as PostgresCreateSchema, d as PostgresDdlVisitor, f as PostgresDropPolicy, i as AnyPostgresDdlNode, l as PostgresCreateTable, n as AlterTableActionVisitor, o as PostgresAlterTable, r as AnyAlterTableAction, s as PostgresCreatePolicy, t as AddColumnAction, u as PostgresDdlNode } from "./nodes-CSkPX3rI.mjs";
3
- export { AddColumnAction, type AlterTableActionVisitor, type AnyAlterTableAction, type AnyPostgresDdlNode, DropDefaultAction, PostgresAlterTable, PostgresCreatePolicy, PostgresCreateSchema, PostgresCreateTable, PostgresDdlNode, type PostgresDdlVisitor, PostgresDropPolicy, type RlsPolicyOperation };
2
+ import { a as DropDefaultAction, c as PostgresCreatePolicy, d as PostgresDdlNode, f as PostgresDdlVisitor, i as AnyPostgresDdlNode, l as PostgresCreateSchema, m as PostgresDropPolicy, n as AlterTableActionVisitor, o as PostgresAlterPolicyRename, p as PostgresDisableRowLevelSecurity, r as AnyAlterTableAction, s as PostgresAlterTable, t as AddColumnAction, u as PostgresCreateTable } from "./nodes-BtQyZha6.mjs";
3
+ export { AddColumnAction, type AlterTableActionVisitor, type AnyAlterTableAction, type AnyPostgresDdlNode, DropDefaultAction, PostgresAlterPolicyRename, PostgresAlterTable, PostgresCreatePolicy, PostgresCreateSchema, PostgresCreateTable, PostgresDdlNode, type PostgresDdlVisitor, PostgresDisableRowLevelSecurity, PostgresDropPolicy, type RlsPolicyOperation };
package/dist/ddl.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { a as PostgresCreateSchema, c as PostgresDropPolicy, i as PostgresCreatePolicy, n as DropDefaultAction, o as PostgresCreateTable, r as PostgresAlterTable, s as PostgresDdlNode, t as AddColumnAction } from "./nodes-Dh__NS58.mjs";
2
- export { AddColumnAction, DropDefaultAction, PostgresAlterTable, PostgresCreatePolicy, PostgresCreateSchema, PostgresCreateTable, PostgresDdlNode, PostgresDropPolicy };
1
+ import { a as PostgresCreatePolicy, c as PostgresDdlNode, i as PostgresAlterTable, l as PostgresDisableRowLevelSecurity, n as DropDefaultAction, o as PostgresCreateSchema, r as PostgresAlterPolicyRename, s as PostgresCreateTable, t as AddColumnAction, u as PostgresDropPolicy } from "./nodes-B815pj_X.mjs";
2
+ export { AddColumnAction, DropDefaultAction, PostgresAlterPolicyRename, PostgresAlterTable, PostgresCreatePolicy, PostgresCreateSchema, PostgresCreateTable, PostgresDdlNode, PostgresDisableRowLevelSecurity, PostgresDropPolicy };
@@ -1,7 +1,7 @@
1
1
  import { T as postgresQualifyColumnType } from "./codecs-CkVQrZ4G.mjs";
2
2
  import { t as DEFAULT_NAMESPACE_ID } from "./namespace-ids-xtp_ZY86.mjs";
3
- import { i as postgresCreateNamespace } from "./postgres-schema-DcG72fcT.mjs";
4
- import { i as postgresAuthoringTypes, n as postgresAuthoringFieldPresets, r as postgresAuthoringPslBlockDescriptors, t as postgresAuthoringEntityTypes } from "./authoring-BBIGcFZM.mjs";
3
+ import { i as postgresCreateNamespace } from "./postgres-schema-DTLA_aRi.mjs";
4
+ import { a as postgresAuthoringTypes, i as postgresAuthoringPslBlockDescriptors, n as postgresAuthoringFieldPresets, r as postgresAuthoringModelAttributes, t as postgresAuthoringEntityTypes } from "./authoring-WkqG_MkU.mjs";
5
5
  import { t as postgresTargetDescriptorMetaRuntime } from "./descriptor-meta-runtime-UwYdV8fD.mjs";
6
6
  const postgresTargetDescriptorMeta = {
7
7
  ...postgresTargetDescriptorMetaRuntime,
@@ -11,6 +11,7 @@ const postgresTargetDescriptorMeta = {
11
11
  field: postgresAuthoringFieldPresets,
12
12
  entityTypes: postgresAuthoringEntityTypes,
13
13
  pslBlockDescriptors: postgresAuthoringPslBlockDescriptors,
14
+ modelAttributes: postgresAuthoringModelAttributes,
14
15
  createNamespace: postgresCreateNamespace,
15
16
  qualifyColumnType: postgresQualifyColumnType
16
17
  }
@@ -18,4 +19,4 @@ const postgresTargetDescriptorMeta = {
18
19
  //#endregion
19
20
  export { postgresTargetDescriptorMeta as t };
20
21
 
21
- //# sourceMappingURL=descriptor-meta-C-tyS25s.mjs.map
22
+ //# sourceMappingURL=descriptor-meta-BOcKPaLE.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"descriptor-meta-BOcKPaLE.mjs","names":[],"sources":["../src/core/descriptor-meta.ts"],"sourcesContent":["import type { CodecTypes } from '../exports/codec-types';\nimport {\n postgresAuthoringEntityTypes,\n postgresAuthoringFieldPresets,\n postgresAuthoringModelAttributes,\n postgresAuthoringPslBlockDescriptors,\n postgresAuthoringTypes,\n} from './authoring';\nimport { postgresQualifyColumnType } from './codecs';\nimport { postgresTargetDescriptorMetaRuntime } from './descriptor-meta-runtime';\nimport { DEFAULT_NAMESPACE_ID } from './namespace-ids';\nimport { postgresCreateNamespace } from './postgres-schema';\n\nconst postgresTargetDescriptorMetaBase = {\n ...postgresTargetDescriptorMetaRuntime,\n defaultNamespaceId: DEFAULT_NAMESPACE_ID,\n authoring: {\n type: postgresAuthoringTypes,\n field: postgresAuthoringFieldPresets,\n entityTypes: postgresAuthoringEntityTypes,\n pslBlockDescriptors: postgresAuthoringPslBlockDescriptors,\n modelAttributes: postgresAuthoringModelAttributes,\n createNamespace: postgresCreateNamespace,\n qualifyColumnType: postgresQualifyColumnType,\n },\n} as const;\n\nexport const postgresTargetDescriptorMeta: typeof postgresTargetDescriptorMetaBase & {\n readonly __codecTypes?: CodecTypes;\n} = postgresTargetDescriptorMetaBase;\n"],"mappings":";;;;;AA2BA,MAAa,+BAET;CAfF,GAAG;CACH,oBAAoB;CACpB,WAAW;EACT,MAAM;EACN,OAAO;EACP,aAAa;EACb,qBAAqB;EACrB,iBAAiB;EACjB,iBAAiB;EACjB,mBAAmB;CACrB;AAKE"}
@@ -1,8 +1,8 @@
1
- import { r as isPostgresSchema } from "./postgres-schema-DcG72fcT.mjs";
2
- import { r as postgresDiffSubjectGranularity } from "./schema-node-kinds-ClScchhi.mjs";
3
- import { a as PostgresDatabaseSchemaNode, i as PostgresNamespaceSchemaNode, n as PostgresRoleSchemaNode, r as PostgresPolicySchemaNode, t as PostgresTableSchemaNode } from "./postgres-table-schema-node-BZWWEo7B.mjs";
4
- import { t as resolveDdlSchemaForNamespaceStorage } from "./resolve-ddl-schema-BOtCoeKV.mjs";
5
- import { i as resolvePostgresNodeIssueControlPolicySubject } from "./control-policy-DievMCOV.mjs";
1
+ import { r as isPostgresSchema } from "./postgres-schema-DTLA_aRi.mjs";
2
+ import { i as postgresDiffSubjectGranularity, t as PostgresTableSchemaNode } from "./postgres-table-schema-node-9FCtCUz2.mjs";
3
+ import { i as PostgresDatabaseSchemaNode, n as PostgresPolicySchemaNode, r as PostgresNamespaceSchemaNode, t as PostgresRoleSchemaNode } from "./postgres-role-schema-node-BiSTCTNg.mjs";
4
+ import { t as resolveDdlSchemaForNamespaceStorage } from "./resolve-ddl-schema-Ca88Tg6W.mjs";
5
+ import { i as resolvePostgresNodeIssueControlPolicySubject } from "./control-policy-BtOZBVxL.mjs";
6
6
  import { UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir";
7
7
  import { blindCast } from "@prisma-next/utils/casts";
8
8
  import { buildNativeTypeExpander, contractNamespaceToSchemaIR } from "@prisma-next/family-sql/control";
@@ -89,12 +89,19 @@ function contractToPostgresDatabaseSchemaNode(contract, options) {
89
89
  ...ifDefined("primaryKey", sqlTable.primaryKey),
90
90
  ...ifDefined("annotations", sqlTable.annotations),
91
91
  ...ifDefined("checks", sqlTable.checks),
92
- policies: policiesByTable.get(tableName) ?? []
92
+ policies: policiesByTable.get(tableName) ?? [],
93
+ rlsEnabled: Object.hasOwn(ns.rls, tableName)
93
94
  });
94
95
  }
95
- for (const [tableName, tablePolicies] of policiesByTable) if (!(tableName in tables)) {
96
- const policyName = tablePolicies[0]?.name ?? "(unknown)";
97
- throw new Error(`contract-to-postgres-database-schema-node: policy "${policyName}" references table "${tableName}" not present in namespace "${ddlSchema}"`);
96
+ for (const [tableName, tablePolicies] of policiesByTable) {
97
+ if (!(tableName in tables)) {
98
+ const policyName = tablePolicies[0]?.name ?? "(unknown)";
99
+ throw new Error(`contract-to-postgres-database-schema-node: policy "${policyName}" references table "${tableName}" not present in namespace "${ddlSchema}"`);
100
+ }
101
+ if (!Object.hasOwn(ns.rls, tableName)) {
102
+ const policyPrefix = tablePolicies[0]?.prefix ?? "(unknown)";
103
+ throw new Error(`contract-to-postgres-database-schema-node: policy "${policyPrefix}" targets table "${tableName}" in namespace "${ddlSchema}", which is not RLS-controlled. Mark the model with @@rls (entries.rls["${tableName}"]) or remove the policy.`);
104
+ }
98
105
  }
99
106
  namespaces[ddlSchema] = new PostgresNamespaceSchemaNode({
100
107
  schemaName: ddlSchema,
@@ -155,7 +162,8 @@ function normalizePostgresActualForDiff(expected, actual) {
155
162
  ...ifDefined("primaryKey", actualTable.primaryKey),
156
163
  ...ifDefined("annotations", actualTable.annotations),
157
164
  ...ifDefined("checks", actualTable.checks),
158
- policies: [...actualTable.policies]
165
+ policies: [...actualTable.policies],
166
+ rlsEnabled: actualTable.rlsEnabled
159
167
  });
160
168
  }
161
169
  namespaces[nsId] = new PostgresNamespaceSchemaNode({
@@ -311,4 +319,4 @@ function buildPostgresPlanDiff(input) {
311
319
  //#endregion
312
320
  export { diffPostgresSchema as n, contractToPostgresDatabaseSchemaNode as r, buildPostgresPlanDiff as t };
313
321
 
314
- //# sourceMappingURL=diff-database-schema-ff3ioNtK.mjs.map
322
+ //# sourceMappingURL=diff-database-schema-CWb-jeLy.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diff-database-schema-CWb-jeLy.mjs","names":[],"sources":["../src/core/migrations/contract-to-postgres-database-schema-node.ts","../src/core/migrations/diff-database-schema.ts"],"sourcesContent":["import type { ContractToSchemaIROptions } from '@prisma-next/family-sql/control';\nimport { contractNamespaceToSchemaIR } from '@prisma-next/family-sql/control';\nimport { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport { SqlForeignKeyIR } from '@prisma-next/sql-schema-ir/types';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport type { PostgresRlsPolicy } from '../postgres-rls-policy';\nimport type { PostgresContract } from '../postgres-schema';\nimport { isPostgresSchema } from '../postgres-schema';\nimport { PostgresDatabaseSchemaNode } from '../schema-ir/postgres-database-schema-node';\nimport { PostgresNamespaceSchemaNode } from '../schema-ir/postgres-namespace-schema-node';\nimport { PostgresPolicySchemaNode } from '../schema-ir/postgres-policy-schema-node';\nimport { PostgresRoleSchemaNode } from '../schema-ir/postgres-role-schema-node';\nimport { PostgresTableSchemaNode } from '../schema-ir/postgres-table-schema-node';\nimport { resolveDdlSchemaForNamespaceStorage } from './resolve-ddl-schema';\n\nfunction toPolicyNode(policy: PostgresRlsPolicy, namespaceId: string): PostgresPolicySchemaNode {\n return new PostgresPolicySchemaNode({\n name: policy.name,\n prefix: policy.prefix,\n tableName: policy.tableName,\n namespaceId,\n operation: policy.operation,\n roles: [...policy.roles],\n ...ifDefined('using', policy.using),\n ...ifDefined('withCheck', policy.withCheck),\n permissive: policy.permissive,\n });\n}\n\n/**\n * Projects a Postgres contract into the expected schema-diff tree: a\n * `PostgresDatabaseSchemaNode` root holding one `PostgresNamespaceSchemaNode`\n * per Postgres namespace, each holding its `PostgresTableSchemaNode`s with\n * their `PostgresPolicySchemaNode`s, plus the database roles on the root.\n *\n * Not a duplicate of the family's `contractToSchemaIR`: that builds a flat,\n * single `{ tables }` map (and throws on cross-namespace name collisions, with\n * no RLS/role concept) for SQLite's single-schema world. This is the\n * Postgres-specific *tree* shape — multi-schema, RLS-policy-aware, role-aware.\n * It reuses the family's per-namespace table conversion (`contractNamespaceToSchemaIR`)\n * for column/FK/index building and only adds the Postgres tree/policy/role shape.\n *\n * Tables are grouped by their owning namespace (resolved DDL schema name) so\n * the tree mirrors Postgres's object hierarchy. The DDL schema name is\n * resolved once per namespace.\n *\n * A policy that references a table absent from its namespace is a malformed\n * contract — the loop throws rather than fabricating a stub table.\n */\nexport function contractToPostgresDatabaseSchemaNode(\n contract: PostgresContract | null,\n options: ContractToSchemaIROptions,\n): PostgresDatabaseSchemaNode {\n if (contract === null) {\n return new PostgresDatabaseSchemaNode({\n namespaces: {},\n roles: [],\n existingSchemas: [],\n pgVersion: '',\n });\n }\n\n const namespaces: Record<string, PostgresNamespaceSchemaNode> = {};\n const roles: PostgresRoleSchemaNode[] = [];\n const ownedSchemas: string[] = [];\n\n for (const ns of Object.values(contract.storage.namespaces)) {\n if (!isPostgresSchema(ns)) continue;\n const ddlSchema = resolveDdlSchemaForNamespaceStorage(contract.storage, ns.id);\n ownedSchemas.push(ddlSchema);\n\n // Convert only THIS namespace's tables (passing the full storage for\n // type/value-set/enum resolution that spans namespaces), so the same table\n // name can exist in two schemas without colliding in a bare-keyed record.\n const sqlTables = contractNamespaceToSchemaIR(contract.storage, ns.id, options).tables;\n\n const policiesByTable = new Map<string, PostgresPolicySchemaNode[]>();\n for (const policy of Object.values(ns.policy)) {\n const list = policiesByTable.get(policy.tableName) ?? [];\n list.push(toPolicyNode(policy, ddlSchema));\n policiesByTable.set(policy.tableName, list);\n }\n\n const tables: Record<string, PostgresTableSchemaNode> = {};\n for (const tableName of Object.keys(ns.table)) {\n const sqlTable = sqlTables[tableName];\n if (sqlTable === undefined) continue;\n // The family conversion stamps `referencedSchema` with the FK target's\n // namespace id verbatim, which can be the unbound sentinel. Resolve it\n // to the real live DDL schema here — introspected FKs already carry the\n // live schema, so this is what lets an expected FK pair (by diff-node\n // id) with its introspected counterpart.\n const foreignKeys = sqlTable.foreignKeys.map(\n (fk) =>\n new SqlForeignKeyIR({\n columns: fk.columns,\n referencedTable: fk.referencedTable,\n referencedColumns: fk.referencedColumns,\n ...ifDefined('referencedSchema', fk.referencedSchema),\n ...ifDefined('name', fk.name),\n ...ifDefined('onDelete', fk.onDelete),\n ...ifDefined('onUpdate', fk.onUpdate),\n ...ifDefined('annotations', fk.annotations),\n resolvedReferencedNamespace: resolveDdlSchemaForNamespaceStorage(\n contract.storage,\n fk.referencedSchema ?? UNBOUND_NAMESPACE_ID,\n ),\n }),\n );\n tables[tableName] = new PostgresTableSchemaNode({\n name: sqlTable.name,\n columns: sqlTable.columns,\n foreignKeys,\n uniques: sqlTable.uniques,\n indexes: sqlTable.indexes,\n ...ifDefined('primaryKey', sqlTable.primaryKey),\n ...ifDefined('annotations', sqlTable.annotations),\n ...ifDefined('checks', sqlTable.checks),\n policies: policiesByTable.get(tableName) ?? [],\n // Marker-driven, never derived from the policy set: the `rls` entry\n // is the single authored source of enablement.\n rlsEnabled: Object.hasOwn(ns.rls, tableName),\n });\n }\n\n for (const [tableName, tablePolicies] of policiesByTable) {\n if (!(tableName in tables)) {\n const policyName = tablePolicies[0]?.name ?? '(unknown)';\n throw new Error(\n `contract-to-postgres-database-schema-node: policy \"${policyName}\" references table \"${tableName}\" not present in namespace \"${ddlSchema}\"`,\n );\n }\n if (!Object.hasOwn(ns.rls, tableName)) {\n const policyPrefix = tablePolicies[0]?.prefix ?? '(unknown)';\n throw new Error(\n `contract-to-postgres-database-schema-node: policy \"${policyPrefix}\" targets table \"${tableName}\" in namespace \"${ddlSchema}\", which is not RLS-controlled. Mark the model with @@rls (entries.rls[\"${tableName}\"]) or remove the policy.`,\n );\n }\n }\n\n namespaces[ddlSchema] = new PostgresNamespaceSchemaNode({\n schemaName: ddlSchema,\n tables,\n nativeEnumTypeNames: [],\n });\n\n for (const role of Object.values(ns.role)) {\n roles.push(new PostgresRoleSchemaNode({ name: role.name, namespaceId: role.namespaceId }));\n }\n }\n\n return new PostgresDatabaseSchemaNode({\n namespaces,\n roles,\n existingSchemas: ownedSchemas,\n pgVersion: '',\n });\n}\n","import type { Contract, ControlPolicy } from '@prisma-next/contract/types';\nimport type { SqlSchemaDiffResult } from '@prisma-next/family-sql/control';\nimport { buildNativeTypeExpander } from '@prisma-next/family-sql/control';\nimport {\n classifyDiffSubjectGranularity,\n resolveSemanticSatisfaction,\n} from '@prisma-next/family-sql/diff';\nimport type { TargetBoundComponentDescriptor } from '@prisma-next/framework-components/components';\nimport type { SchemaDiffIssue } from '@prisma-next/framework-components/control';\nimport { diffSchemas } from '@prisma-next/framework-components/control';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { SqlSchemaIRNode } from '@prisma-next/sql-schema-ir/types';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport type { PostgresContract } from '../postgres-schema';\nimport { PostgresDatabaseSchemaNode } from '../schema-ir/postgres-database-schema-node';\nimport { PostgresNamespaceSchemaNode } from '../schema-ir/postgres-namespace-schema-node';\nimport { PostgresTableSchemaNode } from '../schema-ir/postgres-table-schema-node';\nimport {\n postgresDiffSubjectGranularity,\n type SqlSchemaDiffNode,\n} from '../schema-ir/schema-node-kinds';\nimport { contractToPostgresDatabaseSchemaNode } from './contract-to-postgres-database-schema-node';\nimport { resolvePostgresNodeIssueControlPolicySubject } from './control-policy';\n\nfunction ownedSchemaNames(expected: PostgresDatabaseSchemaNode): ReadonlySet<string> {\n const policyNamespaces = Object.values(expected.namespaces).flatMap((ns) =>\n Object.values(ns.tables).flatMap((t) => t.policies.map((p) => p.namespaceId)),\n );\n return new Set([...policyNamespaces, ...expected.existingSchemas]);\n}\n\n/**\n * Applies the family's semantic-satisfaction normalization across a Postgres\n * tree pair: every actual table with an expected counterpart (paired by\n * namespace id, then table id) gets its unique/index child lists adjusted;\n * everything else passes through untouched.\n */\nexport function normalizePostgresActualForDiff(\n expected: PostgresDatabaseSchemaNode,\n actual: PostgresDatabaseSchemaNode,\n): PostgresDatabaseSchemaNode {\n const namespaces: Record<string, PostgresNamespaceSchemaNode> = {};\n for (const [nsId, actualNs] of Object.entries(actual.namespaces)) {\n const expectedNs = expected.namespaces[nsId];\n if (expectedNs === undefined) {\n namespaces[nsId] = actualNs;\n continue;\n }\n const tables: Record<string, PostgresTableSchemaNode> = {};\n for (const [tableName, actualTable] of Object.entries(actualNs.tables)) {\n const expectedTable = expectedNs.tables[tableName];\n if (expectedTable === undefined) {\n tables[tableName] = actualTable;\n continue;\n }\n const adjusted = resolveSemanticSatisfaction({\n expectedUniques: expectedTable.uniques,\n expectedIndexes: expectedTable.indexes,\n actualUniques: actualTable.uniques,\n actualIndexes: actualTable.indexes,\n });\n tables[tableName] = new PostgresTableSchemaNode({\n name: actualTable.name,\n columns: actualTable.columns,\n foreignKeys: actualTable.foreignKeys,\n uniques: adjusted.actualUniques,\n indexes: adjusted.actualIndexes,\n ...ifDefined('primaryKey', actualTable.primaryKey),\n ...ifDefined('annotations', actualTable.annotations),\n ...ifDefined('checks', actualTable.checks),\n policies: [...actualTable.policies],\n rlsEnabled: actualTable.rlsEnabled,\n });\n }\n namespaces[nsId] = new PostgresNamespaceSchemaNode({\n schemaName: actualNs.schemaName,\n tables,\n nativeEnumTypeNames: actualNs.nativeEnumTypeNames,\n nativeEnums: actualNs.nativeEnums,\n });\n }\n return new PostgresDatabaseSchemaNode({\n namespaces,\n roles: [...actual.roles],\n existingSchemas: [...actual.existingSchemas],\n pgVersion: actual.pgVersion,\n });\n}\n\n/**\n * Drops contract namespaces that declare no tables from the verdict-diff\n * expected tree and the relational owned-schema set. The legacy relational\n * walk skipped a table-less namespace (e.g. an enums-only schema) before\n * pairing, so neither its DDL schema's absence nor that schema's live\n * relational contents ever reached the verdict — the pruned tree\n * reproduces that. The prune loses no expected policies: policies attach\n * to tables, so a table-less namespace carries none (the projection\n * throws on a policy referencing an absent table). Live policies in a\n * pruned schema remain governed via the full owned set (see\n * {@link diffPostgresSchema}).\n */\nfunction pruneTableLessNamespaces(\n expected: PostgresDatabaseSchemaNode,\n): PostgresDatabaseSchemaNode {\n const namespaces = Object.fromEntries(\n Object.entries(expected.namespaces).filter(([, ns]) => Object.keys(ns.tables).length > 0),\n );\n return new PostgresDatabaseSchemaNode({\n namespaces,\n roles: [...expected.roles],\n existingSchemas: expected.existingSchemas.filter((s) => namespaces[s] !== undefined),\n pgVersion: expected.pgVersion,\n });\n}\n\n/**\n * Resolves a verdict-diff issue's subject table's declared control policy\n * directly from the contract, by delegating to the same node-typed resolver\n * ({@link resolvePostgresNodeIssueControlPolicySubject}) the planner uses to\n * gate DDL calls. `undefined` when the issue resolves to no contract table.\n */\nfunction resolveControlPolicy(\n issue: SchemaDiffIssue,\n contract: Contract<SqlStorage>,\n): ControlPolicy | undefined {\n const nodeIssue = blindCast<\n SchemaDiffIssue<SqlSchemaDiffNode>,\n 'every node in a Postgres schema diff tree is a SqlSchemaDiffNode'\n >(issue);\n return resolvePostgresNodeIssueControlPolicySubject(nodeIssue, contract)\n ?.explicitNodeControlPolicy;\n}\n\n/**\n * The Postgres full-tree node diff for the family verify verdict: derive\n * the expected tree (resolved leaf values, expander threaded, FK schemas\n * resolved, table-less namespaces pruned), normalize the actual tree for\n * semantic satisfaction, run the generic\n * differ, and scope out `not-expected` findings under namespaces the\n * contract does not own. Ownership is role-aware, mirroring the legacy\n * decomposition: relational extras check the PRUNED owned set (the legacy\n * per-namespace walk never visited a table-less namespace, so its live\n * relational contents are invisible), while `structural` extras (RLS\n * policies) check the FULL owned set (the legacy policy diff governed\n * every contract schema regardless of tables — RLS governance does not\n * shrink because a namespace declares no tables). The codec `verifyType`\n * hooks run once per contract namespace with tables against that\n * namespace's paired actual node (the hooks read namespace-scoped state\n * such as `nativeEnumTypeNames`).\n */\nexport function diffPostgresSchema(input: {\n readonly contract: Contract<SqlStorage>;\n readonly schema: SqlSchemaIRNode;\n readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;\n}): SqlSchemaDiffResult {\n const postgresContract = blindCast<\n PostgresContract,\n 'diffPostgresSchema is only called with a postgres contract'\n >(input.contract);\n PostgresDatabaseSchemaNode.assert(input.schema);\n const actual = input.schema;\n const expandNativeType = buildNativeTypeExpander(input.frameworkComponents);\n const fullExpected = contractToPostgresDatabaseSchemaNode(postgresContract, {\n annotationNamespace: 'pg',\n ...ifDefined('expandNativeType', expandNativeType),\n });\n const expected = pruneTableLessNamespaces(fullExpected);\n const normalizedActual = normalizePostgresActualForDiff(expected, actual);\n const relationalOwned = ownedSchemaNames(expected);\n const structuralOwned = ownedSchemaNames(fullExpected);\n const issues = diffSchemas(expected, normalizedActual).filter((issue) => {\n if (issue.reason !== 'not-expected') return true;\n const namespaceSegment = issue.path[1];\n if (namespaceSegment === undefined) return true;\n const granularity = classifyDiffSubjectGranularity(issue, postgresDiffSubjectGranularity);\n const owned = granularity === 'structural' ? structuralOwned : relationalOwned;\n return owned.has(namespaceSegment);\n });\n const namespacePairs = Object.values(expected.namespaces).map((ns) => ({\n actual: actual.namespaces[ns.schemaName],\n }));\n return {\n issues,\n resolveControlPolicy: (issue) => resolveControlPolicy(issue, postgresContract),\n namespacePairs,\n };\n}\n\n/**\n * Adds an empty namespace node to the actual tree for every expected namespace\n * absent from it. The relational plan diff pairs on namespace: a contract\n * namespace whose live schema does not exist yet must surface each of its\n * tables as `not-found` (→ `CREATE TABLE`), NOT as a single namespace\n * `not-found` that subtree-coalescing would collapse (leaving `CREATE SCHEMA`\n * with no tables). Padding makes the namespaces pair, so only table/column/\n * policy drift surfaces; `CREATE SCHEMA` comes separately from the synthesized\n * namespace-presence stitch (`verifyPostgresNamespacePresence`), never from the\n * tree diff — matching the retired per-namespace-paired relational walk, which\n * paired a missing schema against an empty namespace node.\n */\nfunction padActualNamespaces(\n expected: PostgresDatabaseSchemaNode,\n actual: PostgresDatabaseSchemaNode,\n): PostgresDatabaseSchemaNode {\n const namespaces: Record<string, PostgresNamespaceSchemaNode> = { ...actual.namespaces };\n let padded = false;\n for (const schemaName of Object.keys(expected.namespaces)) {\n if (namespaces[schemaName] === undefined) {\n namespaces[schemaName] = new PostgresNamespaceSchemaNode({\n schemaName,\n tables: {},\n nativeEnumTypeNames: [],\n });\n padded = true;\n }\n }\n if (!padded) return actual;\n return new PostgresDatabaseSchemaNode({\n namespaces,\n roles: [...actual.roles],\n existingSchemas: [...actual.existingSchemas],\n pgVersion: actual.pgVersion,\n });\n}\n\nexport interface PostgresPlanDiff {\n /** The desired (\"end\") tree — resolved leaf values (incl. `codecRef`) on every column, table-less namespaces pruned. */\n readonly expected: PostgresDatabaseSchemaNode;\n /** The live (\"start\") tree, padded with empty namespaces and normalized for semantic satisfaction against `expected`. */\n readonly actual: PostgresDatabaseSchemaNode;\n /** The one node diff over the two trees: relational + policy drift, role-aware ownership filtered. */\n readonly issues: readonly SchemaDiffIssue<SqlSchemaDiffNode>[];\n}\n\n/**\n * The Postgres planner's diff input: the SAME tree-building\n * `diffPostgresSchema` uses (expander threaded, FK schemas resolved,\n * table-less namespaces pruned, actual normalized for semantic satisfaction,\n * role-aware ownership filter) plus actual namespace padding (so a missing\n * schema's tables surface as `not-found` instead of a swallowed namespace\n * `not-found`). One differ drives both verify and plan; this is the\n * plan-side derivation. The single issue list covers tables / columns /\n * constraints / indexes / defaults AND policies — the caller splits it\n * (relational → `mapNodeIssueToCall`; policy → RLS ops) and stitches in\n * `CREATE SCHEMA` separately.\n */\nexport function buildPostgresPlanDiff(input: {\n readonly contract: Contract<SqlStorage>;\n readonly actualSchema: SqlSchemaIRNode;\n readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;\n}): PostgresPlanDiff {\n const postgresContract = blindCast<\n PostgresContract,\n 'buildPostgresPlanDiff is only called with a postgres contract'\n >(input.contract);\n PostgresDatabaseSchemaNode.assert(input.actualSchema);\n const actual = input.actualSchema;\n const expandNativeType = buildNativeTypeExpander(input.frameworkComponents);\n const projectionOptions = {\n annotationNamespace: 'pg',\n ...ifDefined('expandNativeType', expandNativeType),\n };\n const fullExpected = contractToPostgresDatabaseSchemaNode(postgresContract, projectionOptions);\n const expected = pruneTableLessNamespaces(fullExpected);\n const paddedActual = padActualNamespaces(expected, actual);\n const normalizedActual = normalizePostgresActualForDiff(expected, paddedActual);\n const relationalOwned = ownedSchemaNames(expected);\n const structuralOwned = ownedSchemaNames(fullExpected);\n const issues = blindCast<\n readonly SchemaDiffIssue<SqlSchemaDiffNode>[],\n 'both trees are PostgresDatabaseSchemaNodes, so every diff-issue node is a SqlSchemaDiffNode'\n >(diffSchemas(expected, normalizedActual)).filter((issue) => {\n if (issue.reason !== 'not-expected') return true;\n const namespaceSegment = issue.path[1];\n if (namespaceSegment === undefined) return true;\n const granularity = classifyDiffSubjectGranularity(issue, postgresDiffSubjectGranularity);\n const owned = granularity === 'structural' ? structuralOwned : relationalOwned;\n return owned.has(namespaceSegment);\n });\n return { expected, actual: normalizedActual, issues };\n}\n"],"mappings":";;;;;;;;;;;;;AAeA,SAAS,aAAa,QAA2B,aAA+C;CAC9F,OAAO,IAAI,yBAAyB;EAClC,MAAM,OAAO;EACb,QAAQ,OAAO;EACf,WAAW,OAAO;EAClB;EACA,WAAW,OAAO;EAClB,OAAO,CAAC,GAAG,OAAO,KAAK;EACvB,GAAG,UAAU,SAAS,OAAO,KAAK;EAClC,GAAG,UAAU,aAAa,OAAO,SAAS;EAC1C,YAAY,OAAO;CACrB,CAAC;AACH;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,qCACd,UACA,SAC4B;CAC5B,IAAI,aAAa,MACf,OAAO,IAAI,2BAA2B;EACpC,YAAY,CAAC;EACb,OAAO,CAAC;EACR,iBAAiB,CAAC;EAClB,WAAW;CACb,CAAC;CAGH,MAAM,aAA0D,CAAC;CACjE,MAAM,QAAkC,CAAC;CACzC,MAAM,eAAyB,CAAC;CAEhC,KAAK,MAAM,MAAM,OAAO,OAAO,SAAS,QAAQ,UAAU,GAAG;EAC3D,IAAI,CAAC,i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AO,IAAI,2BAA2B;EACpC;EACA,OAAO,CAAC,GAAG,OAAO,KAAK;EACvB,iBAAiB,CAAC,GAAG,OAAO,eAAe;EAC3C,WAAW,OAAO;CACpB,CAAC;AACH;;;;;;;;;;;;;AAuBA,SAAgB,sBAAsB,OAIjB;CACnB,MAAM,mBAAmB,UAGvB,MAAM,QAAQ;CAChB,2BAA2B,OAAO,MAAM,YAAY;CACpD,MAAM,SAAS,MAAM;CAMrB,MAAM,eAAe,qCAAqC,kBAAkB;EAH1E,qBAAqB;EACrB,GAAG,UAAU,oBAHU,wBAAwB,MAAM,mBAGL,CAAC;CAEyC,CAAC;CAC7F,MAAM,WAAW,yBAAyB,YAAY;CAEtD,MAAM,mBAAmB,+BAA+B,UADnC,oBAAoB,UAAU,MAC0B,CAAC;CAC9E,MAAM,kBAAkB,iBAAiB,QAAQ;CACjD,MAAM,kBAAkB,iBAAiB,YAAY;CAYrD,OAAO;EAAE;EAAU,QAAQ;EAAkB,QAX9B,UAGb,YAAY,UAAU,gBAAgB,CAAC,CAAC,CAAC,QAAQ,UAAU;GAC3D,IAAI,MAAM,WAAW,gBAAgB,OAAO;GAC5C,MAAM,mBAAmB,MAAM,KAAK;GACpC,IAAI,qBAAqB,KAAA,GAAW,OAAO;GAG3C,QAFoB,+BAA+B,OAAO,8BAClC,MAAM,eAAe,kBAAkB,gBAAA,CAClD,IAAI,gBAAgB;EACnC,CACkD;CAAE;AACtD"}
@@ -1,4 +1,4 @@
1
- import { t as PostgresDatabaseSchemaNode } from "./postgres-database-schema-node-UpzA0Ug5.mjs";
1
+ import { t as PostgresDatabaseSchemaNode } from "./postgres-database-schema-node-CfdTY-Qs.mjs";
2
2
  import { SqlStorage } from "@prisma-next/sql-contract/types";
3
3
  import { SqlSchemaIRNode } from "@prisma-next/sql-schema-ir/types";
4
4
  import { DiffableNode, SchemaDiffIssue } from "@prisma-next/framework-components/control";
@@ -1 +1 @@
1
- {"version":3,"file":"diff-database-schema.d.mts","names":[],"sources":["../src/core/schema-ir/schema-node-kinds.ts","../src/core/migrations/diff-database-schema.ts"],"mappings":";;;;;;;;;;;;;;;KAiBY,iBAAA,GAAoB,eAAA,GAAkB,YAAY;;;UCgN7C,gBAAA;EAsBa;EAAA,SApBnB,QAAA,EAAU,0BAAA;EAqBI;EAAA,SAnBd,MAAA,EAAQ,0BAAA;EAoBa;EAAA,SAlBrB,MAAA,WAAiB,eAAA,CAAgB,iBAAA;AAAA;;;;;;;;;;;;;iBAe5B,qBAAA,CAAsB,KAAA;EAAA,SAC3B,QAAA,EAAU,QAAA,CAAS,UAAA;EAAA,SACnB,YAAA,EAAc,eAAA;EAAA,SACd,mBAAA,EAAqB,aAAA,CAAc,8BAAA;AAAA,IAC1C,gBAAA"}
1
+ {"version":3,"file":"diff-database-schema.d.mts","names":[],"sources":["../src/core/schema-ir/schema-node-kinds.ts","../src/core/migrations/diff-database-schema.ts"],"mappings":";;;;;;;;;;;;;;;KAiBY,iBAAA,GAAoB,eAAA,GAAkB,YAAY;;;UCiN7C,gBAAA;EAsBa;EAAA,SApBnB,QAAA,EAAU,0BAAA;EAqBI;EAAA,SAnBd,MAAA,EAAQ,0BAAA;EAoBa;EAAA,SAlBrB,MAAA,WAAiB,eAAA,CAAgB,iBAAA;AAAA;;;;;;;;;;;;;iBAe5B,qBAAA,CAAsB,KAAA;EAAA,SAC3B,QAAA,EAAU,QAAA,CAAS,UAAA;EAAA,SACnB,YAAA,EAAc,eAAA;EAAA,SACd,mBAAA,EAAqB,aAAA,CAAc,8BAAA;AAAA,IAC1C,gBAAA"}
@@ -1,2 +1,2 @@
1
- import { t as buildPostgresPlanDiff } from "./diff-database-schema-ff3ioNtK.mjs";
1
+ import { t as buildPostgresPlanDiff } from "./diff-database-schema-CWb-jeLy.mjs";
2
2
  export { buildPostgresPlanDiff };
@@ -1,4 +1,4 @@
1
- import { x as PostgresOpFactoryCall } from "./op-factory-call-Dt-Jx5JS.mjs";
1
+ import { x as PostgresOpFactoryCall } from "./op-factory-call-D6_7-7Vc.mjs";
2
2
  import { SqlStorage, StorageTable, StorageTypeInstance } from "@prisma-next/sql-contract/types";
3
3
  import { CodecControlHooks, MigrationOperationPolicy, SqlPlannerConflict } from "@prisma-next/family-sql/control";
4
4
  import { SqlColumnIR, SqlSchemaIR, SqlSchemaIRNode } from "@prisma-next/sql-schema-ir/types";
@@ -1 +1 @@
1
- {"version":3,"file":"issue-planner.d.mts","names":[],"sources":["../src/core/migrations/planner-strategies.ts","../src/core/migrations/issue-planner.ts"],"mappings":";;;;;;;;;;;;;;;;;;;UAwIiB,eAAA;EAAA,SACN,UAAA,EAAY,QAAA,CAAS,UAAA;EAAA,SACrB,YAAA,EAAc,QAAA,CAAS,UAAA;EAAA,SACvB,UAAA;EAAA,SACA,UAAA,EAAY,WAAA,SAAoB,iBAAA;EAAA,SAChC,YAAA,EAAc,QAAA,CAAS,MAAA,SAAe,mBAAA;EAAA,SACtC,MAAA,EAAQ,WAAA;EAAA,SACR,MAAA,EAAQ,wBAAA;EAAA,SACR,mBAAA,EAAqB,aAAA,CAAc,8BAAA;AAAA;;ACtB9C;;;;AACgD;AAoShD;KDjQY,qBAAA,IACV,MAAA,WAAiB,eAAA,IACjB,OAAA,EAAS,eAAA;EAGL,IAAA;EACA,MAAA,WAAiB,eAAA;EACjB,KAAA,WAAgB,qBAAA;EC2Pa;;;;;;;EDnP7B,MAAA;AAAA;EAEA,IAAA;AAAA;;;UCrDW,iBAAA;EAAA,SACN,KAAA,WAAgB,qBAAqB;AAAA;;;;;;;;;;iBAoShC,qBAAA,eAAoC,YAAA,GAAe,YAAA,EACjE,MAAA,WAAiB,eAAA,CAAgB,KAAA,eACvB,eAAA,CAAgB,KAAA;AAAA,UAkZX,mBAAA;EAAA,SACN,MAAA,WAAiB,eAAA;EAAA,SACjB,UAAA,EAAY,QAAA,CAAS,UAAA;EAAA,SACrB,YAAA,EAAc,QAAA,CAAS,UAAA;EAAA,SACvB,UAAA;EAAA,SACA,UAAA,EAAY,WAAA,SAAoB,iBAAA;EAAA,SAChC,YAAA,EAAc,QAAA,CAAS,MAAA,SAAe,mBAAA;EAzZd;;;;;;;EAAA,SAiaxB,MAAA,GAAS,WAAA;EAla+C;;;;;EAAA,SAwaxD,MAAA,GAAS,wBAAA;EAtaa;AAAA;AAkZjC;;EAlZiC,SA2atB,mBAAA,GAAsB,aAAA,CAAc,8BAAA;EAAA,SACpC,UAAA,YAAsB,qBAAA;AAAA;;;;;;;;iBAUjB,UAAA,CACd,OAAA,EAAS,mBAAA,GACR,MAAA,CAAO,iBAAA,WAA4B,kBAAA"}
1
+ {"version":3,"file":"issue-planner.d.mts","names":[],"sources":["../src/core/migrations/planner-strategies.ts","../src/core/migrations/issue-planner.ts"],"mappings":";;;;;;;;;;;;;;;;;;;UAwIiB,eAAA;EAAA,SACN,UAAA,EAAY,QAAA,CAAS,UAAA;EAAA,SACrB,YAAA,EAAc,QAAA,CAAS,UAAA;EAAA,SACvB,UAAA;EAAA,SACA,UAAA,EAAY,WAAA,SAAoB,iBAAA;EAAA,SAChC,YAAA,EAAc,QAAA,CAAS,MAAA,SAAe,mBAAA;EAAA,SACtC,MAAA,EAAQ,WAAA;EAAA,SACR,MAAA,EAAQ,wBAAA;EAAA,SACR,mBAAA,EAAqB,aAAA,CAAc,8BAAA;AAAA;;ACpB9C;;;;AACgD;AAqShD;KDpQY,qBAAA,IACV,MAAA,WAAiB,eAAA,IACjB,OAAA,EAAS,eAAA;EAGL,IAAA;EACA,MAAA,WAAiB,eAAA;EACjB,KAAA,WAAgB,qBAAA;EC8Pa;;;;;;;EDtP7B,MAAA;AAAA;EAEA,IAAA;AAAA;;;UCnDW,iBAAA;EAAA,SACN,KAAA,WAAgB,qBAAqB;AAAA;;;;;;;;;;iBAqShC,qBAAA,eAAoC,YAAA,GAAe,YAAA,EACjE,MAAA,WAAiB,eAAA,CAAgB,KAAA,eACvB,eAAA,CAAgB,KAAA;AAAA,UAwbX,mBAAA;EAAA,SACN,MAAA,WAAiB,eAAA;EAAA,SACjB,UAAA,EAAY,QAAA,CAAS,UAAA;EAAA,SACrB,YAAA,EAAc,QAAA,CAAS,UAAA;EAAA,SACvB,UAAA;EAAA,SACA,UAAA,EAAY,WAAA,SAAoB,iBAAA;EAAA,SAChC,YAAA,EAAc,QAAA,CAAS,MAAA,SAAe,mBAAA;EA/bd;;;;;;;EAAA,SAucxB,MAAA,GAAS,WAAA;EAxc+C;;;;;EAAA,SA8cxD,MAAA,GAAS,wBAAA;EA5ca;AAAA;AAwbjC;;EAxbiC,SAidtB,mBAAA,GAAsB,aAAA,CAAc,8BAAA;EAAA,SACpC,UAAA,YAAsB,qBAAA;AAAA;;;;;;;;iBAUjB,UAAA,CACd,OAAA,EAAS,mBAAA,GACR,MAAA,CAAO,iBAAA,WAA4B,kBAAA"}
@@ -1,2 +1,2 @@
1
- import { o as coalesceSubtreeIssues, u as planIssues } from "./control-policy-DievMCOV.mjs";
1
+ import { o as coalesceSubtreeIssues, u as planIssues } from "./control-policy-BtOZBVxL.mjs";
2
2
  export { coalesceSubtreeIssues, planIssues };
@@ -1,6 +1,6 @@
1
1
  import { n as DataTransformOptions, r as dataTransform, t as DataTransformClosure } from "./data-transform-DPzwBMhW.mjs";
2
- import { E as Op } from "./op-factory-call-Dt-Jx5JS.mjs";
3
- import { t as PostgresMigration } from "./postgres-migration-DFaxuRyI.mjs";
2
+ import { E as Op } from "./op-factory-call-D6_7-7Vc.mjs";
3
+ import { t as PostgresMigration } from "./postgres-migration-cyBe2Ee0.mjs";
4
4
  import { checkExpression, col, fn, foreignKey, lit, primaryKey, unique } from "@prisma-next/sql-relational-core/contract-free";
5
5
  import { placeholder } from "@prisma-next/errors/migration";
6
6
  import { MigrationCLI } from "@prisma-next/cli/migration-cli";
@@ -1,6 +1,6 @@
1
- import { k as createExtension } from "./op-factory-call-DZWTTjKM.mjs";
1
+ import { j as createExtension } from "./op-factory-call-DxNNKUeZ.mjs";
2
2
  import { t as dataTransform } from "./data-transform-BOWpliq8.mjs";
3
- import { t as PostgresMigration } from "./postgres-migration-D3XACWKM.mjs";
3
+ import { t as PostgresMigration } from "./postgres-migration-BahMHTbj.mjs";
4
4
  import { checkExpression, col, fn, foreignKey, lit, primaryKey, unique } from "@prisma-next/sql-relational-core/contract-free";
5
5
  import { placeholder } from "@prisma-next/errors/migration";
6
6
  import { MigrationCLI } from "@prisma-next/cli/migration-cli";
@@ -124,7 +124,39 @@ var PostgresDropPolicy = class extends PostgresDdlNode {
124
124
  return visitor.dropPolicy(this);
125
125
  }
126
126
  };
127
+ var PostgresAlterPolicyRename = class extends PostgresDdlNode {
128
+ kind = "alter-policy-rename";
129
+ schema;
130
+ table;
131
+ name;
132
+ newName;
133
+ constructor(options) {
134
+ super();
135
+ this.schema = options.schema;
136
+ this.table = options.table;
137
+ this.name = options.name;
138
+ this.newName = options.newName;
139
+ this.freeze();
140
+ }
141
+ accept(visitor) {
142
+ return visitor.alterPolicyRename(this);
143
+ }
144
+ };
145
+ var PostgresDisableRowLevelSecurity = class extends PostgresDdlNode {
146
+ kind = "disable-row-level-security";
147
+ schema;
148
+ table;
149
+ constructor(options) {
150
+ super();
151
+ this.schema = options.schema;
152
+ this.table = options.table;
153
+ this.freeze();
154
+ }
155
+ accept(visitor) {
156
+ return visitor.disableRowLevelSecurity(this);
157
+ }
158
+ };
127
159
  //#endregion
128
- export { PostgresCreateSchema as a, PostgresDropPolicy as c, PostgresCreatePolicy as i, DropDefaultAction as n, PostgresCreateTable as o, PostgresAlterTable as r, PostgresDdlNode as s, AddColumnAction as t };
160
+ export { PostgresCreatePolicy as a, PostgresDdlNode as c, PostgresAlterTable as i, PostgresDisableRowLevelSecurity as l, DropDefaultAction as n, PostgresCreateSchema as o, PostgresAlterPolicyRename as r, PostgresCreateTable as s, AddColumnAction as t, PostgresDropPolicy as u };
129
161
 
130
- //# sourceMappingURL=nodes-Dh__NS58.mjs.map
162
+ //# sourceMappingURL=nodes-B815pj_X.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"nodes-Dh__NS58.mjs","names":[],"sources":["../src/core/ddl/nodes.ts"],"sourcesContent":["import {\n type DdlColumn,\n DdlNode,\n type DdlTableConstraint,\n} from '@prisma-next/sql-relational-core/ast';\nimport type { RlsPolicyOperation } from '../rls/canonicalize';\n\n// ---------------------------------------------------------------------------\n// AlterTableAction — nested polymorphic hierarchy\n// ---------------------------------------------------------------------------\n\nexport interface AlterTableActionVisitor<R> {\n addColumn(action: AddColumnAction): R;\n dropDefault(action: DropDefaultAction): R;\n}\n\nexport abstract class AlterTableAction {\n abstract readonly kind: string;\n abstract accept<R>(visitor: AlterTableActionVisitor<R>): R;\n}\n\nexport class AddColumnAction extends AlterTableAction {\n readonly kind = 'add-column' as const;\n readonly column: DdlColumn;\n\n constructor(column: DdlColumn) {\n super();\n this.column = column;\n Object.freeze(this);\n }\n\n override accept<R>(visitor: AlterTableActionVisitor<R>): R {\n return visitor.addColumn(this);\n }\n}\n\nexport class DropDefaultAction extends AlterTableAction {\n readonly kind = 'drop-default' as const;\n readonly columnName: string;\n\n constructor(columnName: string) {\n super();\n this.columnName = columnName;\n Object.freeze(this);\n }\n\n override accept<R>(visitor: AlterTableActionVisitor<R>): R {\n return visitor.dropDefault(this);\n }\n}\n\n/**\n * The set of ALTER TABLE subactions currently expressible as typed DDL.\n *\n * The remaining actions — SetDefault, SetNotNull, DropNotNull,\n * AlterColumnType — are still emitted as raw SQL by `operations/columns.ts`\n * and join this union as they are converted to typed DDL. Until then it is\n * intentionally partial: only the ALTER subactions used by the\n * already-converted ops (AddColumn, DropDefault) appear here.\n */\nexport type AnyAlterTableAction = AddColumnAction | DropDefaultAction;\n\n// ---------------------------------------------------------------------------\n// Top-level DDL visitor\n// ---------------------------------------------------------------------------\n\nexport interface PostgresDdlVisitor<R> {\n createTable(node: PostgresCreateTable): R;\n createSchema(node: PostgresCreateSchema): R;\n alterTable(node: PostgresAlterTable): R;\n createPolicy(node: PostgresCreatePolicy): R;\n dropPolicy(node: PostgresDropPolicy): R;\n}\n\nexport abstract class PostgresDdlNode extends DdlNode {\n abstract accept<R>(visitor: PostgresDdlVisitor<R>): R;\n}\n\nfunction freezeDdlColumns(columns: readonly DdlColumn[]): ReadonlyArray<DdlColumn> {\n return Object.freeze([...columns]);\n}\n\nfunction freezeConstraints(\n constraints: readonly DdlTableConstraint[] | undefined,\n): ReadonlyArray<DdlTableConstraint> | undefined {\n return constraints ? Object.freeze([...constraints]) : undefined;\n}\n\nexport class PostgresCreateTable extends PostgresDdlNode {\n readonly kind = 'create-table' as const;\n readonly table: string;\n readonly schema: string | undefined;\n readonly ifNotExists: boolean | undefined;\n readonly columns: ReadonlyArray<DdlColumn>;\n readonly constraints: ReadonlyArray<DdlTableConstraint> | undefined;\n\n constructor(options: {\n readonly table: string;\n readonly schema?: string;\n readonly ifNotExists?: boolean;\n readonly columns: readonly DdlColumn[];\n readonly constraints?: readonly DdlTableConstraint[];\n }) {\n super();\n this.table = options.table;\n this.schema = options.schema;\n this.ifNotExists = options.ifNotExists;\n this.columns = freezeDdlColumns(options.columns);\n this.constraints = freezeConstraints(options.constraints);\n this.freeze();\n }\n\n override accept<R>(visitor: PostgresDdlVisitor<R>): R {\n return visitor.createTable(this);\n }\n}\n\nexport class PostgresCreateSchema extends PostgresDdlNode {\n readonly kind = 'create-schema' as const;\n readonly schema: string;\n readonly ifNotExists: boolean | undefined;\n\n constructor(options: { readonly schema: string; readonly ifNotExists?: boolean }) {\n super();\n this.schema = options.schema;\n this.ifNotExists = options.ifNotExists;\n this.freeze();\n }\n\n override accept<R>(visitor: PostgresDdlVisitor<R>): R {\n return visitor.createSchema(this);\n }\n}\n\nexport class PostgresAlterTable extends PostgresDdlNode {\n readonly kind = 'alter-table' as const;\n readonly table: string;\n readonly schema: string | undefined;\n readonly actions: ReadonlyArray<AnyAlterTableAction>;\n\n constructor(options: {\n readonly table: string;\n readonly schema?: string;\n readonly actions: readonly AnyAlterTableAction[];\n }) {\n super();\n this.table = options.table;\n this.schema = options.schema;\n this.actions = Object.freeze([...options.actions]);\n this.freeze();\n }\n\n override accept<R>(visitor: PostgresDdlVisitor<R>): R {\n return visitor.alterTable(this);\n }\n}\n\nexport type { RlsPolicyOperation };\n\nexport class PostgresCreatePolicy extends PostgresDdlNode {\n readonly kind = 'create-policy' as const;\n readonly schema: string;\n readonly table: string;\n readonly name: string;\n readonly permissive: boolean;\n readonly operation: RlsPolicyOperation;\n readonly roles: ReadonlyArray<string>;\n readonly using: string | undefined;\n readonly withCheck: string | undefined;\n\n constructor(options: {\n readonly schema: string;\n readonly table: string;\n readonly name: string;\n readonly permissive: boolean;\n readonly operation: RlsPolicyOperation;\n readonly roles: readonly string[];\n readonly using?: string;\n readonly withCheck?: string;\n }) {\n super();\n this.schema = options.schema;\n this.table = options.table;\n this.name = options.name;\n this.permissive = options.permissive;\n this.operation = options.operation;\n this.roles = Object.freeze([...options.roles]);\n this.using = options.using;\n this.withCheck = options.withCheck;\n this.freeze();\n }\n\n override accept<R>(visitor: PostgresDdlVisitor<R>): R {\n return visitor.createPolicy(this);\n }\n}\n\nexport class PostgresDropPolicy extends PostgresDdlNode {\n readonly kind = 'drop-policy' as const;\n readonly schema: string;\n readonly table: string;\n readonly name: string;\n\n constructor(options: { readonly schema: string; readonly table: string; readonly name: string }) {\n super();\n this.schema = options.schema;\n this.table = options.table;\n this.name = options.name;\n this.freeze();\n }\n\n override accept<R>(visitor: PostgresDdlVisitor<R>): R {\n return visitor.dropPolicy(this);\n }\n}\n\nexport type AnyPostgresDdlNode =\n | PostgresCreateTable\n | PostgresCreateSchema\n | PostgresAlterTable\n | PostgresCreatePolicy\n | PostgresDropPolicy;\n"],"mappings":";;AAgBA,IAAsB,mBAAtB,MAAuC,CAGvC;AAEA,IAAa,kBAAb,cAAqC,iBAAiB;CACpD,OAAgB;CAChB;CAEA,YAAY,QAAmB;EAC7B,MAAM;EACN,KAAK,SAAS;EACd,OAAO,OAAO,IAAI;CACpB;CAEA,OAAmB,SAAwC;EACzD,OAAO,QAAQ,UAAU,IAAI;CAC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A,OAAmB,SAAmC;EACpD,OAAO,QAAQ,WAAW,IAAI;CAChC;AACF;AAIA,IAAa,uBAAb,cAA0C,gBAAgB;CACxD,OAAgB;CAChB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA,YAAY,SAST;EACD,MAAM;EACN,KAAK,SAAS,QAAQ;EACtB,KAAK,QAAQ,QAAQ;EACrB,KAAK,OAAO,QAAQ;EACpB,KAAK,aAAa,QAAQ;EAC1B,KAAK,YAAY,QAAQ;EACzB,KAAK,QAAQ,OAAO,OAAO,CAAC,GAAG,QAAQ,KAAK,CAAC;EAC7C,KAAK,QAAQ,QAAQ;EACrB,KAAK,YAAY,QAAQ;EACzB,KAAK,OAAO;CACd;CAEA,OAAmB,SAAmC;EACpD,OAAO,QAAQ,aAAa,IAAI;CAClC;AACF;AAEA,IAAa,qBAAb,cAAwC,gBAAgB;CACtD,OAAgB;CAChB;CACA;CACA;CAEA,YAAY,SAAqF;EAC/F,MAAM;EACN,KAAK,SAAS,QAAQ;EACtB,KAAK,QAAQ,QAAQ;EACrB,KAAK,OAAO,QAAQ;EACpB,KAAK,OAAO;CACd;CAEA,OAAmB,SAAmC;EACpD,OAAO,QAAQ,WAAW,IAAI;CAChC;AACF"}
1
+ {"version":3,"file":"nodes-B815pj_X.mjs","names":[],"sources":["../src/core/ddl/nodes.ts"],"sourcesContent":["import {\n type DdlColumn,\n DdlNode,\n type DdlTableConstraint,\n} from '@prisma-next/sql-relational-core/ast';\nimport type { RlsPolicyOperation } from '../rls/canonicalize';\n\n// ---------------------------------------------------------------------------\n// AlterTableAction — nested polymorphic hierarchy\n// ---------------------------------------------------------------------------\n\nexport interface AlterTableActionVisitor<R> {\n addColumn(action: AddColumnAction): R;\n dropDefault(action: DropDefaultAction): R;\n}\n\nexport abstract class AlterTableAction {\n abstract readonly kind: string;\n abstract accept<R>(visitor: AlterTableActionVisitor<R>): R;\n}\n\nexport class AddColumnAction extends AlterTableAction {\n readonly kind = 'add-column' as const;\n readonly column: DdlColumn;\n\n constructor(column: DdlColumn) {\n super();\n this.column = column;\n Object.freeze(this);\n }\n\n override accept<R>(visitor: AlterTableActionVisitor<R>): R {\n return visitor.addColumn(this);\n }\n}\n\nexport class DropDefaultAction extends AlterTableAction {\n readonly kind = 'drop-default' as const;\n readonly columnName: string;\n\n constructor(columnName: string) {\n super();\n this.columnName = columnName;\n Object.freeze(this);\n }\n\n override accept<R>(visitor: AlterTableActionVisitor<R>): R {\n return visitor.dropDefault(this);\n }\n}\n\n/**\n * The set of ALTER TABLE subactions currently expressible as typed DDL.\n *\n * The remaining actions — SetDefault, SetNotNull, DropNotNull,\n * AlterColumnType — are still emitted as raw SQL by `operations/columns.ts`\n * and join this union as they are converted to typed DDL. Until then it is\n * intentionally partial: only the ALTER subactions used by the\n * already-converted ops (AddColumn, DropDefault) appear here.\n */\nexport type AnyAlterTableAction = AddColumnAction | DropDefaultAction;\n\n// ---------------------------------------------------------------------------\n// Top-level DDL visitor\n// ---------------------------------------------------------------------------\n\nexport interface PostgresDdlVisitor<R> {\n createTable(node: PostgresCreateTable): R;\n createSchema(node: PostgresCreateSchema): R;\n alterTable(node: PostgresAlterTable): R;\n createPolicy(node: PostgresCreatePolicy): R;\n dropPolicy(node: PostgresDropPolicy): R;\n alterPolicyRename(node: PostgresAlterPolicyRename): R;\n disableRowLevelSecurity(node: PostgresDisableRowLevelSecurity): R;\n}\n\nexport abstract class PostgresDdlNode extends DdlNode {\n abstract accept<R>(visitor: PostgresDdlVisitor<R>): R;\n}\n\nfunction freezeDdlColumns(columns: readonly DdlColumn[]): ReadonlyArray<DdlColumn> {\n return Object.freeze([...columns]);\n}\n\nfunction freezeConstraints(\n constraints: readonly DdlTableConstraint[] | undefined,\n): ReadonlyArray<DdlTableConstraint> | undefined {\n return constraints ? Object.freeze([...constraints]) : undefined;\n}\n\nexport class PostgresCreateTable extends PostgresDdlNode {\n readonly kind = 'create-table' as const;\n readonly table: string;\n readonly schema: string | undefined;\n readonly ifNotExists: boolean | undefined;\n readonly columns: ReadonlyArray<DdlColumn>;\n readonly constraints: ReadonlyArray<DdlTableConstraint> | undefined;\n\n constructor(options: {\n readonly table: string;\n readonly schema?: string;\n readonly ifNotExists?: boolean;\n readonly columns: readonly DdlColumn[];\n readonly constraints?: readonly DdlTableConstraint[];\n }) {\n super();\n this.table = options.table;\n this.schema = options.schema;\n this.ifNotExists = options.ifNotExists;\n this.columns = freezeDdlColumns(options.columns);\n this.constraints = freezeConstraints(options.constraints);\n this.freeze();\n }\n\n override accept<R>(visitor: PostgresDdlVisitor<R>): R {\n return visitor.createTable(this);\n }\n}\n\nexport class PostgresCreateSchema extends PostgresDdlNode {\n readonly kind = 'create-schema' as const;\n readonly schema: string;\n readonly ifNotExists: boolean | undefined;\n\n constructor(options: { readonly schema: string; readonly ifNotExists?: boolean }) {\n super();\n this.schema = options.schema;\n this.ifNotExists = options.ifNotExists;\n this.freeze();\n }\n\n override accept<R>(visitor: PostgresDdlVisitor<R>): R {\n return visitor.createSchema(this);\n }\n}\n\nexport class PostgresAlterTable extends PostgresDdlNode {\n readonly kind = 'alter-table' as const;\n readonly table: string;\n readonly schema: string | undefined;\n readonly actions: ReadonlyArray<AnyAlterTableAction>;\n\n constructor(options: {\n readonly table: string;\n readonly schema?: string;\n readonly actions: readonly AnyAlterTableAction[];\n }) {\n super();\n this.table = options.table;\n this.schema = options.schema;\n this.actions = Object.freeze([...options.actions]);\n this.freeze();\n }\n\n override accept<R>(visitor: PostgresDdlVisitor<R>): R {\n return visitor.alterTable(this);\n }\n}\n\nexport type { RlsPolicyOperation };\n\nexport class PostgresCreatePolicy extends PostgresDdlNode {\n readonly kind = 'create-policy' as const;\n readonly schema: string;\n readonly table: string;\n readonly name: string;\n readonly permissive: boolean;\n readonly operation: RlsPolicyOperation;\n readonly roles: ReadonlyArray<string>;\n readonly using: string | undefined;\n readonly withCheck: string | undefined;\n\n constructor(options: {\n readonly schema: string;\n readonly table: string;\n readonly name: string;\n readonly permissive: boolean;\n readonly operation: RlsPolicyOperation;\n readonly roles: readonly string[];\n readonly using?: string;\n readonly withCheck?: string;\n }) {\n super();\n this.schema = options.schema;\n this.table = options.table;\n this.name = options.name;\n this.permissive = options.permissive;\n this.operation = options.operation;\n this.roles = Object.freeze([...options.roles]);\n this.using = options.using;\n this.withCheck = options.withCheck;\n this.freeze();\n }\n\n override accept<R>(visitor: PostgresDdlVisitor<R>): R {\n return visitor.createPolicy(this);\n }\n}\n\nexport class PostgresDropPolicy extends PostgresDdlNode {\n readonly kind = 'drop-policy' as const;\n readonly schema: string;\n readonly table: string;\n readonly name: string;\n\n constructor(options: { readonly schema: string; readonly table: string; readonly name: string }) {\n super();\n this.schema = options.schema;\n this.table = options.table;\n this.name = options.name;\n this.freeze();\n }\n\n override accept<R>(visitor: PostgresDdlVisitor<R>): R {\n return visitor.dropPolicy(this);\n }\n}\n\nexport class PostgresAlterPolicyRename extends PostgresDdlNode {\n readonly kind = 'alter-policy-rename' as const;\n readonly schema: string;\n readonly table: string;\n readonly name: string;\n readonly newName: string;\n\n constructor(options: {\n readonly schema: string;\n readonly table: string;\n readonly name: string;\n readonly newName: string;\n }) {\n super();\n this.schema = options.schema;\n this.table = options.table;\n this.name = options.name;\n this.newName = options.newName;\n this.freeze();\n }\n\n override accept<R>(visitor: PostgresDdlVisitor<R>): R {\n return visitor.alterPolicyRename(this);\n }\n}\n\nexport class PostgresDisableRowLevelSecurity extends PostgresDdlNode {\n readonly kind = 'disable-row-level-security' as const;\n readonly schema: string;\n readonly table: string;\n\n constructor(options: { readonly schema: string; readonly table: string }) {\n super();\n this.schema = options.schema;\n this.table = options.table;\n this.freeze();\n }\n\n override accept<R>(visitor: PostgresDdlVisitor<R>): R {\n return visitor.disableRowLevelSecurity(this);\n }\n}\n\nexport type AnyPostgresDdlNode =\n | PostgresCreateTable\n | PostgresCreateSchema\n | PostgresAlterTable\n | PostgresCreatePolicy\n | PostgresDropPolicy\n | PostgresAlterPolicyRename\n | PostgresDisableRowLevelSecurity;\n"],"mapp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;EACpD,OAAO,QAAQ,kBAAkB,IAAI;CACvC;AACF;AAEA,IAAa,kCAAb,cAAqD,gBAAgB;CACnE,OAAgB;CAChB;CACA;CAEA,YAAY,SAA8D;EACxE,MAAM;EACN,KAAK,SAAS,QAAQ;EACtB,KAAK,QAAQ,QAAQ;EACrB,KAAK,OAAO;CACd;CAEA,OAAmB,SAAmC;EACpD,OAAO,QAAQ,wBAAwB,IAAI;CAC7C;AACF"}
@@ -38,6 +38,8 @@ interface PostgresDdlVisitor<R> {
38
38
  alterTable(node: PostgresAlterTable): R;
39
39
  createPolicy(node: PostgresCreatePolicy): R;
40
40
  dropPolicy(node: PostgresDropPolicy): R;
41
+ alterPolicyRename(node: PostgresAlterPolicyRename): R;
42
+ disableRowLevelSecurity(node: PostgresDisableRowLevelSecurity): R;
41
43
  }
42
44
  declare abstract class PostgresDdlNode extends DdlNode {
43
45
  abstract accept<R>(visitor: PostgresDdlVisitor<R>): R;
@@ -114,7 +116,31 @@ declare class PostgresDropPolicy extends PostgresDdlNode {
114
116
  });
115
117
  accept<R>(visitor: PostgresDdlVisitor<R>): R;
116
118
  }
117
- type AnyPostgresDdlNode = PostgresCreateTable | PostgresCreateSchema | PostgresAlterTable | PostgresCreatePolicy | PostgresDropPolicy;
119
+ declare class PostgresAlterPolicyRename extends PostgresDdlNode {
120
+ readonly kind: "alter-policy-rename";
121
+ readonly schema: string;
122
+ readonly table: string;
123
+ readonly name: string;
124
+ readonly newName: string;
125
+ constructor(options: {
126
+ readonly schema: string;
127
+ readonly table: string;
128
+ readonly name: string;
129
+ readonly newName: string;
130
+ });
131
+ accept<R>(visitor: PostgresDdlVisitor<R>): R;
132
+ }
133
+ declare class PostgresDisableRowLevelSecurity extends PostgresDdlNode {
134
+ readonly kind: "disable-row-level-security";
135
+ readonly schema: string;
136
+ readonly table: string;
137
+ constructor(options: {
138
+ readonly schema: string;
139
+ readonly table: string;
140
+ });
141
+ accept<R>(visitor: PostgresDdlVisitor<R>): R;
142
+ }
143
+ type AnyPostgresDdlNode = PostgresCreateTable | PostgresCreateSchema | PostgresAlterTable | PostgresCreatePolicy | PostgresDropPolicy | PostgresAlterPolicyRename | PostgresDisableRowLevelSecurity;
118
144
  //#endregion
119
- export { DropDefaultAction as a, PostgresCreateSchema as c, PostgresDdlVisitor as d, PostgresDropPolicy as f, AnyPostgresDdlNode as i, PostgresCreateTable as l, AlterTableActionVisitor as n, PostgresAlterTable as o, AnyAlterTableAction as r, PostgresCreatePolicy as s, AddColumnAction as t, PostgresDdlNode as u };
120
- //# sourceMappingURL=nodes-CSkPX3rI.d.mts.map
145
+ export { DropDefaultAction as a, PostgresCreatePolicy as c, PostgresDdlNode as d, PostgresDdlVisitor as f, AnyPostgresDdlNode as i, PostgresCreateSchema as l, PostgresDropPolicy as m, AlterTableActionVisitor as n, PostgresAlterPolicyRename as o, PostgresDisableRowLevelSecurity as p, AnyAlterTableAction as r, PostgresAlterTable as s, AddColumnAction as t, PostgresCreateTable as u };
146
+ //# sourceMappingURL=nodes-BtQyZha6.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodes-BtQyZha6.d.mts","names":[],"sources":["../src/core/ddl/nodes.ts"],"mappings":";;;;UAWiB,uBAAA;EACf,SAAA,CAAU,MAAA,EAAQ,eAAA,GAAkB,CAAA;EACpC,WAAA,CAAY,MAAA,EAAQ,iBAAA,GAAoB,CAAA;AAAA;AAAA,uBAGpB,gBAAA;EAAA,kBACF,IAAA;EAAA,SACT,MAAA,IAAU,OAAA,EAAS,uBAAA,CAAwB,CAAA,IAAK,CAAA;AAAA;AAAA,cAG9C,eAAA,SAAwB,gBAAA;EAAA,SAC1B,IAAA;EAAA,SACA,MAAA,EAAQ,SAAA;cAEL,MAAA,EAAQ,SAAA;EAMX,MAAA,IAAU,OAAA,EAAS,uBAAA,CAAwB,CAAA,IAAK,CAAA;AAAA;AAAA,cAK9C,iBAAA,SAA0B,gBAAA;EAAA,SAC5B,IAAA;EAAA,SACA,UAAA;cAEG,UAA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