@prisma/orm-target-postgres 8.0.0-rc.14-dev.20 → 8.0.0-rc.14-dev.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{adapter-zLXT8Yxm-BX8ynGWu.mjs → adapter-CBoNuaSX-Lqzxy-Qt.mjs} +3 -3
- package/dist/{adapter-zLXT8Yxm-BX8ynGWu.mjs.map → adapter-CBoNuaSX-Lqzxy-Qt.mjs.map} +1 -1
- package/dist/{adapter-DmDLDsVW.d.mts → adapter-PLCU5rSG.d.mts} +3 -3
- package/dist/{adapter-DmDLDsVW.d.mts.map → adapter-PLCU5rSG.d.mts.map} +1 -1
- package/dist/adapter.d.mts +2 -2
- package/dist/adapter.mjs +2 -2
- package/dist/adapter__adapter.d.mts +1 -1
- package/dist/adapter__adapter.mjs +1 -1
- package/dist/adapter__control.d.mts +1 -1
- package/dist/adapter__control.mjs +2 -2
- package/dist/adapter__control.mjs.map +1 -1
- package/dist/adapter__runtime.mjs +1 -1
- package/dist/adapter__runtime.mjs.map +1 -1
- package/dist/{contract-free-C0GQe4X_.mjs → contract-free-DeK6m1dy.mjs} +2 -2
- package/dist/{contract-free-C0GQe4X_.mjs.map → contract-free-DeK6m1dy.mjs.map} +1 -1
- package/dist/{contract-free-DFF0Xo-V.d.mts → contract-free-DlLLhKi4.d.mts} +2 -2
- package/dist/{contract-free-DFF0Xo-V.d.mts.map → contract-free-DlLLhKi4.d.mts.map} +1 -1
- package/dist/{control-CoZVI8XA.d.mts → control-RTK8NJRT.d.mts} +3 -3
- package/dist/{control-CoZVI8XA.d.mts.map → control-RTK8NJRT.d.mts.map} +1 -1
- package/dist/{control-adapter-DlHDFQw4-Awa40s5_.mjs → control-adapter-Rzj1Wx4j-om2RNriu.mjs} +12 -12
- package/dist/control-adapter-Rzj1Wx4j-om2RNriu.mjs.map +1 -0
- package/dist/{control-policy-B_b8ZqDi-zNYBao6-.mjs → control-policy-BDZr0Xz9-C6OPekoo.mjs} +3 -3
- package/dist/{control-policy-B_b8ZqDi-zNYBao6-.mjs.map → control-policy-BDZr0Xz9-C6OPekoo.mjs.map} +1 -1
- package/dist/{control-9MzjJLOE.mjs → control-xdedZDo5.mjs} +4 -4
- package/dist/{control-9MzjJLOE.mjs.map → control-xdedZDo5.mjs.map} +1 -1
- package/dist/ddl-B-WjvCal.d.mts +1 -0
- package/dist/{ddl-C6M0Hkbe-BSSauy2X.mjs → ddl-BQFDVert-CcDdETee.mjs} +17 -5
- package/dist/ddl-BQFDVert-CcDdETee.mjs.map +1 -0
- package/dist/{diff-database-schema-Cd6igMdS-CD3R7EC4.mjs → diff-database-schema-D_U4h-Ne-Dr3N_Zhs.mjs} +3 -3
- package/dist/{diff-database-schema-Cd6igMdS-CD3R7EC4.mjs.map → diff-database-schema-D_U4h-Ne-Dr3N_Zhs.mjs.map} +1 -1
- package/dist/{issue-planner-WWpJ3gOQ.d.mts → issue-planner-BdnqkLvV.d.mts} +2 -2
- package/dist/{issue-planner-WWpJ3gOQ.d.mts.map → issue-planner-BdnqkLvV.d.mts.map} +1 -1
- package/dist/{migration-DwqTcQ5d.d.mts → migration-D7F66l-1.d.mts} +3 -3
- package/dist/{migration-DwqTcQ5d.d.mts.map → migration-D7F66l-1.d.mts.map} +1 -1
- package/dist/migration-PTHAY9Cv.mjs.map +1 -1
- package/dist/{nodes-DAvDJLvJ-BBdvFXNa.mjs → nodes-Bm2a7z6e-BXTXyzZv.mjs} +3 -6
- package/dist/nodes-Bm2a7z6e-BXTXyzZv.mjs.map +1 -0
- package/dist/{nodes-BU-V-aZA-RqwPH68u.d.mts → nodes-C1fPapnK-j0AK7Gcj.d.mts} +21 -19
- package/dist/{nodes-BU-V-aZA-RqwPH68u.d.mts.map → nodes-C1fPapnK-j0AK7Gcj.d.mts.map} +1 -1
- package/dist/{op-factory-call-DYkz28kP-4BmpSB4B.mjs → op-factory-call-BeXmjOLn-Cm9tMP0i.mjs} +12 -12
- package/dist/op-factory-call-BeXmjOLn-Cm9tMP0i.mjs.map +1 -0
- package/dist/{op-factory-call-CmhDgfov-BjHdIpND.d.mts → op-factory-call-CaEALaar-Nh0fSxQY.d.mts} +3 -12
- package/dist/op-factory-call-CaEALaar-Nh0fSxQY.d.mts.map +1 -0
- package/dist/op-factory-call-DVz_g8zS.d.mts +1 -0
- package/dist/{planner-fD25Vk53.d.mts → planner-DECxo-qa.d.mts} +2 -2
- package/dist/{planner-fD25Vk53.d.mts.map → planner-DECxo-qa.d.mts.map} +1 -1
- package/dist/{planner-produced-postgres-migration-C3-L3nmn-BnqXdB_l.mjs → planner-produced-postgres-migration-BHWUCdp0-CPa2RncE.mjs} +3 -3
- package/dist/{planner-produced-postgres-migration-C3-L3nmn-BnqXdB_l.mjs.map → planner-produced-postgres-migration-BHWUCdp0-CPa2RncE.mjs.map} +1 -1
- package/dist/planner-produced-postgres-migration-BMfo2BlI.d.mts +1 -0
- package/dist/{planner-produced-postgres-migration-CMGC3vS6-CGdYLZFB.d.mts → planner-produced-postgres-migration-DE2Ia9Ba-hYITaAdW.d.mts} +3 -3
- package/dist/planner-produced-postgres-migration-DE2Ia9Ba-hYITaAdW.d.mts.map +1 -0
- package/dist/{planner-CbuWXI6E-CrlrOSd3.mjs → planner-rr-edfu0-5jOaQ-Xj.mjs} +7 -7
- package/dist/{planner-CbuWXI6E-CrlrOSd3.mjs.map → planner-rr-edfu0-5jOaQ-Xj.mjs.map} +1 -1
- package/dist/{postgres-migration-vpMSrXLQ-CJ72Zey3.d.mts → postgres-migration-BCzAcFmN-Bz_I02Gc.d.mts} +3 -3
- package/dist/{postgres-migration-vpMSrXLQ-CJ72Zey3.d.mts.map → postgres-migration-BCzAcFmN-Bz_I02Gc.d.mts.map} +1 -1
- package/dist/{postgres-migration-4qSv6qtX-Cj41qUBf.mjs → postgres-migration-Brm-aBQE-CatENAfZ.mjs} +5 -5
- package/dist/{postgres-migration-4qSv6qtX-Cj41qUBf.mjs.map → postgres-migration-Brm-aBQE-CatENAfZ.mjs.map} +1 -1
- package/dist/target.d.mts +12 -12
- package/dist/target.mjs +10 -10
- package/dist/target__contract-free.d.mts +1 -1
- package/dist/target__contract-free.mjs +2 -2
- package/dist/target__control.mjs +2 -2
- package/dist/target__ddl.d.mts +3 -3
- package/dist/target__ddl.mjs +1 -1
- package/dist/target__diff-database-schema.mjs +1 -1
- package/dist/target__issue-planner.d.mts +1 -1
- package/dist/target__issue-planner.mjs +1 -1
- package/dist/target__migration.d.mts +2 -2
- package/dist/target__migration.mjs +2 -2
- package/dist/target__op-factory-call.d.mts +2 -2
- package/dist/target__op-factory-call.mjs +1 -1
- package/dist/target__planner-produced-postgres-migration.d.mts +2 -2
- package/dist/target__planner-produced-postgres-migration.mjs +1 -1
- package/dist/target__planner.d.mts +1 -1
- package/dist/target__planner.mjs +2 -2
- package/package.json +9 -9
- package/dist/control-adapter-DlHDFQw4-Awa40s5_.mjs.map +0 -1
- package/dist/ddl-B4Rh8ntj.d.mts +0 -1
- package/dist/ddl-C6M0Hkbe-BSSauy2X.mjs.map +0 -1
- package/dist/nodes-DAvDJLvJ-BBdvFXNa.mjs.map +0 -1
- package/dist/op-factory-call-CmhDgfov-BjHdIpND.d.mts.map +0 -1
- package/dist/op-factory-call-DYkz28kP-4BmpSB4B.mjs.map +0 -1
- package/dist/op-factory-call-DbjizP4b.d.mts +0 -1
- package/dist/planner-produced-postgres-migration-CMGC3vS6-CGdYLZFB.d.mts.map +0 -1
- package/dist/planner-produced-postgres-migration-DJFPEI7l.d.mts +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./nodes-C1fPapnK-j0AK7Gcj.mjs";
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { S as PG_TEXT_CODEC_ID } from "./codec-ids-Cb0yO-IS--e0P2rfI.mjs";
|
|
2
2
|
import { h as postgresCreateNamespace, l as PostgresTableSource } from "./postgres-schema-C8slJGZo-CFGUyJPt.mjs";
|
|
3
|
-
import { a as PostgresAlterTable, c as PostgresCreateSchema, f as PostgresDisableRowLevelSecurity, h as PostgresDropType, i as PostgresAlterPolicyRename, l as PostgresCreateTable, m as PostgresDropPolicy, n as DropDefaultAction, o as PostgresCreateIndex, p as PostgresDropIndex, r as PostgresAlterIndexRename, s as PostgresCreatePolicy, t as AddColumnAction, u as PostgresCreateType } from "./nodes-
|
|
3
|
+
import { a as PostgresAlterTable, c as PostgresCreateSchema, f as PostgresDisableRowLevelSecurity, h as PostgresDropType, i as PostgresAlterPolicyRename, l as PostgresCreateTable, m as PostgresDropPolicy, n as DropDefaultAction, o as PostgresCreateIndex, p as PostgresDropIndex, r as PostgresAlterIndexRename, s as PostgresCreatePolicy, t as AddColumnAction, u as PostgresCreateType } from "./nodes-Bm2a7z6e-BXTXyzZv.mjs";
|
|
4
|
+
import { opaqueSql } from "@prisma/orm-family-sql/relational-core/ast";
|
|
5
|
+
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
4
6
|
import { cfExpr, cfTable, exprSelect } from "@prisma/orm-family-sql/relational-core/contract-free";
|
|
5
|
-
//#region ../../../3-targets/3-targets/postgres/dist/ddl-
|
|
7
|
+
//#region ../../../3-targets/3-targets/postgres/dist/ddl-BQFDVert.mjs
|
|
6
8
|
/**
|
|
7
9
|
* `to_regclass($1)` with the qualified table name bound as a text parameter.
|
|
8
10
|
* Thin vocabulary wrapper over the core `cfExpr.fn` helper — the target
|
|
@@ -342,7 +344,12 @@ function alterTable(options) {
|
|
|
342
344
|
* must supply safe, pre-validated SQL expressions.
|
|
343
345
|
*/
|
|
344
346
|
function createPolicy(options) {
|
|
345
|
-
|
|
347
|
+
const { using, withCheck, ...rest } = options;
|
|
348
|
+
return new PostgresCreatePolicy({
|
|
349
|
+
...rest,
|
|
350
|
+
...ifDefined("using", using === void 0 ? void 0 : opaqueSql(using)),
|
|
351
|
+
...ifDefined("withCheck", withCheck === void 0 ? void 0 : opaqueSql(withCheck))
|
|
352
|
+
});
|
|
346
353
|
}
|
|
347
354
|
/**
|
|
348
355
|
* Build a Postgres `DROP POLICY` DDL node.
|
|
@@ -366,7 +373,12 @@ function alterPolicyRename(options) {
|
|
|
366
373
|
* names unqualified (the unbound namespace).
|
|
367
374
|
*/
|
|
368
375
|
function createIndex(options) {
|
|
369
|
-
|
|
376
|
+
const { elements, where, ...rest } = options;
|
|
377
|
+
return new PostgresCreateIndex({
|
|
378
|
+
...rest,
|
|
379
|
+
elements: "columns" in elements ? { columns: elements.columns } : { expression: opaqueSql(elements.expression) },
|
|
380
|
+
where: where === void 0 ? void 0 : opaqueSql(where)
|
|
381
|
+
});
|
|
370
382
|
}
|
|
371
383
|
/**
|
|
372
384
|
* Build a Postgres `DROP INDEX` DDL node. The index name (and optional
|
|
@@ -392,4 +404,4 @@ function disableRowLevelSecurity(options) {
|
|
|
392
404
|
//#endregion
|
|
393
405
|
export { toRegclass as A, nativeEnumValueExistsAst as C, tableExistsAst as D, rlsPolicyExistsAst as E, tableIsEmptyAst as O, nativeEnumTypeExistsAst as S, rlsEnabledAst as T, dropIndex as _, columnDefaultAst as a, extensionExistsAst as b, columnTypeAst as c, createPolicy as d, createSchema as f, dropDefaultAction as g, disableRowLevelSecurity as h, alterTable as i, tablePrimaryKeyAst as k, constraintExistsAst as l, createType as m, alterIndexRename as n, columnExistsAst as o, createTable as p, alterPolicyRename as r, columnNullabilityAst as s, addColumnAction as t, createIndex as u, dropPolicy as v, noNullValuesAst as w, indexExistsAst as x, dropType as y };
|
|
394
406
|
|
|
395
|
-
//# sourceMappingURL=ddl-
|
|
407
|
+
//# sourceMappingURL=ddl-BQFDVert-CcDdETee.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ddl-BQFDVert-CcDdETee.mjs","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/ddl-BQFDVert.mjs"],"sourcesContent":["import { S as PG_TEXT_CODEC_ID } from \"./codec-ids-Cb0yO-IS.mjs\";\nimport { i as postgresCreateNamespace, u as PostgresTableSource } from \"./postgres-schema-C8slJGZo.mjs\";\nimport { a as PostgresAlterTable, c as PostgresCreateSchema, f as PostgresDisableRowLevelSecurity, h as PostgresDropType, i as PostgresAlterPolicyRename, l as PostgresCreateTable, m as PostgresDropPolicy, n as DropDefaultAction, o as PostgresCreateIndex, p as PostgresDropIndex, r as PostgresAlterIndexRename, s as PostgresCreatePolicy, t as AddColumnAction, u as PostgresCreateType } from \"./nodes-Bm2a7z6e.mjs\";\nimport { opaqueSql } from \"@internal/sql-relational-core/ast\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { cfExpr, cfTable, exprSelect } from \"@internal/sql-relational-core/contract-free\";\n//#region src/contract-free/checks.ts\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*/\nfunction toRegclass(qualifiedName) {\n\treturn cfExpr.fn({\n\t\tmethod: \"to_regclass\",\n\t\ttemplate: \"to_regclass({{self}})\",\n\t\tself: cfExpr.param(qualifiedName, PG_TEXT_CODEC_ID),\n\t\treturns: {\n\t\t\tcodecId: PG_TEXT_CODEC_ID,\n\t\t\tnullable: true\n\t\t}\n\t});\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*/\nfunction tableExistsAst(schema, table) {\n\tconst regclass = toRegclass(postgresCreateNamespace({\n\t\tid: schema,\n\t\tentries: { table: {} }\n\t}).qualifyTable(table));\n\treturn {\n\t\ttableAbsent: () => exprSelect().project(\"result\", regclass.isNull()).build(),\n\t\ttablePresent: () => exprSelect().project(\"result\", regclass.isNotNull()).build()\n\t};\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*/\nfunction constraintExistsAst(options) {\n\tconst namespace = postgresCreateNamespace({\n\t\tid: options.schema,\n\t\tentries: { table: {} }\n\t});\n\tconst conditions = [cfExpr.columnRef(\"c\", \"conname\").eqParam(options.constraintName, PG_TEXT_CODEC_ID), cfExpr.columnRef(\"n\", \"nspname\").eqExpr(namespace.schemaFilterExpression())];\n\tif (options.table !== void 0) conditions.push(cfExpr.columnRef(\"c\", \"conrelid\").eqExpr(toRegclass(namespace.qualifyTable(options.table))));\n\tconst inner = () => exprSelect().from(cfTable(\"pg_constraint\", \"c\")).join(cfTable(\"pg_namespace\", \"n\"), cfExpr.columnRef(\"n\", \"oid\").eqExpr(cfExpr.columnRef(\"c\", \"connamespace\"))).project(\"one\", cfExpr.lit(1)).where(cfExpr.allOf(conditions));\n\treturn {\n\t\tconstraintPresent: () => exprSelect().project(\"result\", cfExpr.exists(inner())).build(),\n\t\tconstraintAbsent: () => exprSelect().project(\"result\", cfExpr.notExists(inner())).build()\n\t};\n}\nfunction checkNamespace(schema) {\n\treturn postgresCreateNamespace({\n\t\tid: schema,\n\t\tentries: { table: {} }\n\t});\n}\nfunction informationSchemaColumns() {\n\treturn new PostgresTableSource({\n\t\tschema: \"information_schema\",\n\t\tname: \"columns\"\n\t});\n}\nfunction infoSchemaColumnConditions(options) {\n\treturn [\n\t\tcfExpr.identifierRef(\"table_schema\").eqExpr(checkNamespace(options.schema).schemaFilterExpression()),\n\t\tcfExpr.identifierRef(\"table_name\").eqParam(options.table, PG_TEXT_CODEC_ID),\n\t\tcfExpr.identifierRef(\"column_name\").eqParam(options.column, PG_TEXT_CODEC_ID)\n\t];\n}\nfunction infoSchemaColumnQuery(conditions) {\n\treturn exprSelect().from(informationSchemaColumns()).project(\"one\", cfExpr.lit(1)).where(cfExpr.allOf(conditions));\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*/\nfunction columnExistsAst(options) {\n\tconst inner = () => infoSchemaColumnQuery(infoSchemaColumnConditions(options));\n\treturn {\n\t\tcolumnPresent: () => exprSelect().project(\"result\", cfExpr.exists(inner())).build(),\n\t\tcolumnAbsent: () => exprSelect().project(\"result\", cfExpr.notExists(inner())).build()\n\t};\n}\n/**\n* Typed nullability check: EXISTS over `information_schema.columns` with\n* `is_nullable` compared against the bound `'YES'` / `'NO'` marker.\n*/\nfunction columnNullabilityAst(options) {\n\tconst conditions = [...infoSchemaColumnConditions(options), cfExpr.identifierRef(\"is_nullable\").eqParam(options.nullable ? \"YES\" : \"NO\", PG_TEXT_CODEC_ID)];\n\treturn exprSelect().project(\"result\", cfExpr.exists(infoSchemaColumnQuery(conditions))).build();\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*/\nfunction columnDefaultAst(options) {\n\tconst withDefault = () => infoSchemaColumnQuery([...infoSchemaColumnConditions(options), cfExpr.identifierRef(\"column_default\").isNotNull()]);\n\tconst withoutDefault = () => infoSchemaColumnQuery([...infoSchemaColumnConditions(options), cfExpr.identifierRef(\"column_default\").isNull()]);\n\treturn {\n\t\tdefaultPresent: () => exprSelect().project(\"result\", cfExpr.exists(withDefault())).build(),\n\t\tdefaultAbsent: () => exprSelect().project(\"result\", cfExpr.exists(withoutDefault())).build(),\n\t\tnoDefault: () => exprSelect().project(\"result\", cfExpr.notExists(withDefault())).build()\n\t};\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*/\nfunction columnTypeAst(options) {\n\tconst formatType = cfExpr.fn({\n\t\tmethod: \"format_type\",\n\t\ttemplate: \"format_type({{self}}, {{arg0}})\",\n\t\tself: cfExpr.columnRef(\"a\", \"atttypid\"),\n\t\targs: [cfExpr.columnRef(\"a\", \"atttypmod\")],\n\t\treturns: {\n\t\t\tcodecId: PG_TEXT_CODEC_ID,\n\t\t\tnullable: false\n\t\t}\n\t});\n\tconst inner = exprSelect().from(cfTable(\"pg_attribute\", \"a\")).join(cfTable(\"pg_class\", \"c\"), cfExpr.columnRef(\"c\", \"oid\").eqExpr(cfExpr.columnRef(\"a\", \"attrelid\"))).join(cfTable(\"pg_namespace\", \"n\"), cfExpr.columnRef(\"n\", \"oid\").eqExpr(cfExpr.columnRef(\"c\", \"relnamespace\"))).project(\"one\", cfExpr.lit(1)).where(cfExpr.allOf([\n\t\tcfExpr.columnRef(\"n\", \"nspname\").eqExpr(checkNamespace(options.schema).schemaFilterExpression()),\n\t\tcfExpr.columnRef(\"c\", \"relname\").eqParam(options.table, PG_TEXT_CODEC_ID),\n\t\tcfExpr.columnRef(\"a\", \"attname\").eqParam(options.column, PG_TEXT_CODEC_ID),\n\t\tformatType.eqParam(options.expectedType, PG_TEXT_CODEC_ID),\n\t\tcfExpr.columnRef(\"a\", \"attisdropped\").not()\n\t]));\n\treturn exprSelect().project(\"result\", cfExpr.exists(inner)).build();\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*/\nfunction tablePrimaryKeyAst(options) {\n\tconst conditions = [\n\t\tcfExpr.columnRef(\"n\", \"nspname\").eqExpr(checkNamespace(options.schema).schemaFilterExpression()),\n\t\tcfExpr.columnRef(\"c\", \"relname\").eqParam(options.table, PG_TEXT_CODEC_ID),\n\t\tcfExpr.columnRef(\"i\", \"indisprimary\")\n\t];\n\tif (options.constraintName !== void 0) conditions.push(cfExpr.columnRef(\"c2\", \"relname\").eqParam(options.constraintName, PG_TEXT_CODEC_ID));\n\tconst inner = () => exprSelect().from(cfTable(\"pg_index\", \"i\")).join(cfTable(\"pg_class\", \"c\"), cfExpr.columnRef(\"c\", \"oid\").eqExpr(cfExpr.columnRef(\"i\", \"indrelid\"))).join(cfTable(\"pg_namespace\", \"n\"), cfExpr.columnRef(\"n\", \"oid\").eqExpr(cfExpr.columnRef(\"c\", \"relnamespace\"))).leftJoin(cfTable(\"pg_class\", \"c2\"), cfExpr.columnRef(\"c2\", \"oid\").eqExpr(cfExpr.columnRef(\"i\", \"indexrelid\"))).project(\"one\", cfExpr.lit(1)).where(cfExpr.allOf(conditions));\n\treturn {\n\t\tpkPresent: () => exprSelect().project(\"result\", cfExpr.exists(inner())).build(),\n\t\tpkAbsent: () => exprSelect().project(\"result\", cfExpr.notExists(inner())).build()\n\t};\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*/\nfunction tableIsEmptyAst(schema, table) {\n\tconst inner = exprSelect().from(checkNamespace(schema).tableSource(table)).project(\"one\", cfExpr.lit(1)).limit(1);\n\treturn exprSelect().project(\"result\", cfExpr.notExists(inner)).build();\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*/\nfunction noNullValuesAst(options) {\n\tconst inner = exprSelect().from(checkNamespace(options.schema).tableSource(options.table)).project(\"one\", cfExpr.lit(1)).where(cfExpr.identifierRef(options.column).isNull());\n\treturn exprSelect().project(\"result\", cfExpr.notExists(inner)).build();\n}\n/**\n* Typed extension existence check over `pg_extension`, with the extension\n* name bound as a text parameter.\n*/\nfunction extensionExistsAst(extensionName) {\n\tconst inner = () => exprSelect().from(cfTable(\"pg_extension\")).project(\"one\", cfExpr.lit(1)).where(cfExpr.identifierRef(\"extname\").eqParam(extensionName, PG_TEXT_CODEC_ID));\n\treturn {\n\t\textensionPresent: () => exprSelect().project(\"result\", cfExpr.exists(inner())).build(),\n\t\textensionAbsent: () => exprSelect().project(\"result\", cfExpr.notExists(inner())).build()\n\t};\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*/\nfunction rlsPolicyExistsAst(options) {\n\tconst inner = () => exprSelect().from(cfTable(\"pg_policies\")).project(\"one\", cfExpr.lit(1)).where(cfExpr.allOf([\n\t\tcfExpr.identifierRef(\"schemaname\").eqParam(options.schema, PG_TEXT_CODEC_ID),\n\t\tcfExpr.identifierRef(\"tablename\").eqParam(options.table, PG_TEXT_CODEC_ID),\n\t\tcfExpr.identifierRef(\"policyname\").eqParam(options.policyName, PG_TEXT_CODEC_ID)\n\t]));\n\treturn {\n\t\tpolicyPresent: () => exprSelect().project(\"result\", cfExpr.exists(inner())).build(),\n\t\tpolicyAbsent: () => exprSelect().project(\"result\", cfExpr.notExists(inner())).build()\n\t};\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*/\nfunction rlsEnabledAst(schema, table) {\n\tconst inner = (enabled) => exprSelect().from(cfTable(\"pg_class\", \"c\")).join(cfTable(\"pg_namespace\", \"n\"), cfExpr.columnRef(\"n\", \"oid\").eqExpr(cfExpr.columnRef(\"c\", \"relnamespace\"))).project(\"one\", cfExpr.lit(1)).where(cfExpr.allOf([\n\t\tcfExpr.columnRef(\"n\", \"nspname\").eqParam(schema, PG_TEXT_CODEC_ID),\n\t\tcfExpr.columnRef(\"c\", \"relname\").eqParam(table, PG_TEXT_CODEC_ID),\n\t\tenabled ? cfExpr.columnRef(\"c\", \"relrowsecurity\") : cfExpr.columnRef(\"c\", \"relrowsecurity\").not()\n\t]));\n\treturn {\n\t\trlsEnabled: () => exprSelect().project(\"result\", cfExpr.exists(inner(true))).build(),\n\t\trlsDisabled: () => exprSelect().project(\"result\", cfExpr.exists(inner(false))).build()\n\t};\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*/\nfunction indexExistsAst(schema, indexName) {\n\tconst regclass = toRegclass(checkNamespace(schema).qualifyTable(indexName));\n\treturn {\n\t\tindexPresent: () => exprSelect().project(\"result\", regclass.isNotNull()).build(),\n\t\tindexAbsent: () => exprSelect().project(\"result\", regclass.isNull()).build()\n\t};\n}\n/**\n* Typed native-enum type existence check over `pg_type` joined to\n* `pg_namespace`, restricted to enum types (`typtype = 'e'`). Schema and\n* type name are bound as text parameters; `schema` is a namespace\n* coordinate (the `__unbound__` sentinel compares against\n* `current_schema()`), matching {@link tableExistsAst} et al.\n*/\nfunction nativeEnumTypeExistsAst(schema, typeName) {\n\tconst inner = () => exprSelect().from(cfTable(\"pg_type\", \"t\")).join(cfTable(\"pg_namespace\", \"n\"), cfExpr.columnRef(\"n\", \"oid\").eqExpr(cfExpr.columnRef(\"t\", \"typnamespace\"))).project(\"one\", cfExpr.lit(1)).where(cfExpr.allOf([\n\t\tcfExpr.columnRef(\"n\", \"nspname\").eqExpr(checkNamespace(schema).schemaFilterExpression()),\n\t\tcfExpr.columnRef(\"t\", \"typname\").eqParam(typeName, PG_TEXT_CODEC_ID),\n\t\tcfExpr.columnRef(\"t\", \"typtype\").eqParam(\"e\", PG_TEXT_CODEC_ID)\n\t]));\n\treturn {\n\t\ttypePresent: () => exprSelect().project(\"result\", cfExpr.exists(inner())).build(),\n\t\ttypeAbsent: () => exprSelect().project(\"result\", cfExpr.notExists(inner())).build()\n\t};\n}\n/**\n* Typed native-enum member-value existence check over `pg_enum` joined to\n* `pg_type` and `pg_namespace`. Schema, type name, and the candidate member\n* value are bound as text parameters — used by `addNativeEnumValue`'s\n* precheck (value absent) and postcheck (value present).\n*/\nfunction nativeEnumValueExistsAst(options) {\n\tconst inner = () => exprSelect().from(cfTable(\"pg_enum\", \"e\")).join(cfTable(\"pg_type\", \"t\"), cfExpr.columnRef(\"t\", \"oid\").eqExpr(cfExpr.columnRef(\"e\", \"enumtypid\"))).join(cfTable(\"pg_namespace\", \"n\"), cfExpr.columnRef(\"n\", \"oid\").eqExpr(cfExpr.columnRef(\"t\", \"typnamespace\"))).project(\"one\", cfExpr.lit(1)).where(cfExpr.allOf([\n\t\tcfExpr.columnRef(\"n\", \"nspname\").eqExpr(checkNamespace(options.schema).schemaFilterExpression()),\n\t\tcfExpr.columnRef(\"t\", \"typname\").eqParam(options.typeName, PG_TEXT_CODEC_ID),\n\t\tcfExpr.columnRef(\"e\", \"enumlabel\").eqParam(options.value, PG_TEXT_CODEC_ID)\n\t]));\n\treturn {\n\t\tvaluePresent: () => exprSelect().project(\"result\", cfExpr.exists(inner())).build(),\n\t\tvalueAbsent: () => exprSelect().project(\"result\", cfExpr.notExists(inner())).build()\n\t};\n}\n//#endregion\n//#region src/contract-free/ddl.ts\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 `@internal/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*/\nfunction createTable(options) {\n\treturn new PostgresCreateTable(options);\n}\n/**\n* Build a Postgres `CREATE SCHEMA` query node. See {@link createTable} for the\n* pre-trusted-identifier precondition.\n*/\nfunction createSchema(options) {\n\treturn new PostgresCreateSchema(options);\n}\n/**\n* Build a Postgres `CREATE TYPE … AS ENUM (…)` DDL node. The type name (and\n* optional schema) are quoted by the renderer; the enum member `values` are\n* emitted as single-quote-escaped string literals. An absent `schema` renders\n* the type name unqualified so the connection's `search_path` resolves it.\n*/\nfunction createType(options) {\n\treturn new PostgresCreateType(options);\n}\n/**\n* Build a Postgres `DROP TYPE` DDL node. See {@link createType} for the\n* identifier-quoting and unqualified-when-schemaless behaviour.\n*/\nfunction dropType(options) {\n\treturn new PostgresDropType(options);\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*/\nfunction addColumnAction(column) {\n\treturn new AddColumnAction(column);\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*/\nfunction dropDefaultAction(columnName) {\n\treturn new DropDefaultAction(columnName);\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*/\nfunction alterTable(options) {\n\treturn new PostgresAlterTable(options);\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*/\nfunction createPolicy(options) {\n\tconst { using, withCheck, ...rest } = options;\n\treturn new PostgresCreatePolicy({\n\t\t...rest,\n\t\t...ifDefined(\"using\", using === void 0 ? void 0 : opaqueSql(using)),\n\t\t...ifDefined(\"withCheck\", withCheck === void 0 ? void 0 : opaqueSql(withCheck))\n\t});\n}\n/**\n* Build a Postgres `DROP POLICY` DDL node.\n* Identifiers (`schema`, `table`, `name`) are quoted by the renderer.\n*/\nfunction dropPolicy(options) {\n\treturn new PostgresDropPolicy(options);\n}\n/**\n* Build a Postgres `ALTER POLICY … RENAME TO` DDL node.\n* Identifiers (`schema`, `table`, `name`, `newName`) are quoted by the renderer.\n*/\nfunction alterPolicyRename(options) {\n\treturn new PostgresAlterPolicyRename(options);\n}\n/**\n* Build a Postgres `CREATE [UNIQUE] INDEX` DDL node. Identifiers (`schema`,\n* `table`, `name`, column elements, `type`, option keys) are quoted by the\n* renderer; the `expression` element list and the `where` predicate are\n* inserted verbatim (opaque SQL). An absent `schema` renders the object\n* names unqualified (the unbound namespace).\n*/\nfunction createIndex(options) {\n\tconst { elements, where, ...rest } = options;\n\treturn new PostgresCreateIndex({\n\t\t...rest,\n\t\telements: \"columns\" in elements ? { columns: elements.columns } : { expression: opaqueSql(elements.expression) },\n\t\twhere: where === void 0 ? void 0 : opaqueSql(where)\n\t});\n}\n/**\n* Build a Postgres `DROP INDEX` DDL node. The index name (and optional\n* schema) are quoted by the renderer.\n*/\nfunction dropIndex(options) {\n\treturn new PostgresDropIndex(options);\n}\n/**\n* Build a Postgres `ALTER INDEX … RENAME TO` DDL node. Identifiers are\n* quoted by the renderer.\n*/\nfunction alterIndexRename(options) {\n\treturn new PostgresAlterIndexRename(options);\n}\n/**\n* Build a Postgres `ALTER TABLE … DISABLE ROW LEVEL SECURITY` DDL node.\n* Identifiers (`schema`, `table`) are quoted by the renderer.\n*/\nfunction disableRowLevelSecurity(options) {\n\treturn new PostgresDisableRowLevelSecurity(options);\n}\n//#endregion\nexport { toRegclass as A, nativeEnumValueExistsAst as C, tableExistsAst as D, rlsPolicyExistsAst as E, tableIsEmptyAst as O, nativeEnumTypeExistsAst as S, rlsEnabledAst as T, columnNullabilityAst as _, createIndex as a, extensionExistsAst as b, createTable as c, dropDefaultAction as d, dropIndex as f, columnExistsAst as g, columnDefaultAst as h, alterTable as i, tablePrimaryKeyAst as k, createType as l, dropType as m, alterIndexRename as n, createPolicy as o, dropPolicy as p, alterPolicyRename as r, createSchema as s, addColumnAction as t, disableRowLevelSecurity as u, columnTypeAst as v, noNullValuesAst as w, indexExistsAst as x, constraintExistsAst as y };\n\n//# sourceMappingURL=ddl-BQFDVert.mjs.map"],"mappings":";;;;;;;;;;;;AAYA,SAAS,WAAW,eAAe;CAClC,OAAO,OAAO,GAAG;EAChB,QAAQ;EACR,UAAU;EACV,MAAM,OAAO,MAAM,eAAe,gBAAgB;EAClD,SAAS;GACR,SAAS;GACT,UAAU;EACX;CACD,CAAC;AACF;;;;;;;;;;AAUA,SAAS,eAAe,QAAQ,OAAO;CACtC,MAAM,WAAW,WAAW,wBAAwB;EACnD,IAAI;EACJ,SAAS,EAAE,OAAO,CAAC,EAAE;CACtB,CAAC,CAAC,CAAC,aAAa,KAAK,CAAC;CACtB,OAAO;EACN,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;CAChF;AACD;;;;;;;;;;;;;;;AAeA,SAAS,oBAAoB,SAAS;CACrC,MAAM,YAAY,wBAAwB;EACzC,IAAI,QAAQ;EACZ,SAAS,EAAE,OAAO,CAAC,EAAE;CACtB,CAAC;CACD,MAAM,aAAa,CAAC,OAAO,UAAU,KAAK,SAAS,CAAC,CAAC,QAAQ,QAAQ,gBAAgB,gBAAgB,GAAG,OAAO,UAAU,KAAK,SAAS,CAAC,CAAC,OAAO,UAAU,uBAAuB,CAAC,CAAC;CACnL,IAAI,QAAQ,UAAU,KAAK,GAAG,WAAW,KAAK,OAAO,UAAU,KAAK,UAAU,CAAC,CAAC,OAAO,WAAW,UAAU,aAAa,QAAQ,KAAK,CAAC,CAAC,CAAC;CACzI,MAAM,cAAc,WAAW,CAAC,CAAC,KAAK,QAAQ,iBAAiB,GAAG,CAAC,CAAC,CAAC,KAAK,QAAQ,gBAAgB,GAAG,GAAG,OAA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D,CAAC;AACF;;;;;AAKA,SAAS,UAAU,SAAS;CAC3B,OAAO,IAAI,kBAAkB,OAAO;AACrC;;;;;AAKA,SAAS,iBAAiB,SAAS;CAClC,OAAO,IAAI,yBAAyB,OAAO;AAC5C;;;;;AAKA,SAAS,wBAAwB,SAAS;CACzC,OAAO,IAAI,gCAAgC,OAAO;AACnD"}
|
|
@@ -5,7 +5,7 @@ import { i as PostgresRoleSchemaNode, n as PostgresNamespaceSchemaNode, r as Pos
|
|
|
5
5
|
import { n as postgresResolveDefault } from "./default-normalizer-Cb7nWBUa-DXchlOUk.mjs";
|
|
6
6
|
import { t as resolveDdlSchemaForNamespaceStorage } from "./resolve-ddl-schema-Bq4m2dD9-DrlUipYU.mjs";
|
|
7
7
|
import { n as normalizeSchemaNativeType, r as withLengthOneWhenBare } from "./native-type-normalizer-CW6g9Fut-C5lMRRjS.mjs";
|
|
8
|
-
import { m as resolvePostgresNodeIssueControlPolicySubject } from "./control-policy-
|
|
8
|
+
import { m as resolvePostgresNodeIssueControlPolicySubject } from "./control-policy-BDZr0Xz9-C6OPekoo.mjs";
|
|
9
9
|
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
10
10
|
import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
|
|
11
11
|
import { diffSchemas, issueOutcome } from "@prisma/orm-framework/components/control";
|
|
@@ -14,7 +14,7 @@ import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
|
14
14
|
import { buildDataTypeResolver, buildNativeTypeExpander, contractNamespaceToSchemaIR } from "@prisma/orm-family-sql/family/control";
|
|
15
15
|
import { PrimaryKey, RelationalSchemaNodeKind, SqlForeignKeyIR, SqlIndexIR, SqlUniqueIR } from "@prisma/orm-family-sql/schema-ir/types";
|
|
16
16
|
import { classifyDiffSubjectGranularity } from "@prisma/orm-family-sql/family/diff";
|
|
17
|
-
//#region ../../../3-targets/3-targets/postgres/dist/diff-database-schema-
|
|
17
|
+
//#region ../../../3-targets/3-targets/postgres/dist/diff-database-schema-D_U4h-Ne.mjs
|
|
18
18
|
/** The database root's fixed sentinel id (`PostgresDatabaseSchemaNode#id`). */
|
|
19
19
|
function databaseStep() {
|
|
20
20
|
return {
|
|
@@ -399,4 +399,4 @@ function buildPostgresPlanDiff(input) {
|
|
|
399
399
|
//#endregion
|
|
400
400
|
export { diffPostgresSchema as i, buildPostgresPlanDiff as n, contractToPostgresDatabaseSchemaNode as r, buildPostgresNativeTypeExpander as t };
|
|
401
401
|
|
|
402
|
-
//# sourceMappingURL=diff-database-schema-
|
|
402
|
+
//# sourceMappingURL=diff-database-schema-D_U4h-Ne-Dr3N_Zhs.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff-database-schema-Cd6igMdS-CD3R7EC4.mjs","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/diff-database-schema-Cd6igMdS.mjs"],"sourcesContent":["import { s as postgresError } from \"./errors-DYyzTYzE.mjs\";\nimport { r as isPostgresSchema } from \"./postgres-schema-C8slJGZo.mjs\";\nimport { n as postgresResolveDefault } from \"./default-normalizer-Cb7nWBUa.mjs\";\nimport { a as postgresDiffSubjectGranularity, n as PostgresNativeEnumSchemaNode, r as PostgresSchemaNodeKind, t as PostgresTableSchemaNode } from \"./postgres-table-schema-node-BBkitBQh.mjs\";\nimport { i as PostgresDatabaseSchemaNode, n as PostgresPolicySchemaNode, r as PostgresNamespaceSchemaNode, t as PostgresRoleSchemaNode } from \"./postgres-role-schema-node-B8Z5i5D-.mjs\";\nimport { t as resolveDdlSchemaForNamespaceStorage } from \"./resolve-ddl-schema-Bq4m2dD9.mjs\";\nimport { i as resolvePostgresNodeIssueControlPolicySubject } from \"./control-policy-B_b8ZqDi.mjs\";\nimport { n as normalizeSchemaNativeType, r as withLengthOneWhenBare } from \"./native-type-normalizer-CW6g9Fut.mjs\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { diffSchemas, issueOutcome } from \"@internal/framework-components/control\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { buildDataTypeResolver, buildNativeTypeExpander, contractNamespaceToSchemaIR } from \"@internal/family-sql/control\";\nimport { namingOf } from \"@internal/sql-schema-ir/naming\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { classifyDiffSubjectGranularity } from \"@internal/family-sql/diff\";\nimport { PrimaryKey, RelationalSchemaNodeKind, SqlForeignKeyIR, SqlIndexIR, SqlUniqueIR } from \"@internal/sql-schema-ir/types\";\n//#region src/core/migrations/contract-to-postgres-database-schema-node.ts\n/** The database root's fixed sentinel id (`PostgresDatabaseSchemaNode#id`). */\nfunction databaseStep() {\n\treturn {\n\t\tnodeKind: PostgresSchemaNodeKind.database,\n\t\tid: \"database\"\n\t};\n}\nfunction tableDependsOn(namespaceId, tableName) {\n\treturn [\n\t\tdatabaseStep(),\n\t\t{\n\t\t\tnodeKind: PostgresSchemaNodeKind.namespace,\n\t\t\tid: namespaceId\n\t\t},\n\t\t{\n\t\t\tnodeKind: PostgresSchemaNodeKind.table,\n\t\t\tid: tableName\n\t\t}\n\t];\n}\nfunction roleDependsOn(role) {\n\treturn [databaseStep(), {\n\t\tnodeKind: PostgresSchemaNodeKind.role,\n\t\tid: role\n\t}];\n}\n/**\n* The chains from a table-child object (foreign key, index, unique, primary\n* key) to each of the own columns it is built on, in the Postgres tree.\n* Dropping a covered column auto-drops the object, so the object's drop must\n* precede the column's; the graph derives that direction from these edges.\n*/\nfunction columnDependsOn(namespaceId, tableName, columns) {\n\treturn columns.map((column) => [...tableDependsOn(namespaceId, tableName), {\n\t\tnodeKind: RelationalSchemaNodeKind.column,\n\t\tid: `column:${column}`\n\t}]);\n}\nfunction toPolicyNode(policy, namespaceId) {\n\treturn new PostgresPolicySchemaNode({\n\t\tnaming: namingOf(policy.name, policy.prefix),\n\t\ttableName: policy.tableName,\n\t\tnamespaceId,\n\t\toperation: policy.operation,\n\t\troles: [...policy.roles],\n\t\tusing: policy.using,\n\t\twithCheck: policy.withCheck,\n\t\tpermissive: policy.permissive,\n\t\tdependsOn: [tableDependsOn(namespaceId, policy.tableName), ...policy.roles.map(roleDependsOn)]\n\t});\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*/\nfunction contractToPostgresDatabaseSchemaNode(contract, options) {\n\tif (contract === null) return new PostgresDatabaseSchemaNode({\n\t\tnamespaces: {},\n\t\troles: [],\n\t\texistingSchemas: [],\n\t\tpgVersion: \"\"\n\t});\n\tconst namespaces = {};\n\tconst roles = [];\n\tconst ownedSchemas = [];\n\tfor (const ns of Object.values(contract.storage.namespaces)) {\n\t\tif (!isPostgresSchema(ns)) continue;\n\t\tfor (const role of Object.values(ns.role)) roles.push(new PostgresRoleSchemaNode({\n\t\t\tname: role.name,\n\t\t\tnamespaceId: role.namespaceId\n\t\t}));\n\t\tif (ns.id === UNBOUND_NAMESPACE_ID) {\n\t\t\tif (!Object.entries(ns.entries).some(([entriesKey, slot]) => entriesKey !== \"role\" && Object.keys(slot).length > 0)) continue;\n\t\t}\n\t\tconst ddlSchema = resolveDdlSchemaForNamespaceStorage(contract.storage, ns.id);\n\t\townedSchemas.push(ddlSchema);\n\t\tconst sqlTables = contractNamespaceToSchemaIR(contract.storage, ns.id, options).tables;\n\t\tconst policiesByTable = /* @__PURE__ */ new Map();\n\t\tfor (const policy of Object.values(ns.policy)) {\n\t\t\tconst list = policiesByTable.get(policy.tableName) ?? [];\n\t\t\tlist.push(toPolicyNode(policy, ddlSchema));\n\t\t\tpoliciesByTable.set(policy.tableName, list);\n\t\t}\n\t\tconst tables = {};\n\t\tfor (const tableName of Object.keys(ns.table)) {\n\t\t\tconst sqlTable = sqlTables[tableName];\n\t\t\tif (sqlTable === void 0) continue;\n\t\t\tconst foreignKeys = sqlTable.foreignKeys.map((fk) => {\n\t\t\t\tconst resolvedReferencedNamespace = resolveDdlSchemaForNamespaceStorage(contract.storage, fk.referencedSchema ?? UNBOUND_NAMESPACE_ID);\n\t\t\t\treturn new SqlForeignKeyIR({\n\t\t\t\t\tcolumns: fk.columns,\n\t\t\t\t\treferencedTable: fk.referencedTable,\n\t\t\t\t\treferencedColumns: fk.referencedColumns,\n\t\t\t\t\treferencedSchema: fk.referencedSchema ?? UNBOUND_NAMESPACE_ID,\n\t\t\t\t\t...ifDefined(\"name\", fk.name),\n\t\t\t\t\t...ifDefined(\"onDelete\", fk.onDelete),\n\t\t\t\t\t...ifDefined(\"onUpdate\", fk.onUpdate),\n\t\t\t\t\t...ifDefined(\"annotations\", fk.annotations),\n\t\t\t\t\tresolvedReferencedNamespace,\n\t\t\t\t\tdependsOn: [tableDependsOn(resolvedReferencedNamespace, fk.referencedTable), ...columnDependsOn(ddlSchema, tableName, fk.columns)]\n\t\t\t\t});\n\t\t\t});\n\t\t\tconst uniques = sqlTable.uniques.map((u) => new SqlUniqueIR({\n\t\t\t\tcolumns: u.columns,\n\t\t\t\t...ifDefined(\"name\", u.name),\n\t\t\t\t...ifDefined(\"annotations\", u.annotations),\n\t\t\t\tdependsOn: columnDependsOn(ddlSchema, tableName, u.columns)\n\t\t\t}));\n\t\t\tconst indexes = sqlTable.indexes.map((i) => {\n\t\t\t\tconst base = {\n\t\t\t\t\tnaming: namingOf(i.name, i.prefix),\n\t\t\t\t\twhere: i.where,\n\t\t\t\t\tunique: i.unique,\n\t\t\t\t\tpartial: i.partial,\n\t\t\t\t\ttype: i.type,\n\t\t\t\t\toptions: i.options,\n\t\t\t\t\tannotations: i.annotations,\n\t\t\t\t\tdependsOn: columnDependsOn(ddlSchema, tableName, i.columns ?? Object.keys(sqlTable.columns))\n\t\t\t\t};\n\t\t\t\treturn new SqlIndexIR(i.expression !== void 0 ? {\n\t\t\t\t\t...base,\n\t\t\t\t\texpression: i.expression\n\t\t\t\t} : {\n\t\t\t\t\t...base,\n\t\t\t\t\tcolumns: i.columns ?? []\n\t\t\t\t});\n\t\t\t});\n\t\t\tconst primaryKey = sqlTable.primaryKey !== void 0 ? new PrimaryKey({\n\t\t\t\tcolumns: sqlTable.primaryKey.columns,\n\t\t\t\t...ifDefined(\"name\", sqlTable.primaryKey.name),\n\t\t\t\tdependsOn: columnDependsOn(ddlSchema, tableName, sqlTable.primaryKey.columns)\n\t\t\t}) : void 0;\n\t\t\ttables[tableName] = new PostgresTableSchemaNode({\n\t\t\t\tname: sqlTable.name,\n\t\t\t\tcolumns: sqlTable.columns,\n\t\t\t\tforeignKeys,\n\t\t\t\tuniques,\n\t\t\t\tindexes,\n\t\t\t\t...ifDefined(\"primaryKey\", primaryKey),\n\t\t\t\t...ifDefined(\"annotations\", sqlTable.annotations),\n\t\t\t\t...ifDefined(\"checks\", sqlTable.checks),\n\t\t\t\tpolicies: policiesByTable.get(tableName) ?? [],\n\t\t\t\trlsEnabled: Object.hasOwn(ns.rls, tableName)\n\t\t\t});\n\t\t}\n\t\tfor (const [tableName, tablePolicies] of policiesByTable) {\n\t\t\tif (!(tableName in tables)) {\n\t\t\t\tconst policyName = tablePolicies[0]?.name ?? \"(unknown)\";\n\t\t\t\tthrow postgresError(\"CONTRACT.POLICY_INVALID\", `contract-to-postgres-database-schema-node: policy \"${policyName}\" references table \"${tableName}\" not present in namespace \"${ddlSchema}\"`, { meta: {\n\t\t\t\t\tpolicyName,\n\t\t\t\t\ttableName,\n\t\t\t\t\tnamespaceId: ddlSchema,\n\t\t\t\t\treason: \"table-missing\"\n\t\t\t\t} });\n\t\t\t}\n\t\t\tif (!Object.hasOwn(ns.rls, tableName)) {\n\t\t\t\tconst policyLabel = tablePolicies[0]?.prefix ?? tablePolicies[0]?.name ?? \"(unknown)\";\n\t\t\t\tthrow postgresError(\"CONTRACT.POLICY_INVALID\", `contract-to-postgres-database-schema-node: policy \"${policyLabel}\" targets table \"${tableName}\" in namespace \"${ddlSchema}\", which is not RLS-controlled. Mark the model with @@rls (entries.rls[\"${tableName}\"]) or remove the policy.`, { meta: {\n\t\t\t\t\tpolicyName: policyLabel,\n\t\t\t\t\ttableName,\n\t\t\t\t\tnamespaceId: ddlSchema,\n\t\t\t\t\treason: \"table-not-rls-controlled\"\n\t\t\t\t} });\n\t\t\t}\n\t\t}\n\t\tnamespaces[ddlSchema] = new PostgresNamespaceSchemaNode({\n\t\t\tschemaName: ddlSchema,\n\t\t\ttables,\n\t\t\tnativeEnums: Object.values(ns.entries.native_enum ?? {}).map((entity) => new PostgresNativeEnumSchemaNode({\n\t\t\t\ttypeName: entity.typeName,\n\t\t\t\tnamespaceId: ddlSchema,\n\t\t\t\tmembers: entity.members,\n\t\t\t\t...ifDefined(\"control\", entity.control)\n\t\t\t}))\n\t\t});\n\t}\n\treturn new PostgresDatabaseSchemaNode({\n\t\tnamespaces,\n\t\troles,\n\t\texistingSchemas: ownedSchemas,\n\t\tpgVersion: \"\"\n\t});\n}\n//#endregion\n//#region src/core/migrations/native-type-expander.ts\n/**\n* The family's native type expander, which expands a column's type parameters through its codec's hook, with the type named as introspection reports it: under PostgreSQL's canonical name rather than an alias such as `char` or `int`, and with `character` and `bit` without a length as `character(1)` and `bit(1)`.\n*/\nfunction buildPostgresNativeTypeExpander(frameworkComponents) {\n\tconst expand = buildNativeTypeExpander(frameworkComponents);\n\treturn (input) => {\n\t\treturn withLengthOneWhenBare(normalizeSchemaNativeType(expand === void 0 ? input.nativeType : expand(input)));\n\t};\n}\n//#endregion\n//#region src/core/migrations/diff-database-schema.ts\n/**\n* Whether a diff issue's subject node is cluster-scoped — it carries its own\n* `namespaceId` field (only role and policy diff nodes do) and that\n* coordinate is the unbound sentinel, meaning the node is not owned by any\n* schema/namespace. A role node is always cluster-scoped (roles are\n* cluster-level objects); a policy node's `namespaceId` is always its\n* table's resolved DDL schema, never the sentinel. Namespace-ownership\n* scoping (which compares `issue.path[1]` against the set of DDL schemas\n* the contract owns) makes no sense for a cluster-scoped subject — its path\n* segment at that index is the object's own name, not a schema name — so\n* such an issue bypasses that scoping entirely.\n*/\nfunction isClusterScopedIssue(issue) {\n\tconst node = issue.expected ?? issue.actual;\n\treturn node !== void 0 && nodeNamespaceId(node) === UNBOUND_NAMESPACE_ID;\n}\nfunction nodeNamespaceId(node) {\n\tif (!Object.hasOwn(node, \"namespaceId\")) return void 0;\n\treturn blindCast(node).namespaceId;\n}\nfunction ownedSchemaNames(expected) {\n\tconst policyNamespaces = Object.values(expected.namespaces).flatMap((ns) => Object.values(ns.tables).flatMap((t) => t.policies.map((p) => p.namespaceId)));\n\treturn /* @__PURE__ */ new Set([...policyNamespaces, ...expected.existingSchemas]);\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(expected) {\n\tconst namespaces = Object.fromEntries(Object.entries(expected.namespaces).filter(([, ns]) => Object.keys(ns.tables).length > 0));\n\treturn new PostgresDatabaseSchemaNode({\n\t\tnamespaces,\n\t\troles: [...expected.roles],\n\t\texistingSchemas: expected.existingSchemas.filter((s) => namespaces[s] !== void 0),\n\t\tpgVersion: expected.pgVersion\n\t});\n}\n/**\n* Resolves a verdict-diff issue's subject's declared control policy directly\n* 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 subject.\n*\n* A role issue resolves through that same resolver to `external`\n* unconditionally (see its role branch), regardless of the contract's own\n* default policy: a role is referenced by the contract but not owned, and\n* `external`'s existing semantics — a missing declared subject still fails,\n* every extra is suppressed — are exactly the wanted asymmetric grading for\n* a cluster object the framework does not own.\n*/\nfunction resolveControlPolicy(issue, contract) {\n\treturn resolvePostgresNodeIssueControlPolicySubject(blindCast(issue), contract)?.explicitNodeControlPolicy;\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), run the generic\n* differ over the trees as derived, and scope out `not-expected` findings under namespaces the\n* contract does not own. Ownership scoping bypasses cluster-scoped subjects\n* (roles today), mirroring the legacy decomposition: relational extras check\n* 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 `nativeEnums`).\n*/\nfunction diffPostgresSchema(input) {\n\tconst postgresContract = blindCast(input.contract);\n\tPostgresDatabaseSchemaNode.assert(input.schema);\n\tconst actual = input.schema;\n\tconst fullExpected = contractToPostgresDatabaseSchemaNode(postgresContract, {\n\t\tannotationNamespace: \"pg\",\n\t\texpandNativeType: buildPostgresNativeTypeExpander(input.frameworkComponents),\n\t\tresolveDefault: postgresResolveDefault,\n\t\t...ifDefined(\"dataTypeOf\", buildDataTypeResolver(input.frameworkComponents))\n\t});\n\tconst expected = pruneTableLessNamespaces(fullExpected);\n\tconst relationalOwned = ownedSchemaNames(expected);\n\tconst structuralOwned = ownedSchemaNames(fullExpected);\n\treturn {\n\t\tissues: diffSchemas(expected, actual).filter((issue) => {\n\t\t\tif (issueOutcome(issue) !== \"not-expected\") return true;\n\t\t\tif (isClusterScopedIssue(issue)) return true;\n\t\t\tconst granularity = classifyDiffSubjectGranularity(issue, postgresDiffSubjectGranularity);\n\t\t\tconst namespaceSegment = issue.path[1];\n\t\t\tif (namespaceSegment === void 0) return true;\n\t\t\treturn (granularity === \"structural\" ? structuralOwned : relationalOwned).has(namespaceSegment);\n\t\t}),\n\t\tresolveControlPolicy: (issue) => resolveControlPolicy(issue, postgresContract),\n\t\tnamespacePairs: Object.values(expected.namespaces).map((ns) => ({ actual: actual.namespaces[ns.schemaName] }))\n\t};\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(expected, actual) {\n\tconst namespaces = { ...actual.namespaces };\n\tlet padded = false;\n\tfor (const schemaName of Object.keys(expected.namespaces)) if (namespaces[schemaName] === void 0) {\n\t\tnamespaces[schemaName] = new PostgresNamespaceSchemaNode({\n\t\t\tschemaName,\n\t\t\ttables: {}\n\t\t});\n\t\tpadded = true;\n\t}\n\tif (!padded) return actual;\n\treturn new PostgresDatabaseSchemaNode({\n\t\tnamespaces,\n\t\troles: [...actual.roles],\n\t\texistingSchemas: [...actual.existingSchemas],\n\t\tpgVersion: actual.pgVersion\n\t});\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, cluster-scope-aware ownership filter) plus\n* 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*/\nfunction buildPostgresPlanDiff(input) {\n\tconst postgresContract = blindCast(input.contract);\n\tPostgresDatabaseSchemaNode.assert(input.actualSchema);\n\tconst actual = input.actualSchema;\n\tconst fullExpected = contractToPostgresDatabaseSchemaNode(postgresContract, {\n\t\tannotationNamespace: \"pg\",\n\t\texpandNativeType: buildPostgresNativeTypeExpander(input.frameworkComponents),\n\t\tresolveDefault: postgresResolveDefault,\n\t\t...ifDefined(\"dataTypeOf\", buildDataTypeResolver(input.frameworkComponents))\n\t});\n\tconst expected = pruneTableLessNamespaces(fullExpected);\n\tconst paddedActual = padActualNamespaces(expected, actual);\n\tconst relationalOwned = ownedSchemaNames(expected);\n\tconst structuralOwned = ownedSchemaNames(fullExpected);\n\treturn {\n\t\texpected,\n\t\tactual: paddedActual,\n\t\tissues: blindCast(diffSchemas(expected, paddedActual)).filter((issue) => {\n\t\t\tif (issueOutcome(issue) !== \"not-expected\") return true;\n\t\t\tif (isClusterScopedIssue(issue)) return true;\n\t\t\tconst granularity = classifyDiffSubjectGranularity(issue, postgresDiffSubjectGranularity);\n\t\t\tconst namespaceSegment = issue.path[1];\n\t\t\tif (namespaceSegment === void 0) return true;\n\t\t\treturn (granularity === \"structural\" ? structuralOwned : relationalOwned).has(namespaceSegment);\n\t\t})\n\t};\n}\n//#endregion\nexport { contractToPostgresDatabaseSchemaNode as i, diffPostgresSchema as n, buildPostgresNativeTypeExpander as r, buildPostgresPlanDiff as t };\n\n//# sourceMapping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AG,UAAU,cAAc,sBAAsB,MAAM,mBAAmB,CAAC;CAC5E,CAAC;CACD,MAAM,WAAW,yBAAyB,YAAY;CACtD,MAAM,eAAe,oBAAoB,UAAU,MAAM;CACzD,MAAM,kBAAkB,iBAAiB,QAAQ;CACjD,MAAM,kBAAkB,iBAAiB,YAAY;CACrD,OAAO;EACN;EACA,QAAQ;EACR,QAAQ,UAAU,YAAY,UAAU,YAAY,CAAC,CAAC,CAAC,QAAQ,UAAU;GACxE,IAAI,aAAa,KAAK,MAAM,gBAAgB,OAAO;GACnD,IAAI,qBAAqB,KAAK,GAAG,OAAO;GACxC,MAAM,cAAc,+BAA+B,OAAO,8BAA8B;GACxF,MAAM,mBAAmB,MAAM,KAAK;GACpC,IAAI,qBAAqB,KAAK,GAAG,OAAO;GACxC,QAAQ,gBAAgB,eAAe,kBAAkB,gBAAA,CAAiB,IAAI,gBAAgB;EAC/F,CAAC;CACF;AACD"}
|
|
1
|
+
{"version":3,"file":"diff-database-schema-D_U4h-Ne-Dr3N_Zhs.mjs","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/diff-database-schema-D_U4h-Ne.mjs"],"sourcesContent":["import { s as postgresError } from \"./errors-DYyzTYzE.mjs\";\nimport { r as isPostgresSchema } from \"./postgres-schema-C8slJGZo.mjs\";\nimport { n as postgresResolveDefault } from \"./default-normalizer-Cb7nWBUa.mjs\";\nimport { a as postgresDiffSubjectGranularity, n as PostgresNativeEnumSchemaNode, r as PostgresSchemaNodeKind, t as PostgresTableSchemaNode } from \"./postgres-table-schema-node-BBkitBQh.mjs\";\nimport { i as PostgresDatabaseSchemaNode, n as PostgresPolicySchemaNode, r as PostgresNamespaceSchemaNode, t as PostgresRoleSchemaNode } from \"./postgres-role-schema-node-B8Z5i5D-.mjs\";\nimport { t as resolveDdlSchemaForNamespaceStorage } from \"./resolve-ddl-schema-Bq4m2dD9.mjs\";\nimport { i as resolvePostgresNodeIssueControlPolicySubject } from \"./control-policy-BDZr0Xz9.mjs\";\nimport { n as normalizeSchemaNativeType, r as withLengthOneWhenBare } from \"./native-type-normalizer-CW6g9Fut.mjs\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { diffSchemas, issueOutcome } from \"@internal/framework-components/control\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { buildDataTypeResolver, buildNativeTypeExpander, contractNamespaceToSchemaIR } from \"@internal/family-sql/control\";\nimport { namingOf } from \"@internal/sql-schema-ir/naming\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { classifyDiffSubjectGranularity } from \"@internal/family-sql/diff\";\nimport { PrimaryKey, RelationalSchemaNodeKind, SqlForeignKeyIR, SqlIndexIR, SqlUniqueIR } from \"@internal/sql-schema-ir/types\";\n//#region src/core/migrations/contract-to-postgres-database-schema-node.ts\n/** The database root's fixed sentinel id (`PostgresDatabaseSchemaNode#id`). */\nfunction databaseStep() {\n\treturn {\n\t\tnodeKind: PostgresSchemaNodeKind.database,\n\t\tid: \"database\"\n\t};\n}\nfunction tableDependsOn(namespaceId, tableName) {\n\treturn [\n\t\tdatabaseStep(),\n\t\t{\n\t\t\tnodeKind: PostgresSchemaNodeKind.namespace,\n\t\t\tid: namespaceId\n\t\t},\n\t\t{\n\t\t\tnodeKind: PostgresSchemaNodeKind.table,\n\t\t\tid: tableName\n\t\t}\n\t];\n}\nfunction roleDependsOn(role) {\n\treturn [databaseStep(), {\n\t\tnodeKind: PostgresSchemaNodeKind.role,\n\t\tid: role\n\t}];\n}\n/**\n* The chains from a table-child object (foreign key, index, unique, primary\n* key) to each of the own columns it is built on, in the Postgres tree.\n* Dropping a covered column auto-drops the object, so the object's drop must\n* precede the column's; the graph derives that direction from these edges.\n*/\nfunction columnDependsOn(namespaceId, tableName, columns) {\n\treturn columns.map((column) => [...tableDependsOn(namespaceId, tableName), {\n\t\tnodeKind: RelationalSchemaNodeKind.column,\n\t\tid: `column:${column}`\n\t}]);\n}\nfunction toPolicyNode(policy, namespaceId) {\n\treturn new PostgresPolicySchemaNode({\n\t\tnaming: namingOf(policy.name, policy.prefix),\n\t\ttableName: policy.tableName,\n\t\tnamespaceId,\n\t\toperation: policy.operation,\n\t\troles: [...policy.roles],\n\t\tusing: policy.using,\n\t\twithCheck: policy.withCheck,\n\t\tpermissive: policy.permissive,\n\t\tdependsOn: [tableDependsOn(namespaceId, policy.tableName), ...policy.roles.map(roleDependsOn)]\n\t});\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*/\nfunction contractToPostgresDatabaseSchemaNode(contract, options) {\n\tif (contract === null) return new PostgresDatabaseSchemaNode({\n\t\tnamespaces: {},\n\t\troles: [],\n\t\texistingSchemas: [],\n\t\tpgVersion: \"\"\n\t});\n\tconst namespaces = {};\n\tconst roles = [];\n\tconst ownedSchemas = [];\n\tfor (const ns of Object.values(contract.storage.namespaces)) {\n\t\tif (!isPostgresSchema(ns)) continue;\n\t\tfor (const role of Object.values(ns.role)) roles.push(new PostgresRoleSchemaNode({\n\t\t\tname: role.name,\n\t\t\tnamespaceId: role.namespaceId\n\t\t}));\n\t\tif (ns.id === UNBOUND_NAMESPACE_ID) {\n\t\t\tif (!Object.entries(ns.entries).some(([entriesKey, slot]) => entriesKey !== \"role\" && Object.keys(slot).length > 0)) continue;\n\t\t}\n\t\tconst ddlSchema = resolveDdlSchemaForNamespaceStorage(contract.storage, ns.id);\n\t\townedSchemas.push(ddlSchema);\n\t\tconst sqlTables = contractNamespaceToSchemaIR(contract.storage, ns.id, options).tables;\n\t\tconst policiesByTable = /* @__PURE__ */ new Map();\n\t\tfor (const policy of Object.values(ns.policy)) {\n\t\t\tconst list = policiesByTable.get(policy.tableName) ?? [];\n\t\t\tlist.push(toPolicyNode(policy, ddlSchema));\n\t\t\tpoliciesByTable.set(policy.tableName, list);\n\t\t}\n\t\tconst tables = {};\n\t\tfor (const tableName of Object.keys(ns.table)) {\n\t\t\tconst sqlTable = sqlTables[tableName];\n\t\t\tif (sqlTable === void 0) continue;\n\t\t\tconst foreignKeys = sqlTable.foreignKeys.map((fk) => {\n\t\t\t\tconst resolvedReferencedNamespace = resolveDdlSchemaForNamespaceStorage(contract.storage, fk.referencedSchema ?? UNBOUND_NAMESPACE_ID);\n\t\t\t\treturn new SqlForeignKeyIR({\n\t\t\t\t\tcolumns: fk.columns,\n\t\t\t\t\treferencedTable: fk.referencedTable,\n\t\t\t\t\treferencedColumns: fk.referencedColumns,\n\t\t\t\t\treferencedSchema: fk.referencedSchema ?? UNBOUND_NAMESPACE_ID,\n\t\t\t\t\t...ifDefined(\"name\", fk.name),\n\t\t\t\t\t...ifDefined(\"onDelete\", fk.onDelete),\n\t\t\t\t\t...ifDefined(\"onUpdate\", fk.onUpdate),\n\t\t\t\t\t...ifDefined(\"annotations\", fk.annotations),\n\t\t\t\t\tresolvedReferencedNamespace,\n\t\t\t\t\tdependsOn: [tableDependsOn(resolvedReferencedNamespace, fk.referencedTable), ...columnDependsOn(ddlSchema, tableName, fk.columns)]\n\t\t\t\t});\n\t\t\t});\n\t\t\tconst uniques = sqlTable.uniques.map((u) => new SqlUniqueIR({\n\t\t\t\tcolumns: u.columns,\n\t\t\t\t...ifDefined(\"name\", u.name),\n\t\t\t\t...ifDefined(\"annotations\", u.annotations),\n\t\t\t\tdependsOn: columnDependsOn(ddlSchema, tableName, u.columns)\n\t\t\t}));\n\t\t\tconst indexes = sqlTable.indexes.map((i) => {\n\t\t\t\tconst base = {\n\t\t\t\t\tnaming: namingOf(i.name, i.prefix),\n\t\t\t\t\twhere: i.where,\n\t\t\t\t\tunique: i.unique,\n\t\t\t\t\tpartial: i.partial,\n\t\t\t\t\ttype: i.type,\n\t\t\t\t\toptions: i.options,\n\t\t\t\t\tannotations: i.annotations,\n\t\t\t\t\tdependsOn: columnDependsOn(ddlSchema, tableName, i.columns ?? Object.keys(sqlTable.columns))\n\t\t\t\t};\n\t\t\t\treturn new SqlIndexIR(i.expression !== void 0 ? {\n\t\t\t\t\t...base,\n\t\t\t\t\texpression: i.expression\n\t\t\t\t} : {\n\t\t\t\t\t...base,\n\t\t\t\t\tcolumns: i.columns ?? []\n\t\t\t\t});\n\t\t\t});\n\t\t\tconst primaryKey = sqlTable.primaryKey !== void 0 ? new PrimaryKey({\n\t\t\t\tcolumns: sqlTable.primaryKey.columns,\n\t\t\t\t...ifDefined(\"name\", sqlTable.primaryKey.name),\n\t\t\t\tdependsOn: columnDependsOn(ddlSchema, tableName, sqlTable.primaryKey.columns)\n\t\t\t}) : void 0;\n\t\t\ttables[tableName] = new PostgresTableSchemaNode({\n\t\t\t\tname: sqlTable.name,\n\t\t\t\tcolumns: sqlTable.columns,\n\t\t\t\tforeignKeys,\n\t\t\t\tuniques,\n\t\t\t\tindexes,\n\t\t\t\t...ifDefined(\"primaryKey\", primaryKey),\n\t\t\t\t...ifDefined(\"annotations\", sqlTable.annotations),\n\t\t\t\t...ifDefined(\"checks\", sqlTable.checks),\n\t\t\t\tpolicies: policiesByTable.get(tableName) ?? [],\n\t\t\t\trlsEnabled: Object.hasOwn(ns.rls, tableName)\n\t\t\t});\n\t\t}\n\t\tfor (const [tableName, tablePolicies] of policiesByTable) {\n\t\t\tif (!(tableName in tables)) {\n\t\t\t\tconst policyName = tablePolicies[0]?.name ?? \"(unknown)\";\n\t\t\t\tthrow postgresError(\"CONTRACT.POLICY_INVALID\", `contract-to-postgres-database-schema-node: policy \"${policyName}\" references table \"${tableName}\" not present in namespace \"${ddlSchema}\"`, { meta: {\n\t\t\t\t\tpolicyName,\n\t\t\t\t\ttableName,\n\t\t\t\t\tnamespaceId: ddlSchema,\n\t\t\t\t\treason: \"table-missing\"\n\t\t\t\t} });\n\t\t\t}\n\t\t\tif (!Object.hasOwn(ns.rls, tableName)) {\n\t\t\t\tconst policyLabel = tablePolicies[0]?.prefix ?? tablePolicies[0]?.name ?? \"(unknown)\";\n\t\t\t\tthrow postgresError(\"CONTRACT.POLICY_INVALID\", `contract-to-postgres-database-schema-node: policy \"${policyLabel}\" targets table \"${tableName}\" in namespace \"${ddlSchema}\", which is not RLS-controlled. Mark the model with @@rls (entries.rls[\"${tableName}\"]) or remove the policy.`, { meta: {\n\t\t\t\t\tpolicyName: policyLabel,\n\t\t\t\t\ttableName,\n\t\t\t\t\tnamespaceId: ddlSchema,\n\t\t\t\t\treason: \"table-not-rls-controlled\"\n\t\t\t\t} });\n\t\t\t}\n\t\t}\n\t\tnamespaces[ddlSchema] = new PostgresNamespaceSchemaNode({\n\t\t\tschemaName: ddlSchema,\n\t\t\ttables,\n\t\t\tnativeEnums: Object.values(ns.entries.native_enum ?? {}).map((entity) => new PostgresNativeEnumSchemaNode({\n\t\t\t\ttypeName: entity.typeName,\n\t\t\t\tnamespaceId: ddlSchema,\n\t\t\t\tmembers: entity.members,\n\t\t\t\t...ifDefined(\"control\", entity.control)\n\t\t\t}))\n\t\t});\n\t}\n\treturn new PostgresDatabaseSchemaNode({\n\t\tnamespaces,\n\t\troles,\n\t\texistingSchemas: ownedSchemas,\n\t\tpgVersion: \"\"\n\t});\n}\n//#endregion\n//#region src/core/migrations/native-type-expander.ts\n/**\n* The family's native type expander, which expands a column's type parameters through its codec's hook, with the type named as introspection reports it: under PostgreSQL's canonical name rather than an alias such as `char` or `int`, and with `character` and `bit` without a length as `character(1)` and `bit(1)`.\n*/\nfunction buildPostgresNativeTypeExpander(frameworkComponents) {\n\tconst expand = buildNativeTypeExpander(frameworkComponents);\n\treturn (input) => {\n\t\treturn withLengthOneWhenBare(normalizeSchemaNativeType(expand === void 0 ? input.nativeType : expand(input)));\n\t};\n}\n//#endregion\n//#region src/core/migrations/diff-database-schema.ts\n/**\n* Whether a diff issue's subject node is cluster-scoped — it carries its own\n* `namespaceId` field (only role and policy diff nodes do) and that\n* coordinate is the unbound sentinel, meaning the node is not owned by any\n* schema/namespace. A role node is always cluster-scoped (roles are\n* cluster-level objects); a policy node's `namespaceId` is always its\n* table's resolved DDL schema, never the sentinel. Namespace-ownership\n* scoping (which compares `issue.path[1]` against the set of DDL schemas\n* the contract owns) makes no sense for a cluster-scoped subject — its path\n* segment at that index is the object's own name, not a schema name — so\n* such an issue bypasses that scoping entirely.\n*/\nfunction isClusterScopedIssue(issue) {\n\tconst node = issue.expected ?? issue.actual;\n\treturn node !== void 0 && nodeNamespaceId(node) === UNBOUND_NAMESPACE_ID;\n}\nfunction nodeNamespaceId(node) {\n\tif (!Object.hasOwn(node, \"namespaceId\")) return void 0;\n\treturn blindCast(node).namespaceId;\n}\nfunction ownedSchemaNames(expected) {\n\tconst policyNamespaces = Object.values(expected.namespaces).flatMap((ns) => Object.values(ns.tables).flatMap((t) => t.policies.map((p) => p.namespaceId)));\n\treturn /* @__PURE__ */ new Set([...policyNamespaces, ...expected.existingSchemas]);\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(expected) {\n\tconst namespaces = Object.fromEntries(Object.entries(expected.namespaces).filter(([, ns]) => Object.keys(ns.tables).length > 0));\n\treturn new PostgresDatabaseSchemaNode({\n\t\tnamespaces,\n\t\troles: [...expected.roles],\n\t\texistingSchemas: expected.existingSchemas.filter((s) => namespaces[s] !== void 0),\n\t\tpgVersion: expected.pgVersion\n\t});\n}\n/**\n* Resolves a verdict-diff issue's subject's declared control policy directly\n* 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 subject.\n*\n* A role issue resolves through that same resolver to `external`\n* unconditionally (see its role branch), regardless of the contract's own\n* default policy: a role is referenced by the contract but not owned, and\n* `external`'s existing semantics — a missing declared subject still fails,\n* every extra is suppressed — are exactly the wanted asymmetric grading for\n* a cluster object the framework does not own.\n*/\nfunction resolveControlPolicy(issue, contract) {\n\treturn resolvePostgresNodeIssueControlPolicySubject(blindCast(issue), contract)?.explicitNodeControlPolicy;\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), run the generic\n* differ over the trees as derived, and scope out `not-expected` findings under namespaces the\n* contract does not own. Ownership scoping bypasses cluster-scoped subjects\n* (roles today), mirroring the legacy decomposition: relational extras check\n* 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 `nativeEnums`).\n*/\nfunction diffPostgresSchema(input) {\n\tconst postgresContract = blindCast(input.contract);\n\tPostgresDatabaseSchemaNode.assert(input.schema);\n\tconst actual = input.schema;\n\tconst fullExpected = contractToPostgresDatabaseSchemaNode(postgresContract, {\n\t\tannotationNamespace: \"pg\",\n\t\texpandNativeType: buildPostgresNativeTypeExpander(input.frameworkComponents),\n\t\tresolveDefault: postgresResolveDefault,\n\t\t...ifDefined(\"dataTypeOf\", buildDataTypeResolver(input.frameworkComponents))\n\t});\n\tconst expected = pruneTableLessNamespaces(fullExpected);\n\tconst relationalOwned = ownedSchemaNames(expected);\n\tconst structuralOwned = ownedSchemaNames(fullExpected);\n\treturn {\n\t\tissues: diffSchemas(expected, actual).filter((issue) => {\n\t\t\tif (issueOutcome(issue) !== \"not-expected\") return true;\n\t\t\tif (isClusterScopedIssue(issue)) return true;\n\t\t\tconst granularity = classifyDiffSubjectGranularity(issue, postgresDiffSubjectGranularity);\n\t\t\tconst namespaceSegment = issue.path[1];\n\t\t\tif (namespaceSegment === void 0) return true;\n\t\t\treturn (granularity === \"structural\" ? structuralOwned : relationalOwned).has(namespaceSegment);\n\t\t}),\n\t\tresolveControlPolicy: (issue) => resolveControlPolicy(issue, postgresContract),\n\t\tnamespacePairs: Object.values(expected.namespaces).map((ns) => ({ actual: actual.namespaces[ns.schemaName] }))\n\t};\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(expected, actual) {\n\tconst namespaces = { ...actual.namespaces };\n\tlet padded = false;\n\tfor (const schemaName of Object.keys(expected.namespaces)) if (namespaces[schemaName] === void 0) {\n\t\tnamespaces[schemaName] = new PostgresNamespaceSchemaNode({\n\t\t\tschemaName,\n\t\t\ttables: {}\n\t\t});\n\t\tpadded = true;\n\t}\n\tif (!padded) return actual;\n\treturn new PostgresDatabaseSchemaNode({\n\t\tnamespaces,\n\t\troles: [...actual.roles],\n\t\texistingSchemas: [...actual.existingSchemas],\n\t\tpgVersion: actual.pgVersion\n\t});\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, cluster-scope-aware ownership filter) plus\n* 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*/\nfunction buildPostgresPlanDiff(input) {\n\tconst postgresContract = blindCast(input.contract);\n\tPostgresDatabaseSchemaNode.assert(input.actualSchema);\n\tconst actual = input.actualSchema;\n\tconst fullExpected = contractToPostgresDatabaseSchemaNode(postgresContract, {\n\t\tannotationNamespace: \"pg\",\n\t\texpandNativeType: buildPostgresNativeTypeExpander(input.frameworkComponents),\n\t\tresolveDefault: postgresResolveDefault,\n\t\t...ifDefined(\"dataTypeOf\", buildDataTypeResolver(input.frameworkComponents))\n\t});\n\tconst expected = pruneTableLessNamespaces(fullExpected);\n\tconst paddedActual = padActualNamespaces(expected, actual);\n\tconst relationalOwned = ownedSchemaNames(expected);\n\tconst structuralOwned = ownedSchemaNames(fullExpected);\n\treturn {\n\t\texpected,\n\t\tactual: paddedActual,\n\t\tissues: blindCast(diffSchemas(expected, paddedActual)).filter((issue) => {\n\t\t\tif (issueOutcome(issue) !== \"not-expected\") return true;\n\t\t\tif (isClusterScopedIssue(issue)) return true;\n\t\t\tconst granularity = classifyDiffSubjectGranularity(issue, postgresDiffSubjectGranularity);\n\t\t\tconst namespaceSegment = issue.path[1];\n\t\t\tif (namespaceSegment === void 0) return true;\n\t\t\treturn (granularity === \"structural\" ? structuralOwned : relationalOwned).has(namespaceSegment);\n\t\t})\n\t};\n}\n//#endregion\nexport { contractToPostgresDatabaseSchemaNode as i, diffPostgresSchema as n, buildPostgresNativeTypeExpander as r, buildPostgresPlanDiff as t };\n\n//# sourceMappingURL=diff-database-schema-D_U4h-Ne.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,SAAS,eAAe;CACvB,OAAO;EACN,UAAU,uBAAuB;EACjC,IAAI;CACL;AACD;AACA,SAAS,eAAe,aAAa,WAAW;CAC/C,OAAO;EACN,aAAa;EACb;GACC,UAAU,uBAAuB;GACjC,IAAI;EACL;EACA;GACC,UAAU,uBAAuB;GACjC,IAAI;EACL;CACD;AACD;AACA,SAAS,cAAc,MAAM;CAC5B,OAAO,CAAC,aAAa,GAAG;EACvB,UAAU,uBAAuB;EACjC,IAAI;CACL,CAAC;AACF;;;;;;;AAOA,SAAS,gBAAgB,aAAa,WAAW,SAAS;CACzD,OAAO,QAAQ,KAAK,WAAW,CAAC,GAAG,eAAe,aAAa,SAAS,GAAG;EAC1E,UAAU,yBAAyB;EACnC,IAAI,UAAU;CACf,CAAC,CAAC;AACH;AACA,SAAS,aAAa,QAAQ,aAAa;CAC1C,OAAO,IAAI,yBAAyB;EACnC,QAAQ,SAAS,OAAO,MAAM,OAAO,MAAM;EAC3C,WAAW,OAAO;EAClB;EACA,WAAW,OAAO;EAClB,OAAO,CAAC,GAAG,OAAO,KAAK;EACvB,OAAO,OAAO;EACd,WAAW,OAAO;EAClB,YAAY,OAAO;EACnB,WAAW,CAAC,eAAe,aAAa,OAAO,SAAS,GAAG,GAAG,OAAO,MAAM,IAAI,aAAa,CAAC;CAC9F,CAAC;AACF;;;;;;;;;;;;;;;;;;;;;AAqBA,SAAS,qCAAqC,UAAU,SAAS;CAChE,IAAI,aAAa,MAAM,OAAO,IAAI,2BAA2B;EAC5D,YAAY,CAAC;EACb,OAAO,CAAC;EACR,iBAAiB,CAAC;EAClB,WAAW;CACZ,CAAC;CACD,M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B,OAAO,MAAM,YAAY;CACpD,MAAM,SAAS,MAAM;CACrB,MAAM,eAAe,qCAAqC,kBAAkB;EAC3E,qBAAqB;EACrB,kBAAkB,gCAAgC,MAAM,mBAAmB;EAC3E,gBAAgB;EAChB,GAAG,UAAU,cAAc,sBAAsB,MAAM,mBAAmB,CAAC;CAC5E,CAAC;CACD,MAAM,WAAW,yBAAyB,YAAY;CACtD,MAAM,eAAe,oBAAoB,UAAU,MAAM;CACzD,MAAM,kBAAkB,iBAAiB,QAAQ;CACjD,MAAM,kBAAkB,iBAAiB,YAAY;CACrD,OAAO;EACN;EACA,QAAQ;EACR,QAAQ,UAAU,YAAY,UAAU,YAAY,CAAC,CAAC,CAAC,QAAQ,UAAU;GACxE,IAAI,aAAa,KAAK,MAAM,gBAAgB,OAAO;GACnD,IAAI,qBAAqB,KAAK,GAAG,OAAO;GACxC,MAAM,cAAc,+BAA+B,OAAO,8BAA8B;GACxF,MAAM,mBAAmB,MAAM,KAAK;GACpC,IAAI,qBAAqB,KAAK,GAAG,OAAO;GACxC,QAAQ,gBAAgB,eAAe,kBAAkB,gBAAA,CAAiB,IAAI,gBAAgB;EAC/F,CAAC;CACF;AACD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { j as PostgresOpFactoryCall } from "./op-factory-call-
|
|
1
|
+
import { j as PostgresOpFactoryCall } from "./op-factory-call-CaEALaar-Nh0fSxQY.mjs";
|
|
2
2
|
import { SqlStorage, StorageTypeInstance } from "@prisma/orm-family-sql/contract/types";
|
|
3
3
|
import { DiffableNode, SchemaDiffIssue } from "@prisma/orm-framework/components/control";
|
|
4
4
|
import { CodecControlHooks, MigrationOperationPolicy, SqlPlannerConflict } from "@prisma/orm-family-sql/family/control";
|
|
@@ -102,4 +102,4 @@ interface IssuePlannerOptions {
|
|
|
102
102
|
declare function planIssues(options: IssuePlannerOptions): Result<IssuePlannerValue, readonly SqlPlannerConflict[]>;
|
|
103
103
|
//#endregion
|
|
104
104
|
export { planIssues as n, coalesceSubtreeIssues as t };
|
|
105
|
-
//# sourceMappingURL=issue-planner-
|
|
105
|
+
//# sourceMappingURL=issue-planner-BdnqkLvV.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"issue-planner-
|
|
1
|
+
{"version":3,"file":"issue-planner-BdnqkLvV.d.mts","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/issue-planner.d.mts"],"mappings":";;;;;;;;;;;;;;;;;;;UAkBU;WACC,YAAY,SAAS;WACrB,cAAc,SAAS;WACvB;WACA,YAAY,oBAAoB;WAChC,cAAc,SAAS,eAAe;WACtC,QAAQ;WACR,QAAQ;WACR,qBAAqB,cAAc;;;;;;;;;KASzC,yBAAyB,iBAAiB,mBAAmB,SAAS;EACzE;EACA,iBAAiB;EACjB,gBAAgB;;;;;;;;EAQhB;;EAEA;;;;UAIQ;WACC,gBAAgB;;;;;;;;;;;iBAWV,sBAAsB,cAAc,eAAe,cAAc,iBAAiB,gBAAgB,oBAAoB,gBAAgB;UAC7I;WACC,iBAAiB;WACjB,YAAY,SAAS;WACrB,cAAc,SAAS;WACvB;WACA,YAAY,oBAAoB;WAChC,cAAc,SAAS,eAAe;;;;;;;;WAQtC,SAAS;;;;;;WAMT,SAAS;;;;;WAKT,sBAAsB,cAAc;WACpC,sBAAsB;;;;;;;;;iBAShB,WAAW,SAAS,sBAAsB,OAAO,4BAA4B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./data-transform-Ck5FbyNO-BNE7QlAo.mjs";
|
|
2
|
-
import { A as Op$1 } from "./op-factory-call-
|
|
3
|
-
import "./postgres-migration-
|
|
2
|
+
import { A as Op$1 } from "./op-factory-call-CaEALaar-Nh0fSxQY.mjs";
|
|
3
|
+
import "./postgres-migration-BCzAcFmN-Bz_I02Gc.mjs";
|
|
4
4
|
import { checkExpression, col as col$1, fn as fn$1, foreignKey, lit as lit$1, primaryKey, unique } from "@prisma/orm-family-sql/relational-core/contract-free";
|
|
5
5
|
import { placeholder } from "@prisma/orm-framework/errors/migration";
|
|
6
6
|
import { MigrationCLI } from "@prisma/orm-toolchain/cli/migration-cli";
|
|
@@ -22,4 +22,4 @@ declare function createExtension(extensionName: string): Op$1;
|
|
|
22
22
|
declare function rawSql(op: Op$1): Op$1;
|
|
23
23
|
//#endregion
|
|
24
24
|
export { fn$1 as a, placeholder as c, unique as d, createExtension as i, primaryKey as l, checkExpression as n, foreignKey as o, col$1 as r, lit$1 as s, MigrationCLI as t, rawSql as u };
|
|
25
|
-
//# sourceMappingURL=migration-
|
|
25
|
+
//# sourceMappingURL=migration-D7F66l-1.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-
|
|
1
|
+
{"version":3,"file":"migration-D7F66l-1.d.mts","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/migration.d.mts"],"mappings":";;;;;;;;iBAQiB,gBAAgB,wBAAwB;;;;;;;;;;;;;iBAaxC,OAAO,IAAI,OAAK"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-PTHAY9Cv.mjs","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/migration.mjs"],"sourcesContent":["import { z as createExtension } from \"./op-factory-call-
|
|
1
|
+
{"version":3,"file":"migration-PTHAY9Cv.mjs","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/migration.mjs"],"sourcesContent":["import { z as createExtension } from \"./op-factory-call-BeXmjOLn.mjs\";\nimport { t as PostgresMigration } from \"./postgres-migration-Brm-aBQE.mjs\";\nimport { t as dataTransform } from \"./data-transform-Bo32KRbq.mjs\";\nimport { checkExpression, col, fn, foreignKey, lit, primaryKey, unique } from \"@internal/sql-relational-core/contract-free\";\nimport { placeholder } from \"@internal/errors/migration\";\nimport { MigrationCLI } from \"@internal/cli/migration-cli\";\n//#region src/core/migrations/operations/raw.ts\n/**\n* Identity factory for an already-materialized `SqlMigrationPlanOperation`.\n*\n* The planner uses this via `liftOpToCall` to carry ops produced by SQL\n* family methods, codec control hooks, and component database dependencies\n* alongside migration IR without reverse-engineering them. Users writing\n* raw migrations can pass a full op shape directly — typically built by\n* composing SQL family helpers — to author a migration that bypasses the\n* structured call classes.\n*/\nfunction rawSql(op) {\n\treturn op;\n}\n//#endregion\nexport { PostgresMigration as Migration, MigrationCLI, checkExpression, col, createExtension, dataTransform, fn, foreignKey, lit, placeholder, primaryKey, rawSql, unique };\n\n//# sourceMappingURL=migration.mjs.map"],"mappings":";;;;;;;;;;;;;;AAiBA,SAAS,OAAO,IAAI;CACnB,OAAO;AACR"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DdlNode } from "@prisma/orm-family-sql/relational-core/ast";
|
|
2
|
-
//#region ../../../3-targets/3-targets/postgres/dist/nodes-
|
|
2
|
+
//#region ../../../3-targets/3-targets/postgres/dist/nodes-Bm2a7z6e.mjs
|
|
3
3
|
var AlterTableAction = class {};
|
|
4
4
|
var AddColumnAction = class extends AlterTableAction {
|
|
5
5
|
kind = "add-column";
|
|
@@ -182,10 +182,7 @@ var PostgresCreateIndex = class extends PostgresDdlNode {
|
|
|
182
182
|
elements;
|
|
183
183
|
type;
|
|
184
184
|
options;
|
|
185
|
-
/**
|
|
186
|
-
* Partial-index predicate (WHERE body, without the keyword). Inserted
|
|
187
|
-
* verbatim, never quoted or escaped.
|
|
188
|
-
*/
|
|
185
|
+
/** Partial-index predicate (WHERE body, without the keyword). Never quoted or escaped. */
|
|
189
186
|
where;
|
|
190
187
|
constructor(options) {
|
|
191
188
|
super();
|
|
@@ -252,4 +249,4 @@ var PostgresDisableRowLevelSecurity = class extends PostgresDdlNode {
|
|
|
252
249
|
//#endregion
|
|
253
250
|
export { PostgresAlterTable as a, PostgresCreateSchema as c, PostgresDdlNode as d, PostgresDisableRowLevelSecurity as f, PostgresDropType as h, PostgresAlterPolicyRename as i, PostgresCreateTable as l, PostgresDropPolicy as m, DropDefaultAction as n, PostgresCreateIndex as o, PostgresDropIndex as p, PostgresAlterIndexRename as r, PostgresCreatePolicy as s, AddColumnAction as t, PostgresCreateType as u };
|
|
254
251
|
|
|
255
|
-
//# sourceMappingURL=nodes-
|
|
252
|
+
//# sourceMappingURL=nodes-Bm2a7z6e-BXTXyzZv.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodes-Bm2a7z6e-BXTXyzZv.mjs","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/nodes-Bm2a7z6e.mjs"],"sourcesContent":["import { DdlNode } from \"@internal/sql-relational-core/ast\";\n//#region src/core/ddl/nodes.ts\nvar AlterTableAction = class {};\nvar AddColumnAction = class extends AlterTableAction {\n\tkind = \"add-column\";\n\tcolumn;\n\tconstructor(column) {\n\t\tsuper();\n\t\tthis.column = column;\n\t\tObject.freeze(this);\n\t}\n\taccept(visitor) {\n\t\treturn visitor.addColumn(this);\n\t}\n};\nvar DropDefaultAction = class extends AlterTableAction {\n\tkind = \"drop-default\";\n\tcolumnName;\n\tconstructor(columnName) {\n\t\tsuper();\n\t\tthis.columnName = columnName;\n\t\tObject.freeze(this);\n\t}\n\taccept(visitor) {\n\t\treturn visitor.dropDefault(this);\n\t}\n};\nvar PostgresDdlNode = class extends DdlNode {};\nfunction freezeDdlColumns(columns) {\n\treturn Object.freeze([...columns]);\n}\nfunction freezeConstraints(constraints) {\n\treturn constraints ? Object.freeze([...constraints]) : void 0;\n}\nvar PostgresCreateTable = class extends PostgresDdlNode {\n\tkind = \"create-table\";\n\ttable;\n\tschema;\n\tifNotExists;\n\tcolumns;\n\tconstraints;\n\tconstructor(options) {\n\t\tsuper();\n\t\tthis.table = options.table;\n\t\tthis.schema = options.schema;\n\t\tthis.ifNotExists = options.ifNotExists;\n\t\tthis.columns = freezeDdlColumns(options.columns);\n\t\tthis.constraints = freezeConstraints(options.constraints);\n\t\tthis.freeze();\n\t}\n\taccept(visitor) {\n\t\treturn visitor.createTable(this);\n\t}\n};\nvar PostgresCreateSchema = class extends PostgresDdlNode {\n\tkind = \"create-schema\";\n\tschema;\n\tifNotExists;\n\tconstructor(options) {\n\t\tsuper();\n\t\tthis.schema = options.schema;\n\t\tthis.ifNotExists = options.ifNotExists;\n\t\tthis.freeze();\n\t}\n\taccept(visitor) {\n\t\treturn visitor.createSchema(this);\n\t}\n};\nvar PostgresCreateType = class extends PostgresDdlNode {\n\tkind = \"create-type\";\n\tschema;\n\tname;\n\tvalues;\n\tconstructor(options) {\n\t\tsuper();\n\t\tthis.schema = options.schema;\n\t\tthis.name = options.name;\n\t\tthis.values = Object.freeze([...options.values]);\n\t\tthis.freeze();\n\t}\n\taccept(visitor) {\n\t\treturn visitor.createType(this);\n\t}\n};\nvar PostgresDropType = class extends PostgresDdlNode {\n\tkind = \"drop-type\";\n\tschema;\n\tname;\n\tconstructor(options) {\n\t\tsuper();\n\t\tthis.schema = options.schema;\n\t\tthis.name = options.name;\n\t\tthis.freeze();\n\t}\n\taccept(visitor) {\n\t\treturn visitor.dropType(this);\n\t}\n};\nvar PostgresAlterTable = class extends PostgresDdlNode {\n\tkind = \"alter-table\";\n\ttable;\n\tschema;\n\tactions;\n\tconstructor(options) {\n\t\tsuper();\n\t\tthis.table = options.table;\n\t\tthis.schema = options.schema;\n\t\tthis.actions = Object.freeze([...options.actions]);\n\t\tthis.freeze();\n\t}\n\taccept(visitor) {\n\t\treturn visitor.alterTable(this);\n\t}\n};\nvar PostgresCreatePolicy = class extends PostgresDdlNode {\n\tkind = \"create-policy\";\n\tschema;\n\ttable;\n\tname;\n\tpermissive;\n\toperation;\n\troles;\n\tusing;\n\twithCheck;\n\tconstructor(options) {\n\t\tsuper();\n\t\tthis.schema = options.schema;\n\t\tthis.table = options.table;\n\t\tthis.name = options.name;\n\t\tthis.permissive = options.permissive;\n\t\tthis.operation = options.operation;\n\t\tthis.roles = Object.freeze([...options.roles]);\n\t\tthis.using = options.using;\n\t\tthis.withCheck = options.withCheck;\n\t\tthis.freeze();\n\t}\n\taccept(visitor) {\n\t\treturn visitor.createPolicy(this);\n\t}\n};\nvar PostgresDropPolicy = class extends PostgresDdlNode {\n\tkind = \"drop-policy\";\n\tschema;\n\ttable;\n\tname;\n\tconstructor(options) {\n\t\tsuper();\n\t\tthis.schema = options.schema;\n\t\tthis.table = options.table;\n\t\tthis.name = options.name;\n\t\tthis.freeze();\n\t}\n\taccept(visitor) {\n\t\treturn visitor.dropPolicy(this);\n\t}\n};\nvar PostgresAlterPolicyRename = class extends PostgresDdlNode {\n\tkind = \"alter-policy-rename\";\n\tschema;\n\ttable;\n\tname;\n\tnewName;\n\tconstructor(options) {\n\t\tsuper();\n\t\tthis.schema = options.schema;\n\t\tthis.table = options.table;\n\t\tthis.name = options.name;\n\t\tthis.newName = options.newName;\n\t\tthis.freeze();\n\t}\n\taccept(visitor) {\n\t\treturn visitor.alterPolicyRename(this);\n\t}\n};\nvar PostgresCreateIndex = class extends PostgresDdlNode {\n\tkind = \"create-index\";\n\t/** Absent ⇔ unqualified (the unbound namespace — `search_path` decides). */\n\tschema;\n\ttable;\n\tname;\n\tunique;\n\telements;\n\ttype;\n\toptions;\n\t/** Partial-index predicate (WHERE body, without the keyword). Never quoted or escaped. */\n\twhere;\n\tconstructor(options) {\n\t\tsuper();\n\t\tthis.schema = options.schema;\n\t\tthis.table = options.table;\n\t\tthis.name = options.name;\n\t\tthis.unique = options.unique;\n\t\tthis.elements = \"columns\" in options.elements ? { columns: Object.freeze([...options.elements.columns]) } : { expression: options.elements.expression };\n\t\tthis.type = options.type;\n\t\tthis.options = options.options;\n\t\tthis.where = options.where;\n\t\tthis.freeze();\n\t}\n\taccept(visitor) {\n\t\treturn visitor.createIndex(this);\n\t}\n};\nvar PostgresDropIndex = class extends PostgresDdlNode {\n\tkind = \"drop-index\";\n\t/** Absent ⇔ unqualified (the unbound namespace). */\n\tschema;\n\tname;\n\tconstructor(options) {\n\t\tsuper();\n\t\tthis.schema = options.schema;\n\t\tthis.name = options.name;\n\t\tthis.freeze();\n\t}\n\taccept(visitor) {\n\t\treturn visitor.dropIndex(this);\n\t}\n};\nvar PostgresAlterIndexRename = class extends PostgresDdlNode {\n\tkind = \"alter-index-rename\";\n\t/** Absent ⇔ unqualified (the unbound namespace). */\n\tschema;\n\tfrom;\n\tto;\n\tconstructor(options) {\n\t\tsuper();\n\t\tthis.schema = options.schema;\n\t\tthis.from = options.from;\n\t\tthis.to = options.to;\n\t\tthis.freeze();\n\t}\n\taccept(visitor) {\n\t\treturn visitor.alterIndexRename(this);\n\t}\n};\nvar PostgresDisableRowLevelSecurity = class extends PostgresDdlNode {\n\tkind = \"disable-row-level-security\";\n\tschema;\n\ttable;\n\tconstructor(options) {\n\t\tsuper();\n\t\tthis.schema = options.schema;\n\t\tthis.table = options.table;\n\t\tthis.freeze();\n\t}\n\taccept(visitor) {\n\t\treturn visitor.disableRowLevelSecurity(this);\n\t}\n};\n//#endregion\nexport { PostgresAlterTable as a, PostgresCreateSchema as c, PostgresDdlNode as d, PostgresDisableRowLevelSecurity as f, PostgresDropType as h, PostgresAlterPolicyRename as i, PostgresCreateTable as l, PostgresDropPolicy as m, DropDefaultAction as n, PostgresCreateIndex as o, PostgresDropIndex as p, PostgresAlterIndexRename as r, PostgresCreatePolicy as s, AddColumnAction as t, PostgresCreateType as u };\n\n//# sourceMappingURL=nodes-Bm2a7z6e.mjs.map"],"mappings":";;AAEA,IAAI,mBAAmB,MAAM,CAAC;AAC9B,IAAI,kBAAkB,cAAc,iBAAiB;CACpD,OAAO;CACP;CACA,YAAY,QAAQ;EACnB,MAAM;EACN,KAAK,SAAS;EACd,OAAO,OAAO,IAAI;CACnB;CACA,OAAO,SAAS;EACf,OAAO,QAAQ,UAAU,IAAI;CAC9B;AACD;AACA,IAAI,oBAAoB,cAAc,iBAAiB;CACtD,OAAO;CACP;CACA,YAAY,YAAY;EACvB,MAAM;EACN,KAAK,aAAa;EAClB,OAAO,OAAO,IAAI;CACnB;CACA,OAAO,SAAS;EACf,OAAO,QAAQ,YAAY,IAAI;CAChC;AACD;AACA,IAAI,kBAAkB,c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AACD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as RlsPolicyOperation } from "./canonicalize-CQlxSR4D-MnrT5gtW.mjs";
|
|
2
|
-
import { DdlColumn, DdlNode, DdlTableConstraint } from "@prisma/orm-family-sql/relational-core/ast";
|
|
3
|
-
//#region ../../../3-targets/3-targets/postgres/dist/nodes-
|
|
2
|
+
import { DdlColumn, DdlNode, DdlTableConstraint, OpaqueSql } from "@prisma/orm-family-sql/relational-core/ast";
|
|
3
|
+
//#region ../../../3-targets/3-targets/postgres/dist/nodes-C1fPapnK.d.mts
|
|
4
4
|
//#region src/core/ddl/nodes.d.ts
|
|
5
5
|
interface AlterTableActionVisitor<R> {
|
|
6
6
|
addColumn(action: AddColumnAction): R;
|
|
@@ -117,8 +117,8 @@ declare class PostgresCreatePolicy extends PostgresDdlNode {
|
|
|
117
117
|
readonly permissive: boolean;
|
|
118
118
|
readonly operation: RlsPolicyOperation;
|
|
119
119
|
readonly roles: ReadonlyArray<string>;
|
|
120
|
-
readonly using:
|
|
121
|
-
readonly withCheck:
|
|
120
|
+
readonly using: OpaqueSql | undefined;
|
|
121
|
+
readonly withCheck: OpaqueSql | undefined;
|
|
122
122
|
constructor(options: {
|
|
123
123
|
readonly schema: string;
|
|
124
124
|
readonly table: string;
|
|
@@ -126,8 +126,8 @@ declare class PostgresCreatePolicy extends PostgresDdlNode {
|
|
|
126
126
|
readonly permissive: boolean;
|
|
127
127
|
readonly operation: RlsPolicyOperation;
|
|
128
128
|
readonly roles: readonly string[];
|
|
129
|
-
readonly using?:
|
|
130
|
-
readonly withCheck?:
|
|
129
|
+
readonly using?: OpaqueSql;
|
|
130
|
+
readonly withCheck?: OpaqueSql;
|
|
131
131
|
});
|
|
132
132
|
accept<R>(visitor: PostgresDdlVisitor<R>): R;
|
|
133
133
|
}
|
|
@@ -158,16 +158,21 @@ declare class PostgresAlterPolicyRename extends PostgresDdlNode {
|
|
|
158
158
|
accept<R>(visitor: PostgresDdlVisitor<R>): R;
|
|
159
159
|
}
|
|
160
160
|
/**
|
|
161
|
-
* The element list between the parens of CREATE INDEX: either a column
|
|
162
|
-
* tuple (each identifier quoted by the renderer) or one opaque expression
|
|
163
|
-
* string covering the entire list, inserted verbatim — the same opaque-SQL
|
|
164
|
-
* stance as RLS policy predicates (ADR 234).
|
|
161
|
+
* The element list between the parens of CREATE INDEX, as a migration file writes it: either a column tuple or one SQL expression string covering the entire list.
|
|
165
162
|
*/
|
|
166
|
-
type
|
|
163
|
+
type CreateIndexElements = {
|
|
167
164
|
readonly columns: readonly string[];
|
|
168
165
|
} | {
|
|
169
166
|
readonly expression: string;
|
|
170
167
|
};
|
|
168
|
+
/**
|
|
169
|
+
* The element list between the parens of CREATE INDEX: either a column tuple (each identifier quoted by the renderer) or one `OpaqueSql` value covering the entire list.
|
|
170
|
+
*/
|
|
171
|
+
type DdlIndexElements = {
|
|
172
|
+
readonly columns: readonly string[];
|
|
173
|
+
} | {
|
|
174
|
+
readonly expression: OpaqueSql;
|
|
175
|
+
};
|
|
171
176
|
declare class PostgresCreateIndex extends PostgresDdlNode {
|
|
172
177
|
readonly kind: "create-index";
|
|
173
178
|
/** Absent ⇔ unqualified (the unbound namespace — `search_path` decides). */
|
|
@@ -178,11 +183,8 @@ declare class PostgresCreateIndex extends PostgresDdlNode {
|
|
|
178
183
|
readonly elements: DdlIndexElements;
|
|
179
184
|
readonly type: string | undefined;
|
|
180
185
|
readonly options: Record<string, unknown> | undefined;
|
|
181
|
-
/**
|
|
182
|
-
|
|
183
|
-
* verbatim, never quoted or escaped.
|
|
184
|
-
*/
|
|
185
|
-
readonly where: string | undefined;
|
|
186
|
+
/** Partial-index predicate (WHERE body, without the keyword). Never quoted or escaped. */
|
|
187
|
+
readonly where: OpaqueSql | undefined;
|
|
186
188
|
constructor(options: {
|
|
187
189
|
readonly schema: string | undefined;
|
|
188
190
|
readonly table: string;
|
|
@@ -191,7 +193,7 @@ declare class PostgresCreateIndex extends PostgresDdlNode {
|
|
|
191
193
|
readonly elements: DdlIndexElements;
|
|
192
194
|
readonly type: string | undefined;
|
|
193
195
|
readonly options: Record<string, unknown> | undefined;
|
|
194
|
-
readonly where:
|
|
196
|
+
readonly where: OpaqueSql | undefined;
|
|
195
197
|
});
|
|
196
198
|
accept<R>(visitor: PostgresDdlVisitor<R>): R;
|
|
197
199
|
}
|
|
@@ -231,5 +233,5 @@ declare class PostgresDisableRowLevelSecurity extends PostgresDdlNode {
|
|
|
231
233
|
}
|
|
232
234
|
type AnyPostgresDdlNode = PostgresCreateTable | PostgresCreateSchema | PostgresCreateType | PostgresDropType | PostgresAlterTable | PostgresCreatePolicy | PostgresDropPolicy | PostgresAlterPolicyRename | PostgresCreateIndex | PostgresDropIndex | PostgresAlterIndexRename | PostgresDisableRowLevelSecurity;
|
|
233
235
|
//#endregion
|
|
234
|
-
export {
|
|
235
|
-
//# sourceMappingURL=nodes-
|
|
236
|
+
export { PostgresDdlVisitor as _, CreateIndexElements as a, PostgresDropPolicy as b, PostgresAlterIndexRename as c, PostgresCreateIndex as d, PostgresCreatePolicy as f, PostgresDdlNode as g, PostgresCreateType as h, AnyPostgresDdlNode as i, PostgresAlterPolicyRename as l, PostgresCreateTable as m, AlterTableActionVisitor as n, DdlIndexElements as o, PostgresCreateSchema as p, AnyAlterTableAction as r, DropDefaultAction as s, AddColumnAction as t, PostgresAlterTable as u, PostgresDisableRowLevelSecurity as v, PostgresDropType as x, PostgresDropIndex as y };
|
|
237
|
+
//# sourceMappingURL=nodes-C1fPapnK-j0AK7Gcj.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodes-
|
|
1
|
+
{"version":3,"file":"nodes-C1fPapnK-j0AK7Gcj.d.mts","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/nodes-C1fPapnK.d.mts"],"mappings":";;;;UAGU,wBAAwB;EAChC,UAAU,QAAQ,kBAAkB;EACpC,YAAY,QAAQ,oBAAoB;;uBAEnB;oBACH;WACT,OAAO,GAA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AA6B;WAChC;WACA;WACA;WACA;WACA;WACA,WAAW;WACX,OAAO;WACP,OAAO;WACP,WAAW;EACpB,YAAY;aACD;aACA;aACA;aACA;aACA,WAAW;aACX;aACA,QAAQ;aACR,YAAY;;EAEvB,OAAO,GAAG,SAAS,mBAAmB,KAAK;;cAE/B,2BAA2B;WAC9B;WACA;WACA;WACA;EACT,YAAY;aACD;aACA;aACA;;EAEX,OAAO,GAAG,SAAS,mBAAmB,KAAK;;cAE/B,kCAAkC;WACrC;WACA;WACA;WACA;WACA;EACT,YAAY;aACD;aACA;aACA;aACA;;EAEX,OAAO,GAAG,SAAS,mBAAmB,KAAK;;;;;KAKxC;WACM;;WAEA;;;;;KAKN;WACM;;WAEA,YAAY;;cAET,4BAA4B;WAC/B;;WAEA;WACA;WACA;WACA;WACA,UAAU;WACV;WACA,SAAS;;WAET,OAAO;EAChB,YAAY;aACD;aACA;aACA;aACA;aACA,UAAU;aACV;aACA,SAAS;aACT,OAAO;;EAElB,OAAO,GAAG,SAAS,mBAAmB,KAAK;;cAE/B,0BAA0B;WAC7B;;WAEA;WACA;EACT,YAAY;aACD;aACA;;EAEX,OAAO,GAAG,SAAS,mBAAmB,KAAK;;cAE/B,iCAAiC;WACpC;;WAEA;WACA;WACA;EACT,YAAY;aACD;aACA;aACA;;EAEX,OAAO,GAAG,SAAS,mBAAmB,KAAK;;cAE/B,wCAAwC;WAC3C;WACA;WACA;EACT,YAAY;aACD;aACA;;EAEX,OAAO,GAAG,SAAS,mBAAmB,KAAK;;KAExC,qBAAqB,sBAAsB,uBAAuB,qBAAqB,mBAAmB,qBAAqB,uBAAuB,qBAAqB,4BAA4B,sBAAsB,oBAAoB,2BAA2B"}
|
package/dist/{op-factory-call-DYkz28kP-4BmpSB4B.mjs → op-factory-call-BeXmjOLn-Cm9tMP0i.mjs}
RENAMED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { s as postgresError } from "./errors-DYyzTYzE-39CV_aMo.mjs";
|
|
2
2
|
import { t as DEFAULT_NAMESPACE_ID } from "./namespace-ids-xtp_ZY86-Cpp8PTxD.mjs";
|
|
3
3
|
import { a as validateEnumValueLength, i as quoteQualifiedName, r as quoteIdentifier, t as escapeLiteral } from "./sql-utils-Bh-mnsSY-D6hnFPrP.mjs";
|
|
4
|
-
import { C as nativeEnumValueExistsAst, D as tableExistsAst, E as rlsPolicyExistsAst, O as tableIsEmptyAst, S as nativeEnumTypeExistsAst, T as rlsEnabledAst, _ as dropIndex$1, a as columnDefaultAst, b as extensionExistsAst, c as columnTypeAst, d as createPolicy, f as createSchema, g as dropDefaultAction, h as disableRowLevelSecurity$1, i as alterTable, l as constraintExistsAst, m as createType, n as alterIndexRename, o as columnExistsAst, p as createTable, r as alterPolicyRename, s as columnNullabilityAst, t as addColumnAction, u as createIndex$1, v as dropPolicy, w as noNullValuesAst, x as indexExistsAst, y as dropType } from "./ddl-
|
|
4
|
+
import { C as nativeEnumValueExistsAst, D as tableExistsAst, E as rlsPolicyExistsAst, O as tableIsEmptyAst, S as nativeEnumTypeExistsAst, T as rlsEnabledAst, _ as dropIndex$1, a as columnDefaultAst, b as extensionExistsAst, c as columnTypeAst, d as createPolicy, f as createSchema, g as dropDefaultAction, h as disableRowLevelSecurity$1, i as alterTable, l as constraintExistsAst, m as createType, n as alterIndexRename, o as columnExistsAst, p as createTable, r as alterPolicyRename, s as columnNullabilityAst, t as addColumnAction, u as createIndex$1, v as dropPolicy, w as noNullValuesAst, x as indexExistsAst, y as dropType } from "./ddl-BQFDVert-CcDdETee.mjs";
|
|
5
5
|
import { n as qualifyTableName } from "./planner-sql-checks-Bxz8yvg8-Bj6jGClB.mjs";
|
|
6
6
|
import { t as buildColumnTypeSql } from "./planner-ddl-builders-DSpQVbIm-Y4SbsU-O.mjs";
|
|
7
|
-
import { DdlColumn, FunctionColumnDefault, LiteralColumnDefault } from "@prisma/orm-family-sql/relational-core/ast";
|
|
7
|
+
import { DdlColumn, FunctionColumnDefault, LiteralColumnDefault, opaqueSql, renderOpaqueSql } from "@prisma/orm-family-sql/relational-core/ast";
|
|
8
8
|
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
9
9
|
import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
|
|
10
10
|
import { namingOf } from "@prisma/orm-family-sql/schema-ir/naming";
|
|
@@ -14,7 +14,7 @@ import { InternalError, assertNever } from "@prisma/orm-framework/utils/internal
|
|
|
14
14
|
import { errorUnfilledPlaceholder } from "@prisma/orm-framework/errors/migration";
|
|
15
15
|
import { TsExpression, jsonToTsSource } from "@prisma/orm-framework/ts-render";
|
|
16
16
|
import { REFERENTIAL_ACTION_SQL } from "@prisma/orm-family-sql/contract/referential-action-sql";
|
|
17
|
-
//#region ../../../3-targets/3-targets/postgres/dist/op-factory-call-
|
|
17
|
+
//#region ../../../3-targets/3-targets/postgres/dist/op-factory-call-BeXmjOLn.mjs
|
|
18
18
|
/**
|
|
19
19
|
* Maps a planner schema name to the contract-free DDL builder's optional
|
|
20
20
|
* `schema` field: the unbound sentinel becomes `undefined` (the builder omits
|
|
@@ -75,7 +75,7 @@ async function dropColumn(schemaName, tableName, columnName, lowerer) {
|
|
|
75
75
|
*/
|
|
76
76
|
async function alterColumnType(schemaName, tableName, columnName, options, lowerer) {
|
|
77
77
|
const qualified = qualifyTableName(schemaName, tableName);
|
|
78
|
-
const usingClause = options.using ? ` USING ${options.using}` : ` USING ${quoteIdentifier(columnName)}::${options.qualifiedTargetType}`;
|
|
78
|
+
const usingClause = options.using ? ` USING ${renderOpaqueSql(opaqueSql(options.using))}` : ` USING ${quoteIdentifier(columnName)}::${options.qualifiedTargetType}`;
|
|
79
79
|
const { present } = await columnExistsSteps(lowerer, {
|
|
80
80
|
schema: schemaName,
|
|
81
81
|
table: tableName,
|
|
@@ -195,7 +195,7 @@ function refuseUnwritableSetDefault(tableName, column) {
|
|
|
195
195
|
...meta,
|
|
196
196
|
reason: "set-default-without-default"
|
|
197
197
|
} });
|
|
198
|
-
if (column.default.kind === "function" && column.default.expression === "autoincrement()") throw postgresError("CONTRACT.DEFAULT_INVALID", `setDefault cannot give the existing column "${column.name}" of table "${tableName}" an autoincrement() default, because autoincrement() is written as the column's SERIAL type when the column is created. Set a sequence default instead, as in fn("nextval('<sequence>'::regclass)").`, { meta: {
|
|
198
|
+
if (column.default.kind === "function" && column.default.expression.text === "autoincrement()") throw postgresError("CONTRACT.DEFAULT_INVALID", `setDefault cannot give the existing column "${column.name}" of table "${tableName}" an autoincrement() default, because autoincrement() is written as the column's SERIAL type when the column is created. Set a sequence default instead, as in fn("nextval('<sequence>'::regclass)").`, { meta: {
|
|
199
199
|
...meta,
|
|
200
200
|
reason: "set-default-autoincrement"
|
|
201
201
|
} });
|
|
@@ -356,7 +356,7 @@ async function addCheckConstraint(schemaName, tableName, constraintName, express
|
|
|
356
356
|
operationClass: "additive",
|
|
357
357
|
target: targetDetails("checkConstraint", constraintName, schemaName, tableName),
|
|
358
358
|
precheck: [step(`ensure constraint "${constraintName}" does not exist`, absent.sql, absent.params)],
|
|
359
|
-
execute: [step(`add check constraint "${constraintName}"`, `ALTER TABLE ${qualified} ADD CONSTRAINT ${quoteIdentifier(constraintName)} CHECK (${expression})`)],
|
|
359
|
+
execute: [step(`add check constraint "${constraintName}"`, `ALTER TABLE ${qualified} ADD CONSTRAINT ${quoteIdentifier(constraintName)} CHECK (${renderOpaqueSql(opaqueSql(expression))})`)],
|
|
360
360
|
postcheck: [step(`verify constraint "${constraintName}" exists`, present.sql, present.params)]
|
|
361
361
|
};
|
|
362
362
|
}
|
|
@@ -786,7 +786,7 @@ async function buildAddNotNullColumnWithTemporaryDefaultOperation(options) {
|
|
|
786
786
|
const { schema, tableName, columnName, column, codecHooks, storageTypes, temporaryDefault, lowerer } = options;
|
|
787
787
|
const ddlColumn = col(columnName, buildColumnTypeSql(column, codecHooks, storageTypes), {
|
|
788
788
|
notNull: true,
|
|
789
|
-
default: new FunctionColumnDefault(temporaryDefault)
|
|
789
|
+
default: new FunctionColumnDefault(opaqueSql(temporaryDefault))
|
|
790
790
|
});
|
|
791
791
|
const addColumn = await lowerer.lowerToExecuteRequest(alterTable({
|
|
792
792
|
...ifDefined("schema", boundSchema(schema)),
|
|
@@ -876,8 +876,8 @@ function postgresDefaultToDdlColumnDefault(columnDefault) {
|
|
|
876
876
|
case "literal": return new LiteralColumnDefault(columnDefault.value);
|
|
877
877
|
case "function":
|
|
878
878
|
if (columnDefault.expression === "autoincrement()") return void 0;
|
|
879
|
-
return new FunctionColumnDefault(columnDefault.expression);
|
|
880
|
-
case "sequence": return new FunctionColumnDefault(`nextval('${escapeLiteral(quoteIdentifier(columnDefault.name))}'::regclass)`);
|
|
879
|
+
return new FunctionColumnDefault(opaqueSql(columnDefault.expression));
|
|
880
|
+
case "sequence": return new FunctionColumnDefault(opaqueSql(`nextval('${escapeLiteral(quoteIdentifier(columnDefault.name))}'::regclass)`));
|
|
881
881
|
default: {
|
|
882
882
|
const exhaustive = columnDefault;
|
|
883
883
|
return assertNever(exhaustive, `postgresDefaultToDdlColumnDefault: unhandled kind "${blindCast(exhaustive).kind}"`);
|
|
@@ -887,7 +887,7 @@ function postgresDefaultToDdlColumnDefault(columnDefault) {
|
|
|
887
887
|
function renderDdlColumnDefault(def) {
|
|
888
888
|
if (!def) return "";
|
|
889
889
|
if (def.kind === "literal") return `lit(${jsonToTsSource(def.value)})`;
|
|
890
|
-
return `fn(${jsonToTsSource(def.expression)})`;
|
|
890
|
+
return `fn(${jsonToTsSource(def.expression.text)})`;
|
|
891
891
|
}
|
|
892
892
|
function renderDdlColumnAsTsCall(col) {
|
|
893
893
|
const opts = [];
|
|
@@ -916,7 +916,7 @@ function renderDdlConstraintAsTsCall(constraint) {
|
|
|
916
916
|
const nameOpt = constraint.name ? `, { name: ${jsonToTsSource(constraint.name)} }` : "";
|
|
917
917
|
return `unique(${jsonToTsSource(constraint.columns)}${nameOpt})`;
|
|
918
918
|
}
|
|
919
|
-
case "check-expression": return `checkExpression(${jsonToTsSource(constraint.name)}, ${jsonToTsSource(constraint.expression)})`;
|
|
919
|
+
case "check-expression": return `checkExpression(${jsonToTsSource(constraint.name)}, ${jsonToTsSource(constraint.expression.text)})`;
|
|
920
920
|
}
|
|
921
921
|
}
|
|
922
922
|
function needsColOrConstraintImport(columns) {
|
|
@@ -2150,4 +2150,4 @@ function columnNameOfCall(call) {
|
|
|
2150
2150
|
//#endregion
|
|
2151
2151
|
export { RenameIndexCall as A, renameTableStatement as B, DropNativeEnumTypeCall as C, EnableRowLevelSecurityCall as D, DropTableCall as E, buildTargetDetails as F, columnNameOfCall as I, createExtension as L, RenameTableCall as M, SetDefaultCall as N, RawSqlCall as O, SetNotNullCall as P, installExtension as R, DropIndexCall as S, DropPostgresRlsPolicyCall as T, DisableRowLevelSecurityCall as _, AddNotNullColumnDirectCall as a, DropConstraintCall as b, AddUniqueCall as c, CreateIndexCall as d, CreateNativeEnumTypeCall as f, DataTransformCall as g, CreateTableCall as h, AddNativeEnumValueCall as i, RenamePostgresRlsPolicyCall as j, RenameConstraintCall as k, AlterColumnTypeCall as l, CreateSchemaCall as m, AddColumnCall as n, AddNotNullColumnWithTempDefaultCall as o, CreatePostgresRlsPolicyCall as p, AddForeignKeyCall as r, AddPrimaryKeyCall as s, AddCheckConstraintCall as t, CreateExtensionCall as u, DropCheckConstraintCall as v, DropNotNullCall as w, DropDefaultCall as x, DropColumnCall as y, postgresDefaultToDdlColumnDefault as z };
|
|
2152
2152
|
|
|
2153
|
-
//# sourceMappingURL=op-factory-call-
|
|
2153
|
+
//# sourceMappingURL=op-factory-call-BeXmjOLn-Cm9tMP0i.mjs.map
|