@prisma-next/target-postgres 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{codec-ids-CTikp1if.mjs → codec-ids-BvytN2P8.mjs} +3 -3
- package/dist/codec-ids-BvytN2P8.mjs.map +1 -0
- package/dist/{codec-ids-B1vOchLE.d.mts → codec-ids-CnXu9Qy3.d.mts} +3 -3
- package/dist/codec-ids-CnXu9Qy3.d.mts.map +1 -0
- package/dist/codec-ids.d.mts +2 -2
- package/dist/codec-ids.mjs +2 -2
- package/dist/{codec-types-CnFiNML4.d.mts → codec-types-DHCkwPKE.d.mts} +3 -3
- package/dist/{codec-types-CnFiNML4.d.mts.map → codec-types-DHCkwPKE.d.mts.map} +1 -1
- package/dist/codec-types.d.mts +1 -1
- package/dist/{codecs-CBpEv4s5.d.mts → codecs--0A5_4Bq.d.mts} +26 -23
- package/dist/codecs--0A5_4Bq.d.mts.map +1 -0
- package/dist/codecs.d.mts +2 -2
- package/dist/codecs.mjs +28 -35
- package/dist/codecs.mjs.map +1 -1
- package/dist/contract-free.d.mts +163 -15
- package/dist/contract-free.d.mts.map +1 -1
- package/dist/contract-free.mjs +4 -17
- package/dist/contract-free.mjs.map +1 -1
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +21 -27
- package/dist/control.mjs.map +1 -1
- package/dist/{data-transform-D25tLeYU.mjs → data-transform-BOWpliq8.mjs} +9 -17
- package/dist/data-transform-BOWpliq8.mjs.map +1 -0
- package/dist/{data-transform-DGOqcLrf.d.mts → data-transform-DDgWdB5o.d.mts} +2 -2
- package/dist/data-transform-DDgWdB5o.d.mts.map +1 -0
- package/dist/data-transform.d.mts +1 -1
- package/dist/data-transform.mjs +1 -1
- package/dist/ddl-QDyOSeLc.mjs +251 -0
- package/dist/ddl-QDyOSeLc.mjs.map +1 -0
- package/dist/ddl.d.mts +2 -2
- package/dist/ddl.mjs +2 -2
- package/dist/descriptor-meta-CpGygXpI.mjs +140 -0
- package/dist/descriptor-meta-CpGygXpI.mjs.map +1 -0
- package/dist/{issue-planner-Br0pt1Ea.mjs → issue-planner-DL6g3CmE.mjs} +52 -366
- package/dist/issue-planner-DL6g3CmE.mjs.map +1 -0
- package/dist/issue-planner.d.mts +8 -11
- package/dist/issue-planner.d.mts.map +1 -1
- package/dist/issue-planner.mjs +1 -1
- package/dist/migration.d.mts +5 -92
- package/dist/migration.d.mts.map +1 -1
- package/dist/migration.mjs +4 -4
- package/dist/{nodes-DZk2JZG3.mjs → nodes-Bbhs2rwj.mjs} +31 -2
- package/dist/nodes-Bbhs2rwj.mjs.map +1 -0
- package/dist/{nodes-779hmCfL.d.mts → nodes-pLeLgdis.d.mts} +30 -3
- package/dist/nodes-pLeLgdis.d.mts.map +1 -0
- package/dist/{op-factory-call-D2aAUhmS.mjs → op-factory-call-D_p5vxwt.mjs} +601 -418
- package/dist/op-factory-call-D_p5vxwt.mjs.map +1 -0
- package/dist/{op-factory-call-DMA86_2D.d.mts → op-factory-call-DmQEc3XV.d.mts} +119 -72
- package/dist/op-factory-call-DmQEc3XV.d.mts.map +1 -0
- package/dist/op-factory-call.d.mts +2 -2
- package/dist/op-factory-call.mjs +2 -2
- package/dist/pack.d.mts +36 -15
- package/dist/pack.d.mts.map +1 -1
- package/dist/pack.mjs +1 -1
- package/dist/{planner-CAYPJObw.mjs → planner-Bs_baQax.mjs} +25 -45
- package/dist/planner-Bs_baQax.mjs.map +1 -0
- package/dist/{planner-ddl-builders-Cw2n2llW.mjs → planner-ddl-builders-B2wOwLqI.mjs} +2 -2
- package/dist/planner-ddl-builders-B2wOwLqI.mjs.map +1 -0
- package/dist/planner-ddl-builders.d.mts +4 -4
- package/dist/planner-ddl-builders.d.mts.map +1 -1
- package/dist/planner-ddl-builders.mjs +1 -1
- package/dist/{planner-identity-values-BIpa5p2I.mjs → planner-identity-values-CJPha2Sz.mjs} +3 -9
- package/dist/planner-identity-values-CJPha2Sz.mjs.map +1 -0
- package/dist/planner-identity-values.d.mts +1 -1
- package/dist/planner-identity-values.d.mts.map +1 -1
- package/dist/planner-identity-values.mjs +1 -1
- package/dist/{planner-produced-postgres-migration-NSEhWL0L.mjs → planner-produced-postgres-migration-Cji5vxUf.mjs} +6 -4
- package/dist/planner-produced-postgres-migration-Cji5vxUf.mjs.map +1 -0
- package/dist/{planner-produced-postgres-migration-B4EDvLdz.d.mts → planner-produced-postgres-migration-QqHa2C2l.d.mts} +5 -6
- package/dist/planner-produced-postgres-migration-QqHa2C2l.d.mts.map +1 -0
- package/dist/planner-produced-postgres-migration.d.mts +1 -1
- package/dist/planner-produced-postgres-migration.mjs +1 -1
- package/dist/planner-sql-checks-jqUUGyQR.mjs +152 -0
- package/dist/planner-sql-checks-jqUUGyQR.mjs.map +1 -0
- package/dist/planner-sql-checks.d.mts +3 -49
- package/dist/planner-sql-checks.d.mts.map +1 -1
- package/dist/planner-sql-checks.mjs +2 -2
- package/dist/{planner-type-resolution-836DExFN.mjs → planner-type-resolution-Bt2f_q-F.mjs} +1 -6
- package/dist/planner-type-resolution-Bt2f_q-F.mjs.map +1 -0
- package/dist/planner.d.mts +4 -4
- package/dist/planner.d.mts.map +1 -1
- package/dist/planner.mjs +1 -1
- package/dist/{postgres-contract-serializer-DYTyXjPf.mjs → postgres-contract-serializer-k3TAcPMY.mjs} +30 -37
- package/dist/postgres-contract-serializer-k3TAcPMY.mjs.map +1 -0
- package/dist/postgres-migration-B5jKrXv3.mjs +145 -0
- package/dist/postgres-migration-B5jKrXv3.mjs.map +1 -0
- package/dist/postgres-migration-Y4YBJqkS.d.mts +181 -0
- package/dist/postgres-migration-Y4YBJqkS.d.mts.map +1 -0
- package/dist/{postgres-schema-BuxCxbvB.mjs → postgres-schema-COGZ1ark.mjs} +82 -23
- package/dist/postgres-schema-COGZ1ark.mjs.map +1 -0
- package/dist/{render-ops-BpjstrKQ.mjs → render-ops-BREh1kHe.mjs} +10 -5
- package/dist/render-ops-BREh1kHe.mjs.map +1 -0
- package/dist/render-ops.d.mts +2 -2
- package/dist/render-ops.d.mts.map +1 -1
- package/dist/render-ops.mjs +1 -1
- package/dist/runtime.d.mts +1 -0
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +2 -2
- package/dist/table-source-BvFo7gVs.d.mts +15 -0
- package/dist/table-source-BvFo7gVs.d.mts.map +1 -0
- package/dist/types.d.mts +34 -19
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +2 -3
- package/package.json +17 -18
- package/src/contract-free/checks.ts +363 -0
- package/src/contract-free/ddl.ts +28 -1
- package/src/core/authoring.ts +43 -44
- package/src/core/codec-helpers.ts +0 -17
- package/src/core/codec-ids.ts +1 -1
- package/src/core/codec-type-map.ts +2 -2
- package/src/core/codecs.ts +43 -48
- package/src/core/ddl/nodes.ts +59 -1
- package/src/core/migrations/control-policy.ts +17 -47
- package/src/core/migrations/issue-planner.ts +34 -70
- package/src/core/migrations/op-factory-call.ts +486 -215
- package/src/core/migrations/operations/columns.ts +175 -140
- package/src/core/migrations/operations/constraints.ts +79 -108
- package/src/core/migrations/operations/data-transform.ts +15 -18
- package/src/core/migrations/operations/dependencies.ts +16 -14
- package/src/core/migrations/operations/indexes.ts +31 -28
- package/src/core/migrations/operations/shared.ts +2 -2
- package/src/core/migrations/operations/tables.ts +13 -14
- package/src/core/migrations/planner-ddl-builders.ts +3 -4
- package/src/core/migrations/planner-identity-values.ts +4 -28
- package/src/core/migrations/planner-produced-postgres-migration.ts +15 -7
- package/src/core/migrations/planner-recipes.ts +44 -39
- package/src/core/migrations/planner-sql-checks.ts +3 -178
- package/src/core/migrations/planner-strategies.ts +76 -449
- package/src/core/migrations/planner-type-resolution.ts +2 -20
- package/src/core/migrations/planner.ts +6 -6
- package/src/core/migrations/postgres-migration.ts +287 -7
- package/src/core/migrations/render-ops.ts +26 -13
- package/src/core/migrations/runner.ts +26 -20
- package/src/core/postgres-contract-serializer.ts +37 -54
- package/src/core/postgres-enum-type-schema.ts +17 -0
- package/src/core/postgres-schema.ts +86 -46
- package/src/exports/codecs.ts +2 -2
- package/src/exports/contract-free.ts +22 -1
- package/src/exports/control.ts +0 -22
- package/src/exports/ddl.ts +4 -0
- package/src/exports/migration.ts +1 -29
- package/src/exports/op-factory-call.ts +0 -4
- package/src/exports/planner-sql-checks.ts +0 -7
- package/src/exports/types.ts +0 -1
- package/dist/codec-ids-B1vOchLE.d.mts.map +0 -1
- package/dist/codec-ids-CTikp1if.mjs.map +0 -1
- package/dist/codecs-CBpEv4s5.d.mts.map +0 -1
- package/dist/data-transform-D25tLeYU.mjs.map +0 -1
- package/dist/data-transform-DGOqcLrf.d.mts.map +0 -1
- package/dist/ddl-77SyXgFt.mjs +0 -30
- package/dist/ddl-77SyXgFt.mjs.map +0 -1
- package/dist/descriptor-meta-DKmj-IMN.mjs +0 -14
- package/dist/descriptor-meta-DKmj-IMN.mjs.map +0 -1
- package/dist/descriptor-meta-runtime-My8_s4cs.mjs +0 -130
- package/dist/descriptor-meta-runtime-My8_s4cs.mjs.map +0 -1
- package/dist/enum-planning-BCyvlFHk.mjs +0 -0
- package/dist/enum-planning-BCyvlFHk.mjs.map +0 -1
- package/dist/enum-planning.d.mts +0 -86
- package/dist/enum-planning.d.mts.map +0 -1
- package/dist/enum-planning.mjs +0 -2
- package/dist/issue-planner-Br0pt1Ea.mjs.map +0 -1
- package/dist/nodes-779hmCfL.d.mts.map +0 -1
- package/dist/nodes-DZk2JZG3.mjs.map +0 -1
- package/dist/op-factory-call-D2aAUhmS.mjs.map +0 -1
- package/dist/op-factory-call-DMA86_2D.d.mts.map +0 -1
- package/dist/planner-CAYPJObw.mjs.map +0 -1
- package/dist/planner-ddl-builders-Cw2n2llW.mjs.map +0 -1
- package/dist/planner-identity-values-BIpa5p2I.mjs.map +0 -1
- package/dist/planner-produced-postgres-migration-B4EDvLdz.d.mts.map +0 -1
- package/dist/planner-produced-postgres-migration-NSEhWL0L.mjs.map +0 -1
- package/dist/planner-sql-checks-DAdhnI2c.mjs +0 -272
- package/dist/planner-sql-checks-DAdhnI2c.mjs.map +0 -1
- package/dist/planner-type-resolution-836DExFN.mjs.map +0 -1
- package/dist/postgres-contract-serializer-DYTyXjPf.mjs.map +0 -1
- package/dist/postgres-enum-type-BVn63a89.d.mts +0 -72
- package/dist/postgres-enum-type-BVn63a89.d.mts.map +0 -1
- package/dist/postgres-enum-type-DPKqCBem.mjs +0 -62
- package/dist/postgres-enum-type-DPKqCBem.mjs.map +0 -1
- package/dist/postgres-migration-COore9Mz.mjs +0 -71
- package/dist/postgres-migration-COore9Mz.mjs.map +0 -1
- package/dist/postgres-migration-DZ_gLUOW.d.mts +0 -72
- package/dist/postgres-migration-DZ_gLUOW.d.mts.map +0 -1
- package/dist/postgres-schema-BuxCxbvB.mjs.map +0 -1
- package/dist/render-ops-BpjstrKQ.mjs.map +0 -1
- package/dist/shared-DarONYBZ.d.mts +0 -43
- package/dist/shared-DarONYBZ.d.mts.map +0 -1
- package/src/core/migrations/enum-planning.ts +0 -213
- package/src/core/migrations/operations/enums.ts +0 -114
- package/src/core/postgres-enum-type.ts +0 -89
- package/src/exports/enum-planning.ts +0 -11
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { _ as PG_TEXT_CODEC_ID } from "./codec-ids-BvytN2P8.mjs";
|
|
2
|
+
import { a as PostgresTableSource, i as postgresCreateNamespace } from "./postgres-schema-COGZ1ark.mjs";
|
|
3
|
+
import { i as PostgresCreateTable, n as PostgresAlterTable, r as PostgresCreateSchema, t as AddColumnAction } from "./nodes-Bbhs2rwj.mjs";
|
|
4
|
+
import { cfExpr, cfTable, exprSelect } from "@prisma-next/sql-relational-core/contract-free";
|
|
5
|
+
//#region src/contract-free/checks.ts
|
|
6
|
+
/**
|
|
7
|
+
* `to_regclass($1)` with the qualified table name bound as a text parameter.
|
|
8
|
+
* Thin vocabulary wrapper over the core `cfExpr.fn` helper — the target
|
|
9
|
+
* supplies only the template and the codec'd operand.
|
|
10
|
+
*/
|
|
11
|
+
function toRegclass(qualifiedName) {
|
|
12
|
+
return cfExpr.fn({
|
|
13
|
+
method: "to_regclass",
|
|
14
|
+
template: "to_regclass({{self}})",
|
|
15
|
+
self: cfExpr.param(qualifiedName, PG_TEXT_CODEC_ID),
|
|
16
|
+
returns: {
|
|
17
|
+
codecId: PG_TEXT_CODEC_ID,
|
|
18
|
+
nullable: true
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Typed builder for the migration planner's table-existence checks. Produces
|
|
24
|
+
* FROM-less `SELECT to_regclass($1) IS [NOT] NULL AS "result"` ASTs with the
|
|
25
|
+
* qualified table name bound as a text parameter — never inlined into the SQL.
|
|
26
|
+
*
|
|
27
|
+
* `schema` is a namespace coordinate: the framework `__unbound__` sentinel
|
|
28
|
+
* elides the qualifier (search_path decides at runtime); any other id
|
|
29
|
+
* qualifies as `"schema"."table"`.
|
|
30
|
+
*/
|
|
31
|
+
function tableExistsAst(schema, table) {
|
|
32
|
+
const regclass = toRegclass(postgresCreateNamespace({
|
|
33
|
+
id: schema,
|
|
34
|
+
entries: { table: {} }
|
|
35
|
+
}).qualifyTable(table));
|
|
36
|
+
return {
|
|
37
|
+
tableAbsent: () => exprSelect().project("result", regclass.isNull()).build(),
|
|
38
|
+
tablePresent: () => exprSelect().project("result", regclass.isNotNull()).build()
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Typed builder for the migration planner's constraint-existence checks.
|
|
43
|
+
* Produces `SELECT [NOT ]EXISTS (SELECT 1 FROM pg_constraint c JOIN
|
|
44
|
+
* pg_namespace n ON n.oid = c.connamespace WHERE c.conname = $1 AND
|
|
45
|
+
* n.nspname = $2 [AND c.conrelid = to_regclass($3)]) AS "result"` with the
|
|
46
|
+
* constraint name, schema name, and qualified table name bound as text
|
|
47
|
+
* parameters.
|
|
48
|
+
*
|
|
49
|
+
* When `table` is omitted the check matches by name + schema across all
|
|
50
|
+
* tables. Pass `table` to scope the check to a single table (prevents false
|
|
51
|
+
* matches on identically-named constraints in different tables). `schema`
|
|
52
|
+
* is a namespace coordinate: the `__unbound__` sentinel compares `nspname`
|
|
53
|
+
* against `current_schema()` instead of a bound parameter.
|
|
54
|
+
*/
|
|
55
|
+
function constraintExistsAst(options) {
|
|
56
|
+
const namespace = postgresCreateNamespace({
|
|
57
|
+
id: options.schema,
|
|
58
|
+
entries: { table: {} }
|
|
59
|
+
});
|
|
60
|
+
const conditions = [cfExpr.columnRef("c", "conname").eqParam(options.constraintName, PG_TEXT_CODEC_ID), cfExpr.columnRef("n", "nspname").eqExpr(namespace.schemaFilterExpression())];
|
|
61
|
+
if (options.table !== void 0) conditions.push(cfExpr.columnRef("c", "conrelid").eqExpr(toRegclass(namespace.qualifyTable(options.table))));
|
|
62
|
+
const 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));
|
|
63
|
+
return {
|
|
64
|
+
constraintPresent: () => exprSelect().project("result", cfExpr.exists(inner())).build(),
|
|
65
|
+
constraintAbsent: () => exprSelect().project("result", cfExpr.notExists(inner())).build()
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function checkNamespace(schema) {
|
|
69
|
+
return postgresCreateNamespace({
|
|
70
|
+
id: schema,
|
|
71
|
+
entries: { table: {} }
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
function informationSchemaColumns() {
|
|
75
|
+
return new PostgresTableSource({
|
|
76
|
+
schema: "information_schema",
|
|
77
|
+
name: "columns"
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
function infoSchemaColumnConditions(options) {
|
|
81
|
+
return [
|
|
82
|
+
cfExpr.identifierRef("table_schema").eqExpr(checkNamespace(options.schema).schemaFilterExpression()),
|
|
83
|
+
cfExpr.identifierRef("table_name").eqParam(options.table, PG_TEXT_CODEC_ID),
|
|
84
|
+
cfExpr.identifierRef("column_name").eqParam(options.column, PG_TEXT_CODEC_ID)
|
|
85
|
+
];
|
|
86
|
+
}
|
|
87
|
+
function infoSchemaColumnQuery(conditions) {
|
|
88
|
+
return exprSelect().from(informationSchemaColumns()).project("one", cfExpr.lit(1)).where(cfExpr.allOf(conditions));
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Typed builder for column-existence checks over
|
|
92
|
+
* `information_schema.columns`, with schema, table, and column names bound
|
|
93
|
+
* as text parameters.
|
|
94
|
+
*/
|
|
95
|
+
function columnExistsAst(options) {
|
|
96
|
+
const inner = () => infoSchemaColumnQuery(infoSchemaColumnConditions(options));
|
|
97
|
+
return {
|
|
98
|
+
columnPresent: () => exprSelect().project("result", cfExpr.exists(inner())).build(),
|
|
99
|
+
columnAbsent: () => exprSelect().project("result", cfExpr.notExists(inner())).build()
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Typed nullability check: EXISTS over `information_schema.columns` with
|
|
104
|
+
* `is_nullable` compared against the bound `'YES'` / `'NO'` marker.
|
|
105
|
+
*/
|
|
106
|
+
function columnNullabilityAst(options) {
|
|
107
|
+
const conditions = [...infoSchemaColumnConditions(options), cfExpr.identifierRef("is_nullable").eqParam(options.nullable ? "YES" : "NO", PG_TEXT_CODEC_ID)];
|
|
108
|
+
return exprSelect().project("result", cfExpr.exists(infoSchemaColumnQuery(conditions))).build();
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Typed default-presence checks over `information_schema.columns`.
|
|
112
|
+
* `defaultPresent` / `defaultAbsent` assert the column row exists with a
|
|
113
|
+
* non-null / null `column_default`; `noDefault` is the NOT EXISTS variant
|
|
114
|
+
* (also true when the column row is missing entirely).
|
|
115
|
+
*/
|
|
116
|
+
function columnDefaultAst(options) {
|
|
117
|
+
const withDefault = () => infoSchemaColumnQuery([...infoSchemaColumnConditions(options), cfExpr.identifierRef("column_default").isNotNull()]);
|
|
118
|
+
const withoutDefault = () => infoSchemaColumnQuery([...infoSchemaColumnConditions(options), cfExpr.identifierRef("column_default").isNull()]);
|
|
119
|
+
return {
|
|
120
|
+
defaultPresent: () => exprSelect().project("result", cfExpr.exists(withDefault())).build(),
|
|
121
|
+
defaultAbsent: () => exprSelect().project("result", cfExpr.exists(withoutDefault())).build(),
|
|
122
|
+
noDefault: () => exprSelect().project("result", cfExpr.notExists(withDefault())).build()
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Typed column-type check: EXISTS over `pg_attribute` joined to `pg_class`
|
|
127
|
+
* and `pg_namespace`, comparing `format_type(a.atttypid, a.atttypmod)`
|
|
128
|
+
* against the bound expected display type and excluding dropped columns.
|
|
129
|
+
*/
|
|
130
|
+
function columnTypeAst(options) {
|
|
131
|
+
const formatType = cfExpr.fn({
|
|
132
|
+
method: "format_type",
|
|
133
|
+
template: "format_type({{self}}, {{arg0}})",
|
|
134
|
+
self: cfExpr.columnRef("a", "atttypid"),
|
|
135
|
+
args: [cfExpr.columnRef("a", "atttypmod")],
|
|
136
|
+
returns: {
|
|
137
|
+
codecId: PG_TEXT_CODEC_ID,
|
|
138
|
+
nullable: false
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
const 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([
|
|
142
|
+
cfExpr.columnRef("n", "nspname").eqExpr(checkNamespace(options.schema).schemaFilterExpression()),
|
|
143
|
+
cfExpr.columnRef("c", "relname").eqParam(options.table, PG_TEXT_CODEC_ID),
|
|
144
|
+
cfExpr.columnRef("a", "attname").eqParam(options.column, PG_TEXT_CODEC_ID),
|
|
145
|
+
formatType.eqParam(options.expectedType, PG_TEXT_CODEC_ID),
|
|
146
|
+
cfExpr.columnRef("a", "attisdropped").not()
|
|
147
|
+
]));
|
|
148
|
+
return exprSelect().project("result", cfExpr.exists(inner)).build();
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Typed primary-key existence check over `pg_index` joined to `pg_class`
|
|
152
|
+
* and `pg_namespace`, with a LEFT JOIN on the index relation so an
|
|
153
|
+
* optional `constraintName` can scope the match to a named constraint.
|
|
154
|
+
*/
|
|
155
|
+
function tablePrimaryKeyAst(options) {
|
|
156
|
+
const conditions = [
|
|
157
|
+
cfExpr.columnRef("n", "nspname").eqExpr(checkNamespace(options.schema).schemaFilterExpression()),
|
|
158
|
+
cfExpr.columnRef("c", "relname").eqParam(options.table, PG_TEXT_CODEC_ID),
|
|
159
|
+
cfExpr.columnRef("i", "indisprimary")
|
|
160
|
+
];
|
|
161
|
+
if (options.constraintName !== void 0) conditions.push(cfExpr.columnRef("c2", "relname").eqParam(options.constraintName, PG_TEXT_CODEC_ID));
|
|
162
|
+
const 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));
|
|
163
|
+
return {
|
|
164
|
+
pkPresent: () => exprSelect().project("result", cfExpr.exists(inner())).build(),
|
|
165
|
+
pkAbsent: () => exprSelect().project("result", cfExpr.notExists(inner())).build()
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Typed emptiness check: NOT EXISTS over the user table itself with
|
|
170
|
+
* `LIMIT 1`. The table is addressed through the namespace's polymorphic
|
|
171
|
+
* `tableSource` (qualified for named schemas, bare for the unbound slot).
|
|
172
|
+
*/
|
|
173
|
+
function tableIsEmptyAst(schema, table) {
|
|
174
|
+
const inner = exprSelect().from(checkNamespace(schema).tableSource(table)).project("one", cfExpr.lit(1)).limit(1);
|
|
175
|
+
return exprSelect().project("result", cfExpr.notExists(inner)).build();
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Typed no-NULL-values data check used by `SET NOT NULL` prechecks:
|
|
179
|
+
* NOT EXISTS over the user table where the column IS NULL.
|
|
180
|
+
*/
|
|
181
|
+
function noNullValuesAst(options) {
|
|
182
|
+
const inner = exprSelect().from(checkNamespace(options.schema).tableSource(options.table)).project("one", cfExpr.lit(1)).where(cfExpr.identifierRef(options.column).isNull());
|
|
183
|
+
return exprSelect().project("result", cfExpr.notExists(inner)).build();
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Typed extension existence check over `pg_extension`, with the extension
|
|
187
|
+
* name bound as a text parameter.
|
|
188
|
+
*/
|
|
189
|
+
function extensionExistsAst(extensionName) {
|
|
190
|
+
const inner = () => exprSelect().from(cfTable("pg_extension")).project("one", cfExpr.lit(1)).where(cfExpr.identifierRef("extname").eqParam(extensionName, PG_TEXT_CODEC_ID));
|
|
191
|
+
return {
|
|
192
|
+
extensionPresent: () => exprSelect().project("result", cfExpr.exists(inner())).build(),
|
|
193
|
+
extensionAbsent: () => exprSelect().project("result", cfExpr.notExists(inner())).build()
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Typed index existence check riding the same `to_regclass` vocabulary as
|
|
198
|
+
* `tableExistsAst`, with the qualified index name bound as a text parameter.
|
|
199
|
+
*/
|
|
200
|
+
function indexExistsAst(schema, indexName) {
|
|
201
|
+
const regclass = toRegclass(checkNamespace(schema).qualifyTable(indexName));
|
|
202
|
+
return {
|
|
203
|
+
indexPresent: () => exprSelect().project("result", regclass.isNotNull()).build(),
|
|
204
|
+
indexAbsent: () => exprSelect().project("result", regclass.isNull()).build()
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
//#endregion
|
|
208
|
+
//#region src/contract-free/ddl.ts
|
|
209
|
+
/**
|
|
210
|
+
* Build a Postgres `CREATE TABLE` query node.
|
|
211
|
+
*
|
|
212
|
+
* Pass `constraints` for table-level composite primary keys, foreign keys, and
|
|
213
|
+
* unique constraints — use the {@link PrimaryKeyConstraint}, {@link ForeignKeyConstraint},
|
|
214
|
+
* and {@link UniqueConstraint} classes from `@prisma-next/sql-relational-core/ast`.
|
|
215
|
+
*
|
|
216
|
+
* Precondition: identifiers (`table`, `schema`, column names/types) are
|
|
217
|
+
* emitted to SQL verbatim — they are not quoted or escaped, so callers must
|
|
218
|
+
* pass pre-trusted values (e.g. fixed control-plane identifiers). String-literal
|
|
219
|
+
* default values, by contrast, are single-quote-escaped (embedded `'` doubled)
|
|
220
|
+
* by the renderer. Identifier quoting for untrusted identifiers is added when
|
|
221
|
+
* the migration planner adopts this lowering path.
|
|
222
|
+
*/
|
|
223
|
+
function createTable(options) {
|
|
224
|
+
return new PostgresCreateTable(options);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Build a Postgres `CREATE SCHEMA` query node. See {@link createTable} for the
|
|
228
|
+
* pre-trusted-identifier precondition.
|
|
229
|
+
*/
|
|
230
|
+
function createSchema(options) {
|
|
231
|
+
return new PostgresCreateSchema(options);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Build an `ADD COLUMN` action for use inside {@link alterTable}.
|
|
235
|
+
* The column is a structured `DdlColumn` so codec-encoded defaults flow
|
|
236
|
+
* through the adapter's `pgRenderDdlColumn` → `pgRenderDdlColumnDefault` path.
|
|
237
|
+
*/
|
|
238
|
+
function addColumnAction(column) {
|
|
239
|
+
return new AddColumnAction(column);
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Build a Postgres `ALTER TABLE` query node carrying one or more actions.
|
|
243
|
+
* See {@link addColumnAction} for building actions.
|
|
244
|
+
*/
|
|
245
|
+
function alterTable(options) {
|
|
246
|
+
return new PostgresAlterTable(options);
|
|
247
|
+
}
|
|
248
|
+
//#endregion
|
|
249
|
+
export { columnDefaultAst as a, columnTypeAst as c, indexExistsAst as d, noNullValuesAst as f, toRegclass as g, tablePrimaryKeyAst as h, createTable as i, constraintExistsAst as l, tableIsEmptyAst as m, alterTable as n, columnExistsAst as o, tableExistsAst as p, createSchema as r, columnNullabilityAst as s, addColumnAction as t, extensionExistsAst as u };
|
|
250
|
+
|
|
251
|
+
//# sourceMappingURL=ddl-QDyOSeLc.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ddl-QDyOSeLc.mjs","names":[],"sources":["../src/contract-free/checks.ts","../src/contract-free/ddl.ts"],"sourcesContent":["import type { SelectAst } from '@prisma-next/sql-relational-core/ast';\nimport {\n type CfExpr,\n type CfExprSelectQuery,\n cfExpr,\n cfTable,\n exprSelect,\n} from '@prisma-next/sql-relational-core/contract-free';\nimport { PostgresTableSource } from '../core/ast/table-source';\nimport { PG_TEXT_CODEC_ID } from '../core/codec-ids';\nimport { postgresCreateNamespace } from '../core/postgres-schema';\n\n/**\n * `to_regclass($1)` with the qualified table name bound as a text parameter.\n * Thin vocabulary wrapper over the core `cfExpr.fn` helper — the target\n * supplies only the template and the codec'd operand.\n */\nexport function toRegclass(qualifiedName: string): CfExpr {\n return cfExpr.fn({\n method: 'to_regclass',\n template: 'to_regclass({{self}})',\n self: cfExpr.param(qualifiedName, PG_TEXT_CODEC_ID),\n returns: { codecId: PG_TEXT_CODEC_ID, nullable: true },\n });\n}\n\nexport interface TableExistsCheckBuilder {\n tableAbsent(): SelectAst;\n tablePresent(): SelectAst;\n}\n\n/**\n * Typed builder for the migration planner's table-existence checks. Produces\n * FROM-less `SELECT to_regclass($1) IS [NOT] NULL AS \"result\"` ASTs with the\n * qualified table name bound as a text parameter — never inlined into the SQL.\n *\n * `schema` is a namespace coordinate: the framework `__unbound__` sentinel\n * elides the qualifier (search_path decides at runtime); any other id\n * qualifies as `\"schema\".\"table\"`.\n */\nexport function tableExistsAst(schema: string, table: string): TableExistsCheckBuilder {\n const qualified = postgresCreateNamespace({ id: schema, entries: { table: {} } }).qualifyTable(\n table,\n );\n const regclass = toRegclass(qualified);\n return {\n tableAbsent: () => exprSelect().project('result', regclass.isNull()).build(),\n tablePresent: () => exprSelect().project('result', regclass.isNotNull()).build(),\n };\n}\n\nexport interface ConstraintExistsCheckBuilder {\n constraintPresent(): SelectAst;\n constraintAbsent(): SelectAst;\n}\n\n/**\n * Typed builder for the migration planner's constraint-existence checks.\n * Produces `SELECT [NOT ]EXISTS (SELECT 1 FROM pg_constraint c JOIN\n * pg_namespace n ON n.oid = c.connamespace WHERE c.conname = $1 AND\n * n.nspname = $2 [AND c.conrelid = to_regclass($3)]) AS \"result\"` with the\n * constraint name, schema name, and qualified table name bound as text\n * parameters.\n *\n * When `table` is omitted the check matches by name + schema across all\n * tables. Pass `table` to scope the check to a single table (prevents false\n * matches on identically-named constraints in different tables). `schema`\n * is a namespace coordinate: the `__unbound__` sentinel compares `nspname`\n * against `current_schema()` instead of a bound parameter.\n */\nexport function constraintExistsAst(options: {\n readonly constraintName: string;\n readonly schema: string;\n readonly table?: string;\n}): ConstraintExistsCheckBuilder {\n const namespace = postgresCreateNamespace({ id: options.schema, entries: { table: {} } });\n const conditions = [\n cfExpr.columnRef('c', 'conname').eqParam(options.constraintName, PG_TEXT_CODEC_ID),\n cfExpr.columnRef('n', 'nspname').eqExpr(namespace.schemaFilterExpression()),\n ];\n if (options.table !== undefined) {\n conditions.push(\n cfExpr.columnRef('c', 'conrelid').eqExpr(toRegclass(namespace.qualifyTable(options.table))),\n );\n }\n const inner = (): CfExprSelectQuery =>\n exprSelect()\n .from(cfTable('pg_constraint', 'c'))\n .join(\n cfTable('pg_namespace', 'n'),\n cfExpr.columnRef('n', 'oid').eqExpr(cfExpr.columnRef('c', 'connamespace')),\n )\n .project('one', cfExpr.lit(1))\n .where(cfExpr.allOf(conditions));\n return {\n constraintPresent: () => exprSelect().project('result', cfExpr.exists(inner())).build(),\n constraintAbsent: () => exprSelect().project('result', cfExpr.notExists(inner())).build(),\n };\n}\n\nfunction checkNamespace(schema: string) {\n return postgresCreateNamespace({ id: schema, entries: { table: {} } });\n}\n\nfunction informationSchemaColumns(): PostgresTableSource {\n return new PostgresTableSource({ schema: 'information_schema', name: 'columns' });\n}\n\nfunction infoSchemaColumnConditions(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n}): CfExpr[] {\n return [\n cfExpr\n .identifierRef('table_schema')\n .eqExpr(checkNamespace(options.schema).schemaFilterExpression()),\n cfExpr.identifierRef('table_name').eqParam(options.table, PG_TEXT_CODEC_ID),\n cfExpr.identifierRef('column_name').eqParam(options.column, PG_TEXT_CODEC_ID),\n ];\n}\n\nfunction infoSchemaColumnQuery(conditions: ReadonlyArray<CfExpr>): CfExprSelectQuery {\n return exprSelect()\n .from(informationSchemaColumns())\n .project('one', cfExpr.lit(1))\n .where(cfExpr.allOf(conditions));\n}\n\nexport interface ColumnExistsCheckBuilder {\n columnPresent(): SelectAst;\n columnAbsent(): SelectAst;\n}\n\n/**\n * Typed builder for column-existence checks over\n * `information_schema.columns`, with schema, table, and column names bound\n * as text parameters.\n */\nexport function columnExistsAst(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n}): ColumnExistsCheckBuilder {\n const inner = () => infoSchemaColumnQuery(infoSchemaColumnConditions(options));\n return {\n columnPresent: () => exprSelect().project('result', cfExpr.exists(inner())).build(),\n columnAbsent: () => exprSelect().project('result', cfExpr.notExists(inner())).build(),\n };\n}\n\n/**\n * Typed nullability check: EXISTS over `information_schema.columns` with\n * `is_nullable` compared against the bound `'YES'` / `'NO'` marker.\n */\nexport function columnNullabilityAst(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n readonly nullable: boolean;\n}): SelectAst {\n const conditions = [\n ...infoSchemaColumnConditions(options),\n cfExpr.identifierRef('is_nullable').eqParam(options.nullable ? 'YES' : 'NO', PG_TEXT_CODEC_ID),\n ];\n return exprSelect()\n .project('result', cfExpr.exists(infoSchemaColumnQuery(conditions)))\n .build();\n}\n\nexport interface ColumnDefaultCheckBuilder {\n defaultPresent(): SelectAst;\n defaultAbsent(): SelectAst;\n noDefault(): SelectAst;\n}\n\n/**\n * Typed default-presence checks over `information_schema.columns`.\n * `defaultPresent` / `defaultAbsent` assert the column row exists with a\n * non-null / null `column_default`; `noDefault` is the NOT EXISTS variant\n * (also true when the column row is missing entirely).\n */\nexport function columnDefaultAst(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n}): ColumnDefaultCheckBuilder {\n const withDefault = () =>\n infoSchemaColumnQuery([\n ...infoSchemaColumnConditions(options),\n cfExpr.identifierRef('column_default').isNotNull(),\n ]);\n const withoutDefault = () =>\n infoSchemaColumnQuery([\n ...infoSchemaColumnConditions(options),\n cfExpr.identifierRef('column_default').isNull(),\n ]);\n return {\n defaultPresent: () => exprSelect().project('result', cfExpr.exists(withDefault())).build(),\n defaultAbsent: () => exprSelect().project('result', cfExpr.exists(withoutDefault())).build(),\n noDefault: () => exprSelect().project('result', cfExpr.notExists(withDefault())).build(),\n };\n}\n\n/**\n * Typed column-type check: EXISTS over `pg_attribute` joined to `pg_class`\n * and `pg_namespace`, comparing `format_type(a.atttypid, a.atttypmod)`\n * against the bound expected display type and excluding dropped columns.\n */\nexport function columnTypeAst(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n readonly expectedType: string;\n}): SelectAst {\n const formatType = cfExpr.fn({\n method: 'format_type',\n template: 'format_type({{self}}, {{arg0}})',\n self: cfExpr.columnRef('a', 'atttypid'),\n args: [cfExpr.columnRef('a', 'atttypmod')],\n returns: { codecId: PG_TEXT_CODEC_ID, nullable: false },\n });\n const inner = exprSelect()\n .from(cfTable('pg_attribute', 'a'))\n .join(\n cfTable('pg_class', 'c'),\n cfExpr.columnRef('c', 'oid').eqExpr(cfExpr.columnRef('a', 'attrelid')),\n )\n .join(\n cfTable('pg_namespace', 'n'),\n cfExpr.columnRef('n', 'oid').eqExpr(cfExpr.columnRef('c', 'relnamespace')),\n )\n .project('one', cfExpr.lit(1))\n .where(\n cfExpr.allOf([\n cfExpr\n .columnRef('n', 'nspname')\n .eqExpr(checkNamespace(options.schema).schemaFilterExpression()),\n cfExpr.columnRef('c', 'relname').eqParam(options.table, PG_TEXT_CODEC_ID),\n cfExpr.columnRef('a', 'attname').eqParam(options.column, PG_TEXT_CODEC_ID),\n formatType.eqParam(options.expectedType, PG_TEXT_CODEC_ID),\n cfExpr.columnRef('a', 'attisdropped').not(),\n ]),\n );\n return exprSelect().project('result', cfExpr.exists(inner)).build();\n}\n\nexport interface TablePrimaryKeyCheckBuilder {\n pkPresent(): SelectAst;\n pkAbsent(): SelectAst;\n}\n\n/**\n * Typed primary-key existence check over `pg_index` joined to `pg_class`\n * and `pg_namespace`, with a LEFT JOIN on the index relation so an\n * optional `constraintName` can scope the match to a named constraint.\n */\nexport function tablePrimaryKeyAst(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraintName?: string;\n}): TablePrimaryKeyCheckBuilder {\n const conditions = [\n cfExpr\n .columnRef('n', 'nspname')\n .eqExpr(checkNamespace(options.schema).schemaFilterExpression()),\n cfExpr.columnRef('c', 'relname').eqParam(options.table, PG_TEXT_CODEC_ID),\n cfExpr.columnRef('i', 'indisprimary'),\n ];\n if (options.constraintName !== undefined) {\n conditions.push(\n cfExpr.columnRef('c2', 'relname').eqParam(options.constraintName, PG_TEXT_CODEC_ID),\n );\n }\n const inner = () =>\n exprSelect()\n .from(cfTable('pg_index', 'i'))\n .join(\n cfTable('pg_class', 'c'),\n cfExpr.columnRef('c', 'oid').eqExpr(cfExpr.columnRef('i', 'indrelid')),\n )\n .join(\n cfTable('pg_namespace', 'n'),\n cfExpr.columnRef('n', 'oid').eqExpr(cfExpr.columnRef('c', 'relnamespace')),\n )\n .leftJoin(\n cfTable('pg_class', 'c2'),\n cfExpr.columnRef('c2', 'oid').eqExpr(cfExpr.columnRef('i', 'indexrelid')),\n )\n .project('one', cfExpr.lit(1))\n .where(cfExpr.allOf(conditions));\n return {\n pkPresent: () => exprSelect().project('result', cfExpr.exists(inner())).build(),\n pkAbsent: () => exprSelect().project('result', cfExpr.notExists(inner())).build(),\n };\n}\n\n/**\n * Typed emptiness check: NOT EXISTS over the user table itself with\n * `LIMIT 1`. The table is addressed through the namespace's polymorphic\n * `tableSource` (qualified for named schemas, bare for the unbound slot).\n */\nexport function tableIsEmptyAst(schema: string, table: string): SelectAst {\n const inner = exprSelect()\n .from(checkNamespace(schema).tableSource(table))\n .project('one', cfExpr.lit(1))\n .limit(1);\n return exprSelect().project('result', cfExpr.notExists(inner)).build();\n}\n\n/**\n * Typed no-NULL-values data check used by `SET NOT NULL` prechecks:\n * NOT EXISTS over the user table where the column IS NULL.\n */\nexport function noNullValuesAst(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n}): SelectAst {\n const inner = exprSelect()\n .from(checkNamespace(options.schema).tableSource(options.table))\n .project('one', cfExpr.lit(1))\n .where(cfExpr.identifierRef(options.column).isNull());\n return exprSelect().project('result', cfExpr.notExists(inner)).build();\n}\n\nexport interface ExtensionExistsCheckBuilder {\n extensionPresent(): SelectAst;\n extensionAbsent(): SelectAst;\n}\n\n/**\n * Typed extension existence check over `pg_extension`, with the extension\n * name bound as a text parameter.\n */\nexport function extensionExistsAst(extensionName: string): ExtensionExistsCheckBuilder {\n const inner = () =>\n exprSelect()\n .from(cfTable('pg_extension'))\n .project('one', cfExpr.lit(1))\n .where(cfExpr.identifierRef('extname').eqParam(extensionName, PG_TEXT_CODEC_ID));\n return {\n extensionPresent: () => exprSelect().project('result', cfExpr.exists(inner())).build(),\n extensionAbsent: () => exprSelect().project('result', cfExpr.notExists(inner())).build(),\n };\n}\n\nexport interface IndexExistsCheckBuilder {\n indexPresent(): SelectAst;\n indexAbsent(): SelectAst;\n}\n\n/**\n * Typed index existence check riding the same `to_regclass` vocabulary as\n * `tableExistsAst`, with the qualified index name bound as a text parameter.\n */\nexport function indexExistsAst(schema: string, indexName: string): IndexExistsCheckBuilder {\n const regclass = toRegclass(checkNamespace(schema).qualifyTable(indexName));\n return {\n indexPresent: () => exprSelect().project('result', regclass.isNotNull()).build(),\n indexAbsent: () => exprSelect().project('result', regclass.isNull()).build(),\n };\n}\n","import type { DdlColumn, DdlTableConstraint } from '@prisma-next/sql-relational-core/ast';\nimport {\n AddColumnAction,\n type AnyAlterTableAction,\n PostgresAlterTable,\n PostgresCreateSchema,\n PostgresCreateTable,\n} from '../core/ddl/nodes';\n\n/**\n * Build a Postgres `CREATE TABLE` query node.\n *\n * Pass `constraints` for table-level composite primary keys, foreign keys, and\n * unique constraints — use the {@link PrimaryKeyConstraint}, {@link ForeignKeyConstraint},\n * and {@link UniqueConstraint} classes from `@prisma-next/sql-relational-core/ast`.\n *\n * Precondition: identifiers (`table`, `schema`, column names/types) are\n * emitted to SQL verbatim — they are not quoted or escaped, so callers must\n * pass pre-trusted values (e.g. fixed control-plane identifiers). String-literal\n * default values, by contrast, are single-quote-escaped (embedded `'` doubled)\n * by the renderer. Identifier quoting for untrusted identifiers is added when\n * the migration planner adopts this lowering path.\n */\nexport function createTable(options: {\n readonly table: string;\n readonly schema?: string;\n readonly ifNotExists?: boolean;\n readonly columns: readonly DdlColumn[];\n readonly constraints?: readonly DdlTableConstraint[];\n}): PostgresCreateTable {\n return new PostgresCreateTable(options);\n}\n\n/**\n * Build a Postgres `CREATE SCHEMA` query node. See {@link createTable} for the\n * pre-trusted-identifier precondition.\n */\nexport function createSchema(options: {\n readonly schema: string;\n readonly ifNotExists?: boolean;\n}): PostgresCreateSchema {\n return new PostgresCreateSchema(options);\n}\n\n/**\n * Build an `ADD COLUMN` action for use inside {@link alterTable}.\n * The column is a structured `DdlColumn` so codec-encoded defaults flow\n * through the adapter's `pgRenderDdlColumn` → `pgRenderDdlColumnDefault` path.\n */\nexport function addColumnAction(column: DdlColumn): AddColumnAction {\n return new AddColumnAction(column);\n}\n\n/**\n * Build a Postgres `ALTER TABLE` query node carrying one or more actions.\n * See {@link addColumnAction} for building actions.\n */\nexport function alterTable(options: {\n readonly table: string;\n readonly schema?: string;\n readonly actions: readonly AnyAlterTableAction[];\n}): PostgresAlterTable {\n return new PostgresAlterTable(options);\n}\n"],"mappings":";;;;;;;;;;AAiBA,SAAgB,WAAW,eAA+B;CACxD,OAAO,OAAO,GAAG;EACf,QAAQ;EACR,UAAU;EACV,MAAM,OAAO,MAAM,eAAe,gBAAgB;EAClD,SAAS;GAAE,SAAS;GAAkB,UAAU;EAAK;CACvD,CAAC;AACH;;;;;;;;;;AAgBA,SAAgB,eAAe,QAAgB,OAAwC;CAIrF,MAAM,WAAW,WAHC,wBAAwB;EAAE,IAAI;EAAQ,SAAS,EAAE,OAAO,CAAC,EAAE;CAAE,CAAC,CAAC,CAAC,aAChF,KAEkC,CAAC;CACrC,OAAO;EACL,mBAAmB,WAAW,CAAC,CAAC,QAAQ,UAAU,SAAS,OAAO,CAAC,CAAC,CAAC,MAAM;EAC3E,oBAAoB,WAAW,CAAC,CAAC,QAAQ,UAAU,SAAS,UAAU,CAAC,CAAC,CAAC,MAAM;CACjF;AACF;;;;;;;;;;;;;;;AAqBA,SAAgB,oBAAoB,SAIH;CAC/B,MAAM,YAAY,wBAAwB;EAAE,IAAI,QAAQ;EAAQ,SAAS,EAAE,OAAO,CAAC,EAAE;CAAE,CAAC;CACxF,MAAM,aAAa,CACjB,OAAO,UAAU,KAAK,SAAS,CAAC,CAAC,QAAQ,QAAQ,gBAAgB,gBAAgB,GACjF,OAAO,UAAU,KAAK,SAAS,CAAC,CAAC,OAAO,UAAU,uBAAuB,CAAC,CAC5E;CACA,IAAI,QAAQ,UAAU,KAAA,GACpB,WAAW,KACT,OAAO,UAAU,KAAK,UAAU,CAAC,CAAC,OAAO,WAAW,UAAU,aAAa,QAAQ,KAAK,CAAC,CAAC,CAC5F;CAEF,MAAM,cACJ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PostgresDdlNode, PostgresCreateSchema, PostgresCreateTable, PostgresDdlNode, type PostgresDdlVisitor };
|
|
1
|
+
import { a as PostgresAlterTable, c as PostgresDdlNode, i as AnyPostgresDdlNode, l as PostgresDdlVisitor, n as AlterTableActionVisitor, o as PostgresCreateSchema, r as AnyAlterTableAction, s as PostgresCreateTable, t as AddColumnAction } from "./nodes-pLeLgdis.mjs";
|
|
2
|
+
export { AddColumnAction, type AlterTableActionVisitor, type AnyAlterTableAction, type AnyPostgresDdlNode, PostgresAlterTable, PostgresCreateSchema, PostgresCreateTable, PostgresDdlNode, type PostgresDdlVisitor };
|
package/dist/ddl.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { PostgresCreateSchema, PostgresCreateTable, PostgresDdlNode };
|
|
1
|
+
import { a as PostgresDdlNode, i as PostgresCreateTable, n as PostgresAlterTable, r as PostgresCreateSchema, t as AddColumnAction } from "./nodes-Bbhs2rwj.mjs";
|
|
2
|
+
export { AddColumnAction, PostgresAlterTable, PostgresCreateSchema, PostgresCreateTable, PostgresDdlNode };
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { temporalAuthoringPresets } from "@prisma-next/family-sql/control";
|
|
2
|
+
//#region src/core/authoring.ts
|
|
3
|
+
const postgresAuthoringTypes = {};
|
|
4
|
+
const postgresAuthoringEntityTypes = {};
|
|
5
|
+
/**
|
|
6
|
+
* Field presets contributed by the Postgres target pack.
|
|
7
|
+
*
|
|
8
|
+
* These mirror the PSL scalar-to-codec mapping used by the Postgres adapter
|
|
9
|
+
* (see `createPostgresPslScalarTypeDescriptors`), so that authoring a field
|
|
10
|
+
* via the TS callback surface (e.g. `field.int()`) and via the PSL scalar
|
|
11
|
+
* surface (e.g. `Int`) lowers to byte-identical contracts.
|
|
12
|
+
*
|
|
13
|
+
* The `uuidNative` / `id.uuidv4Native` / `id.uuidv7Native` presets use the
|
|
14
|
+
* native Postgres `uuid` type (codecId `pg/uuid@1`). For cross-target
|
|
15
|
+
* portability use `uuidString` / `id.uuidv4String` / `id.uuidv7String` from
|
|
16
|
+
* the family pack instead.
|
|
17
|
+
*/
|
|
18
|
+
const postgresAuthoringFieldPresets = {
|
|
19
|
+
text: {
|
|
20
|
+
kind: "fieldPreset",
|
|
21
|
+
output: {
|
|
22
|
+
codecId: "pg/text@1",
|
|
23
|
+
nativeType: "text"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
int: {
|
|
27
|
+
kind: "fieldPreset",
|
|
28
|
+
output: {
|
|
29
|
+
codecId: "pg/int4@1",
|
|
30
|
+
nativeType: "int4"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
bigint: {
|
|
34
|
+
kind: "fieldPreset",
|
|
35
|
+
output: {
|
|
36
|
+
codecId: "pg/int8@1",
|
|
37
|
+
nativeType: "int8"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
float: {
|
|
41
|
+
kind: "fieldPreset",
|
|
42
|
+
output: {
|
|
43
|
+
codecId: "pg/float8@1",
|
|
44
|
+
nativeType: "float8"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
decimal: {
|
|
48
|
+
kind: "fieldPreset",
|
|
49
|
+
output: {
|
|
50
|
+
codecId: "pg/numeric@1",
|
|
51
|
+
nativeType: "numeric"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
boolean: {
|
|
55
|
+
kind: "fieldPreset",
|
|
56
|
+
output: {
|
|
57
|
+
codecId: "pg/bool@1",
|
|
58
|
+
nativeType: "bool"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
json: {
|
|
62
|
+
kind: "fieldPreset",
|
|
63
|
+
output: {
|
|
64
|
+
codecId: "pg/jsonb@1",
|
|
65
|
+
nativeType: "jsonb"
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
bytes: {
|
|
69
|
+
kind: "fieldPreset",
|
|
70
|
+
output: {
|
|
71
|
+
codecId: "pg/bytea@1",
|
|
72
|
+
nativeType: "bytea"
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
dateTime: {
|
|
76
|
+
kind: "fieldPreset",
|
|
77
|
+
output: {
|
|
78
|
+
codecId: "pg/timestamptz@1",
|
|
79
|
+
nativeType: "timestamptz"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
temporal: /* @__PURE__ */ temporalAuthoringPresets({
|
|
83
|
+
codecId: "pg/timestamptz@1",
|
|
84
|
+
nativeType: "timestamptz"
|
|
85
|
+
}),
|
|
86
|
+
uuidNative: {
|
|
87
|
+
kind: "fieldPreset",
|
|
88
|
+
output: {
|
|
89
|
+
codecId: "pg/uuid@1",
|
|
90
|
+
nativeType: "uuid"
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
id: {
|
|
94
|
+
uuidv4Native: {
|
|
95
|
+
kind: "fieldPreset",
|
|
96
|
+
output: {
|
|
97
|
+
codecId: "pg/uuid@1",
|
|
98
|
+
nativeType: "uuid",
|
|
99
|
+
executionDefaults: { onCreate: {
|
|
100
|
+
kind: "generator",
|
|
101
|
+
id: "uuidv4"
|
|
102
|
+
} },
|
|
103
|
+
id: true
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
uuidv7Native: {
|
|
107
|
+
kind: "fieldPreset",
|
|
108
|
+
output: {
|
|
109
|
+
codecId: "pg/uuid@1",
|
|
110
|
+
nativeType: "uuid",
|
|
111
|
+
executionDefaults: { onCreate: {
|
|
112
|
+
kind: "generator",
|
|
113
|
+
id: "uuidv7"
|
|
114
|
+
} },
|
|
115
|
+
id: true
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
const postgresTargetDescriptorMetaRuntime = {
|
|
121
|
+
kind: "target",
|
|
122
|
+
familyId: "sql",
|
|
123
|
+
targetId: "postgres",
|
|
124
|
+
id: "postgres",
|
|
125
|
+
version: "0.0.1",
|
|
126
|
+
capabilities: {}
|
|
127
|
+
};
|
|
128
|
+
const postgresTargetDescriptorMeta = {
|
|
129
|
+
...postgresTargetDescriptorMetaRuntime,
|
|
130
|
+
defaultNamespaceId: "public",
|
|
131
|
+
authoring: {
|
|
132
|
+
type: postgresAuthoringTypes,
|
|
133
|
+
field: postgresAuthoringFieldPresets,
|
|
134
|
+
entityTypes: postgresAuthoringEntityTypes
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
//#endregion
|
|
138
|
+
export { postgresTargetDescriptorMetaRuntime as n, postgresAuthoringEntityTypes as r, postgresTargetDescriptorMeta as t };
|
|
139
|
+
|
|
140
|
+
//# sourceMappingURL=descriptor-meta-CpGygXpI.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptor-meta-CpGygXpI.mjs","names":[],"sources":["../src/core/authoring.ts","../src/core/descriptor-meta-runtime.ts","../src/core/descriptor-meta.ts"],"sourcesContent":["import { temporalAuthoringPresets } from '@prisma-next/family-sql/control';\nimport type {\n AuthoringEntityTypeNamespace,\n AuthoringFieldNamespace,\n AuthoringTypeNamespace,\n} from '@prisma-next/framework-components/authoring';\n\nexport const postgresAuthoringTypes = {} as const satisfies AuthoringTypeNamespace;\n\nexport const postgresAuthoringEntityTypes = {} as const satisfies AuthoringEntityTypeNamespace;\n\n/**\n * Field presets contributed by the Postgres target pack.\n *\n * These mirror the PSL scalar-to-codec mapping used by the Postgres adapter\n * (see `createPostgresPslScalarTypeDescriptors`), so that authoring a field\n * via the TS callback surface (e.g. `field.int()`) and via the PSL scalar\n * surface (e.g. `Int`) lowers to byte-identical contracts.\n *\n * The `uuidNative` / `id.uuidv4Native` / `id.uuidv7Native` presets use the\n * native Postgres `uuid` type (codecId `pg/uuid@1`). For cross-target\n * portability use `uuidString` / `id.uuidv4String` / `id.uuidv7String` from\n * the family pack instead.\n */\nexport const postgresAuthoringFieldPresets = {\n text: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/text@1',\n nativeType: 'text',\n },\n },\n int: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/int4@1',\n nativeType: 'int4',\n },\n },\n bigint: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/int8@1',\n nativeType: 'int8',\n },\n },\n float: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/float8@1',\n nativeType: 'float8',\n },\n },\n decimal: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/numeric@1',\n nativeType: 'numeric',\n },\n },\n boolean: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/bool@1',\n nativeType: 'bool',\n },\n },\n json: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/jsonb@1',\n nativeType: 'jsonb',\n },\n },\n bytes: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/bytea@1',\n nativeType: 'bytea',\n },\n },\n dateTime: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/timestamptz@1',\n nativeType: 'timestamptz',\n },\n },\n temporal: /* @__PURE__ */ temporalAuthoringPresets({\n codecId: 'pg/timestamptz@1',\n nativeType: 'timestamptz',\n }),\n uuidNative: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/uuid@1',\n nativeType: 'uuid',\n },\n },\n id: {\n uuidv4Native: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/uuid@1',\n nativeType: 'uuid',\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'uuidv4',\n },\n },\n id: true,\n },\n },\n uuidv7Native: {\n kind: 'fieldPreset',\n output: {\n codecId: 'pg/uuid@1',\n nativeType: 'uuid',\n executionDefaults: {\n onCreate: {\n kind: 'generator',\n id: 'uuidv7',\n },\n },\n id: true,\n },\n },\n },\n} as const satisfies AuthoringFieldNamespace;\n","// Runtime-safe slice of the postgres target descriptor metadata.\n//\n// This file exists separately from ./descriptor-meta on purpose: the runtime\n// plane reads only `kind/familyId/targetId/id/version/capabilities` (plus the\n// `__codecTypes` phantom). The `authoring` slot lives on the pack/control\n// descriptor only, because authoring contributions are consumed at\n// contract-construction time by `assembleAuthoringContributions` (control\n// plane) and the PSL interpreter — never at runtime.\n//\n// Keeping the runtime closure free of the `./authoring` import is what lets\n// the bundler tree-shake `@prisma-next/family-sql/control` (and its\n// transitive `verify-sql-schema` chunk) out of the runtime entry. Do not\n// add an `authoring` field here — if you need to, the pack/control meta in\n// `./descriptor-meta` is the right place. See TML-2766 for context.\nimport type { CodecTypes } from '../exports/codec-types';\n\nconst postgresTargetDescriptorMetaRuntimeBase = {\n kind: 'target',\n familyId: 'sql',\n targetId: 'postgres',\n id: 'postgres',\n version: '0.0.1',\n capabilities: {},\n} as const;\n\nexport const postgresTargetDescriptorMetaRuntime: typeof postgresTargetDescriptorMetaRuntimeBase & {\n readonly __codecTypes?: CodecTypes;\n} = postgresTargetDescriptorMetaRuntimeBase;\n","import type { CodecTypes } from '../exports/codec-types';\nimport {\n postgresAuthoringEntityTypes,\n postgresAuthoringFieldPresets,\n postgresAuthoringTypes,\n} from './authoring';\nimport { postgresTargetDescriptorMetaRuntime } from './descriptor-meta-runtime';\n\nconst postgresTargetDescriptorMetaBase = {\n ...postgresTargetDescriptorMetaRuntime,\n defaultNamespaceId: 'public',\n authoring: {\n type: postgresAuthoringTypes,\n field: postgresAuthoringFieldPresets,\n entityTypes: postgresAuthoringEntityTypes,\n },\n} as const;\n\nexport const postgresTargetDescriptorMeta: typeof postgresTargetDescriptorMetaBase & {\n readonly __codecTypes?: CodecTypes;\n} = postgresTargetDescriptorMetaBase;\n"],"mappings":";;AAOA,MAAa,yBAAyB,CAAC;AAEvC,MAAa,+BAA+B,CAAC;;;;;;;;;;;;;;AAe7C,MAAa,gCAAgC;CAC3C,MAAM;EACJ,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;EACd;CACF;CACA,KAAK;EACH,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;EACd;CACF;CACA,QAAQ;EACN,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;EACd;CACF;CACA,OAAO;EACL,MAAM;E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