@prisma-next/target-postgres 0.13.0-dev.35 → 0.13.0-dev.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/contract-free.d.mts +147 -14
- package/dist/contract-free.d.mts.map +1 -1
- package/dist/contract-free.mjs +3 -16
- package/dist/contract-free.mjs.map +1 -1
- package/dist/control.mjs +2 -2
- package/dist/ddl-QDyOSeLc.mjs +251 -0
- package/dist/ddl-QDyOSeLc.mjs.map +1 -0
- package/dist/{issue-planner-9AVUEL74.mjs → issue-planner-CoI_0uM1.mjs} +8 -118
- package/dist/issue-planner-CoI_0uM1.mjs.map +1 -0
- package/dist/issue-planner.d.mts +1 -1
- package/dist/issue-planner.d.mts.map +1 -1
- package/dist/issue-planner.mjs +1 -1
- package/dist/migration.d.mts +4 -80
- package/dist/migration.d.mts.map +1 -1
- package/dist/migration.mjs +3 -3
- package/dist/{op-factory-call-CvDOetGa.mjs → op-factory-call-B1bXWtfa.mjs} +551 -241
- package/dist/op-factory-call-B1bXWtfa.mjs.map +1 -0
- package/dist/{op-factory-call-CdtMyrlU.d.mts → op-factory-call-DmQEc3XV.d.mts} +111 -20
- package/dist/op-factory-call-DmQEc3XV.d.mts.map +1 -0
- package/dist/op-factory-call.d.mts +1 -1
- package/dist/op-factory-call.mjs +1 -1
- package/dist/{planner-BZxjjT8T.mjs → planner-DS5XBhmi.mjs} +4 -4
- package/dist/{planner-BZxjjT8T.mjs.map → planner-DS5XBhmi.mjs.map} +1 -1
- package/dist/{planner-produced-postgres-migration-CkECqqTy.mjs → planner-produced-postgres-migration-DTwCCek_.mjs} +2 -2
- package/dist/{planner-produced-postgres-migration-CkECqqTy.mjs.map → planner-produced-postgres-migration-DTwCCek_.mjs.map} +1 -1
- package/dist/{planner-produced-postgres-migration-wLhnJMMA.d.mts → planner-produced-postgres-migration-QqHa2C2l.d.mts} +2 -2
- package/dist/{planner-produced-postgres-migration-wLhnJMMA.d.mts.map → planner-produced-postgres-migration-QqHa2C2l.d.mts.map} +1 -1
- 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 +1 -47
- package/dist/planner-sql-checks.d.mts.map +1 -1
- package/dist/planner-sql-checks.mjs +2 -2
- package/dist/planner.d.mts +1 -1
- package/dist/planner.mjs +1 -1
- package/dist/{postgres-contract-serializer-sdg1B6Og.mjs → postgres-contract-serializer-E92REOFk.mjs} +2 -2
- package/dist/{postgres-contract-serializer-sdg1B6Og.mjs.map → postgres-contract-serializer-E92REOFk.mjs.map} +1 -1
- package/dist/postgres-migration-Y4YBJqkS.d.mts +181 -0
- package/dist/postgres-migration-Y4YBJqkS.d.mts.map +1 -0
- package/dist/postgres-migration-otiaw3Ru.mjs +145 -0
- package/dist/postgres-migration-otiaw3Ru.mjs.map +1 -0
- package/dist/{postgres-schema-CDaLWZwd.mjs → postgres-schema-COGZ1ark.mjs} +61 -8
- package/dist/postgres-schema-COGZ1ark.mjs.map +1 -0
- package/dist/runtime.mjs +1 -1
- package/dist/table-source-BvFo7gVs.d.mts +15 -0
- package/dist/table-source-BvFo7gVs.d.mts.map +1 -0
- package/dist/types.d.mts +26 -6
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +1 -1
- package/package.json +17 -17
- package/src/contract-free/checks.ts +363 -0
- package/src/core/migrations/op-factory-call.ts +417 -94
- package/src/core/migrations/operations/columns.ts +175 -140
- package/src/core/migrations/operations/constraints.ts +79 -108
- 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-recipes.ts +42 -33
- package/src/core/migrations/planner-sql-checks.ts +1 -172
- package/src/core/migrations/planner-strategies.ts +25 -73
- package/src/core/migrations/postgres-migration.ts +272 -7
- package/src/core/postgres-schema.ts +47 -6
- package/src/exports/contract-free.ts +21 -0
- package/src/exports/migration.ts +1 -22
- package/src/exports/planner-sql-checks.ts +0 -7
- package/dist/ddl-DY2R_Yqz.mjs +0 -45
- package/dist/ddl-DY2R_Yqz.mjs.map +0 -1
- package/dist/issue-planner-9AVUEL74.mjs.map +0 -1
- package/dist/op-factory-call-CdtMyrlU.d.mts.map +0 -1
- package/dist/op-factory-call-CvDOetGa.mjs.map +0 -1
- package/dist/planner-sql-checks-Bj4G0_gO.mjs +0 -272
- package/dist/planner-sql-checks-Bj4G0_gO.mjs.map +0 -1
- package/dist/postgres-migration-DLXL0GBf.d.mts +0 -77
- package/dist/postgres-migration-DLXL0GBf.d.mts.map +0 -1
- package/dist/postgres-migration-DMnWjdni.mjs +0 -75
- package/dist/postgres-migration-DMnWjdni.mjs.map +0 -1
- package/dist/postgres-schema-CDaLWZwd.mjs.map +0 -1
- package/dist/shared-jcsbXxiW.d.mts +0 -25
- package/dist/shared-jcsbXxiW.d.mts.map +0 -1
package/dist/contract-free.d.mts
CHANGED
|
@@ -1,7 +1,151 @@
|
|
|
1
1
|
import { a as PostgresAlterTable, o as PostgresCreateSchema, r as AnyAlterTableAction, s as PostgresCreateTable, t as AddColumnAction } from "./nodes-pLeLgdis.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { t as PostgresTableSource } from "./table-source-BvFo7gVs.mjs";
|
|
3
|
+
import { DdlColumn, DdlNode, DdlTableConstraint, SelectAst } from "@prisma-next/sql-relational-core/ast";
|
|
4
|
+
import { CfExpr, ColumnDescriptor, ColumnSchema, TableHandle } from "@prisma-next/sql-relational-core/contract-free";
|
|
4
5
|
|
|
6
|
+
//#region src/contract-free/checks.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* `to_regclass($1)` with the qualified table name bound as a text parameter.
|
|
9
|
+
* Thin vocabulary wrapper over the core `cfExpr.fn` helper — the target
|
|
10
|
+
* supplies only the template and the codec'd operand.
|
|
11
|
+
*/
|
|
12
|
+
declare function toRegclass(qualifiedName: string): CfExpr;
|
|
13
|
+
interface TableExistsCheckBuilder {
|
|
14
|
+
tableAbsent(): SelectAst;
|
|
15
|
+
tablePresent(): SelectAst;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Typed builder for the migration planner's table-existence checks. Produces
|
|
19
|
+
* FROM-less `SELECT to_regclass($1) IS [NOT] NULL AS "result"` ASTs with the
|
|
20
|
+
* qualified table name bound as a text parameter — never inlined into the SQL.
|
|
21
|
+
*
|
|
22
|
+
* `schema` is a namespace coordinate: the framework `__unbound__` sentinel
|
|
23
|
+
* elides the qualifier (search_path decides at runtime); any other id
|
|
24
|
+
* qualifies as `"schema"."table"`.
|
|
25
|
+
*/
|
|
26
|
+
declare function tableExistsAst(schema: string, table: string): TableExistsCheckBuilder;
|
|
27
|
+
interface ConstraintExistsCheckBuilder {
|
|
28
|
+
constraintPresent(): SelectAst;
|
|
29
|
+
constraintAbsent(): SelectAst;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Typed builder for the migration planner's constraint-existence checks.
|
|
33
|
+
* Produces `SELECT [NOT ]EXISTS (SELECT 1 FROM pg_constraint c JOIN
|
|
34
|
+
* pg_namespace n ON n.oid = c.connamespace WHERE c.conname = $1 AND
|
|
35
|
+
* n.nspname = $2 [AND c.conrelid = to_regclass($3)]) AS "result"` with the
|
|
36
|
+
* constraint name, schema name, and qualified table name bound as text
|
|
37
|
+
* parameters.
|
|
38
|
+
*
|
|
39
|
+
* When `table` is omitted the check matches by name + schema across all
|
|
40
|
+
* tables. Pass `table` to scope the check to a single table (prevents false
|
|
41
|
+
* matches on identically-named constraints in different tables). `schema`
|
|
42
|
+
* is a namespace coordinate: the `__unbound__` sentinel compares `nspname`
|
|
43
|
+
* against `current_schema()` instead of a bound parameter.
|
|
44
|
+
*/
|
|
45
|
+
declare function constraintExistsAst(options: {
|
|
46
|
+
readonly constraintName: string;
|
|
47
|
+
readonly schema: string;
|
|
48
|
+
readonly table?: string;
|
|
49
|
+
}): ConstraintExistsCheckBuilder;
|
|
50
|
+
interface ColumnExistsCheckBuilder {
|
|
51
|
+
columnPresent(): SelectAst;
|
|
52
|
+
columnAbsent(): SelectAst;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Typed builder for column-existence checks over
|
|
56
|
+
* `information_schema.columns`, with schema, table, and column names bound
|
|
57
|
+
* as text parameters.
|
|
58
|
+
*/
|
|
59
|
+
declare function columnExistsAst(options: {
|
|
60
|
+
readonly schema: string;
|
|
61
|
+
readonly table: string;
|
|
62
|
+
readonly column: string;
|
|
63
|
+
}): ColumnExistsCheckBuilder;
|
|
64
|
+
/**
|
|
65
|
+
* Typed nullability check: EXISTS over `information_schema.columns` with
|
|
66
|
+
* `is_nullable` compared against the bound `'YES'` / `'NO'` marker.
|
|
67
|
+
*/
|
|
68
|
+
declare function columnNullabilityAst(options: {
|
|
69
|
+
readonly schema: string;
|
|
70
|
+
readonly table: string;
|
|
71
|
+
readonly column: string;
|
|
72
|
+
readonly nullable: boolean;
|
|
73
|
+
}): SelectAst;
|
|
74
|
+
interface ColumnDefaultCheckBuilder {
|
|
75
|
+
defaultPresent(): SelectAst;
|
|
76
|
+
defaultAbsent(): SelectAst;
|
|
77
|
+
noDefault(): SelectAst;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Typed default-presence checks over `information_schema.columns`.
|
|
81
|
+
* `defaultPresent` / `defaultAbsent` assert the column row exists with a
|
|
82
|
+
* non-null / null `column_default`; `noDefault` is the NOT EXISTS variant
|
|
83
|
+
* (also true when the column row is missing entirely).
|
|
84
|
+
*/
|
|
85
|
+
declare function columnDefaultAst(options: {
|
|
86
|
+
readonly schema: string;
|
|
87
|
+
readonly table: string;
|
|
88
|
+
readonly column: string;
|
|
89
|
+
}): ColumnDefaultCheckBuilder;
|
|
90
|
+
/**
|
|
91
|
+
* Typed column-type check: EXISTS over `pg_attribute` joined to `pg_class`
|
|
92
|
+
* and `pg_namespace`, comparing `format_type(a.atttypid, a.atttypmod)`
|
|
93
|
+
* against the bound expected display type and excluding dropped columns.
|
|
94
|
+
*/
|
|
95
|
+
declare function columnTypeAst(options: {
|
|
96
|
+
readonly schema: string;
|
|
97
|
+
readonly table: string;
|
|
98
|
+
readonly column: string;
|
|
99
|
+
readonly expectedType: string;
|
|
100
|
+
}): SelectAst;
|
|
101
|
+
interface TablePrimaryKeyCheckBuilder {
|
|
102
|
+
pkPresent(): SelectAst;
|
|
103
|
+
pkAbsent(): SelectAst;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Typed primary-key existence check over `pg_index` joined to `pg_class`
|
|
107
|
+
* and `pg_namespace`, with a LEFT JOIN on the index relation so an
|
|
108
|
+
* optional `constraintName` can scope the match to a named constraint.
|
|
109
|
+
*/
|
|
110
|
+
declare function tablePrimaryKeyAst(options: {
|
|
111
|
+
readonly schema: string;
|
|
112
|
+
readonly table: string;
|
|
113
|
+
readonly constraintName?: string;
|
|
114
|
+
}): TablePrimaryKeyCheckBuilder;
|
|
115
|
+
/**
|
|
116
|
+
* Typed emptiness check: NOT EXISTS over the user table itself with
|
|
117
|
+
* `LIMIT 1`. The table is addressed through the namespace's polymorphic
|
|
118
|
+
* `tableSource` (qualified for named schemas, bare for the unbound slot).
|
|
119
|
+
*/
|
|
120
|
+
declare function tableIsEmptyAst(schema: string, table: string): SelectAst;
|
|
121
|
+
/**
|
|
122
|
+
* Typed no-NULL-values data check used by `SET NOT NULL` prechecks:
|
|
123
|
+
* NOT EXISTS over the user table where the column IS NULL.
|
|
124
|
+
*/
|
|
125
|
+
declare function noNullValuesAst(options: {
|
|
126
|
+
readonly schema: string;
|
|
127
|
+
readonly table: string;
|
|
128
|
+
readonly column: string;
|
|
129
|
+
}): SelectAst;
|
|
130
|
+
interface ExtensionExistsCheckBuilder {
|
|
131
|
+
extensionPresent(): SelectAst;
|
|
132
|
+
extensionAbsent(): SelectAst;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Typed extension existence check over `pg_extension`, with the extension
|
|
136
|
+
* name bound as a text parameter.
|
|
137
|
+
*/
|
|
138
|
+
declare function extensionExistsAst(extensionName: string): ExtensionExistsCheckBuilder;
|
|
139
|
+
interface IndexExistsCheckBuilder {
|
|
140
|
+
indexPresent(): SelectAst;
|
|
141
|
+
indexAbsent(): SelectAst;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Typed index existence check riding the same `to_regclass` vocabulary as
|
|
145
|
+
* `tableExistsAst`, with the qualified index name bound as a text parameter.
|
|
146
|
+
*/
|
|
147
|
+
declare function indexExistsAst(schema: string, indexName: string): IndexExistsCheckBuilder;
|
|
148
|
+
//#endregion
|
|
5
149
|
//#region src/contract-free/columns.d.ts
|
|
6
150
|
type ColOpts = {
|
|
7
151
|
readonly nullable?: boolean;
|
|
@@ -80,16 +224,5 @@ declare function alterTable(options: {
|
|
|
80
224
|
readonly actions: readonly AnyAlterTableAction[];
|
|
81
225
|
}): PostgresAlterTable;
|
|
82
226
|
//#endregion
|
|
83
|
-
|
|
84
|
-
declare class PostgresTableSource extends TableSource {
|
|
85
|
-
readonly schema: string | undefined;
|
|
86
|
-
constructor(options: {
|
|
87
|
-
readonly name: string;
|
|
88
|
-
readonly schema?: string;
|
|
89
|
-
readonly alias?: string;
|
|
90
|
-
});
|
|
91
|
-
rewrite(rewriter: AstRewriter): AnyFromSource;
|
|
92
|
-
}
|
|
93
|
-
//#endregion
|
|
94
|
-
export { PostgresTableSource, addColumnAction, alterTable, buildControlTableBootstrapQueries, buildSignMarkerBootstrapQueries, createSchema, createTable, int4, int8, jsonb, pgTable, text, textArray, timestamptz };
|
|
227
|
+
export { type ColumnDefaultCheckBuilder, type ColumnExistsCheckBuilder, type ConstraintExistsCheckBuilder, type ExtensionExistsCheckBuilder, type IndexExistsCheckBuilder, PostgresTableSource, type TableExistsCheckBuilder, type TablePrimaryKeyCheckBuilder, addColumnAction, alterTable, buildControlTableBootstrapQueries, buildSignMarkerBootstrapQueries, columnDefaultAst, columnExistsAst, columnNullabilityAst, columnTypeAst, constraintExistsAst, createSchema, createTable, extensionExistsAst, indexExistsAst, int4, int8, jsonb, noNullValuesAst, pgTable, tableExistsAst, tableIsEmptyAst, tablePrimaryKeyAst, text, textArray, timestamptz, toRegclass };
|
|
95
228
|
//# sourceMappingURL=contract-free.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract-free.d.mts","names":[],"sources":["../src/contract-free/
|
|
1
|
+
{"version":3,"file":"contract-free.d.mts","names":[],"sources":["../src/contract-free/checks.ts","../src/contract-free/columns.ts","../src/contract-free/control-bootstrap.ts","../src/contract-free/ddl.ts"],"mappings":";;;;;;;;;;AAiBA;iBAAgB,UAAA,CAAW,aAAA,WAAwB,MAAM;AAAA,UASxC,uBAAA;EACf,WAAA,IAAe,SAAA;EACf,YAAA,IAAgB,SAAS;AAAA;;;;;;;;;AAAA;iBAYX,cAAA,CAAe,MAAA,UAAgB,KAAA,WAAgB,uBAAuB;AAAA,UAWrE,4BAAA;EACf,iBAAA,IAAqB,SAAA;EACrB,gBAAA,IAAoB,SAAS;AAAA;;;;AAbuD;AAWtF;;;;;;;;;AAE+B;iBAiBf,mBAAA,CAAoB,OAAA;EAAA,SACzB,cAAA;EAAA,SACA,MAAA;EAAA,SACA,KAAA;AAAA,IACP,4BAA4B;AAAA,UAuDf,wBAAA;EACf,aAAA,IAAiB,SAAA;EACjB,YAAA,IAAgB,SAAS;AAAA;;AAzDK;AAuDhC;;;iBAUgB,eAAA,CAAgB,OAAA;EAAA,SACrB,MAAA;EAAA,SACA,KAAA;EAAA,SACA,MAAA;AAAA,IACP,wBAAwB;;AAZD;AAQ3B;;iBAgBgB,oBAAA,CAAqB,OAAA;EAAA,SAC1B,MAAA;EAAA,SACA,KAAA;EAAA,SACA,MAAA;EAAA,SACA,QAAA;AAAA,IAC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AU,gBAAiD;AAAA,cAC3E,SAAA,GAAa,IAAA,GAAO,OAAA,KAAU,gBAAsD;AAAA,cACpF,WAAA,GAAe,IAAA,GAAO,OAAA,KAAU,gBACR;ADZoB;AASzD;;;;;;;;;AAE2B;AAY3B;AAvByD,iBC0BzC,OAAA,gBAAuB,YAAA,EACrC,MAAA;EAAA,SAAmB,IAAA;EAAA,SAAuB,MAAA;EAAA,SAA0B,KAAA;AAAA,GACpE,OAAA,EAAS,MAAA,GACR,WAAA,CAAY,MAAA;;;iBCEC,+BAAA,aAA4C,OAAO;AAAA,iBAInD,iCAAA,aAA8C,OAAO;;;;;;;AFnCrE;;;;AAAyD;AASzD;;;;;iBGHgB,WAAA,CAAY,OAAA;EAAA,SACjB,KAAA;EAAA,SACA,MAAA;EAAA,SACA,WAAA;EAAA,SACA,OAAA,WAAkB,SAAA;EAAA,SAClB,WAAA,YAAuB,kBAAA;AAAA,IAC9B,mBAAA;;;;;iBAQY,YAAA,CAAa,OAAA;EAAA,SAClB,MAAA;EAAA,SACA,WAAA;AAAA,IACP,oBAAoB;;;;;;iBASR,eAAA,CAAgB,MAAA,EAAQ,SAAA,GAAY,eAAe;;;AHIpC;AAiB/B;iBGbgB,UAAA,CAAW,OAAA;EAAA,SAChB,KAAA;EAAA,SACA,MAAA;EAAA,SACA,OAAA,WAAkB,mBAAA;AAAA,IACzB,kBAAkB"}
|
package/dist/contract-free.mjs
CHANGED
|
@@ -1,21 +1,8 @@
|
|
|
1
1
|
import { _ as PG_TEXT_CODEC_ID, g as PG_TEXT_ARRAY_CODEC_ID, l as PG_INT4_CODEC_ID, p as PG_JSONB_CODEC_ID, u as PG_INT8_CODEC_ID, v as PG_TIMESTAMPTZ_CODEC_ID } from "./codec-ids-BvytN2P8.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { a as PostgresTableSource } from "./postgres-schema-COGZ1ark.mjs";
|
|
3
|
+
import { a as columnDefaultAst, c as columnTypeAst, d as indexExistsAst, f as noNullValuesAst, g as toRegclass, h as tablePrimaryKeyAst, i as createTable, l as constraintExistsAst, m as tableIsEmptyAst, n as alterTable, o as columnExistsAst, p as tableExistsAst, r as createSchema, s as columnNullabilityAst, t as addColumnAction, u as extensionExistsAst } from "./ddl-QDyOSeLc.mjs";
|
|
4
4
|
import { col, fn, lit, table } from "@prisma-next/sql-relational-core/contract-free";
|
|
5
5
|
import { APP_SPACE_ID } from "@prisma-next/framework-components/control";
|
|
6
|
-
//#region src/core/ast/table-source.ts
|
|
7
|
-
var PostgresTableSource = class extends TableSource {
|
|
8
|
-
schema;
|
|
9
|
-
constructor(options) {
|
|
10
|
-
super(options.name, options.alias);
|
|
11
|
-
this.schema = options.schema;
|
|
12
|
-
this.freeze();
|
|
13
|
-
}
|
|
14
|
-
rewrite(rewriter) {
|
|
15
|
-
return rewriter.tableSource ? rewriter.tableSource(this) : this;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
//#endregion
|
|
19
6
|
//#region src/contract-free/columns.ts
|
|
20
7
|
const desc = (codecId, opts) => ({
|
|
21
8
|
codecId,
|
|
@@ -112,6 +99,6 @@ function buildControlTableBootstrapQueries() {
|
|
|
112
99
|
];
|
|
113
100
|
}
|
|
114
101
|
//#endregion
|
|
115
|
-
export { PostgresTableSource, addColumnAction, alterTable, buildControlTableBootstrapQueries, buildSignMarkerBootstrapQueries, createSchema, createTable, int4, int8, jsonb, pgTable, text, textArray, timestamptz };
|
|
102
|
+
export { PostgresTableSource, addColumnAction, alterTable, buildControlTableBootstrapQueries, buildSignMarkerBootstrapQueries, columnDefaultAst, columnExistsAst, columnNullabilityAst, columnTypeAst, constraintExistsAst, createSchema, createTable, extensionExistsAst, indexExistsAst, int4, int8, jsonb, noNullValuesAst, pgTable, tableExistsAst, tableIsEmptyAst, tablePrimaryKeyAst, text, textArray, timestamptz, toRegclass };
|
|
116
103
|
|
|
117
104
|
//# sourceMappingURL=contract-free.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract-free.mjs","names":[],"sources":["../src/
|
|
1
|
+
{"version":3,"file":"contract-free.mjs","names":[],"sources":["../src/contract-free/columns.ts","../src/contract-free/control-bootstrap.ts"],"sourcesContent":["import {\n type ColumnDescriptor,\n type ColumnSchema,\n type TableHandle,\n table,\n} from '@prisma-next/sql-relational-core/contract-free';\nimport { PostgresTableSource } from '../core/ast/table-source';\nimport {\n PG_INT4_CODEC_ID,\n PG_INT8_CODEC_ID,\n PG_JSONB_CODEC_ID,\n PG_TEXT_ARRAY_CODEC_ID,\n PG_TEXT_CODEC_ID,\n PG_TIMESTAMPTZ_CODEC_ID,\n} from '../core/codec-ids';\n\ntype ColOpts = { readonly nullable?: boolean };\n\nconst desc = (codecId: string, opts?: ColOpts): ColumnDescriptor => ({\n codecId,\n nullable: opts?.nullable ?? false,\n});\n\nexport const text = (opts?: ColOpts): ColumnDescriptor => desc(PG_TEXT_CODEC_ID, opts);\nexport const int4 = (opts?: ColOpts): ColumnDescriptor => desc(PG_INT4_CODEC_ID, opts);\nexport const int8 = (opts?: ColOpts): ColumnDescriptor => desc(PG_INT8_CODEC_ID, opts);\nexport const jsonb = (opts?: ColOpts): ColumnDescriptor => desc(PG_JSONB_CODEC_ID, opts);\nexport const textArray = (opts?: ColOpts): ColumnDescriptor => desc(PG_TEXT_ARRAY_CODEC_ID, opts);\nexport const timestamptz = (opts?: ColOpts): ColumnDescriptor =>\n desc(PG_TIMESTAMPTZ_CODEC_ID, opts);\n\n/**\n * Declare a PostgreSQL control-plane table with a typed column schema. Wraps\n * the generic `table()` factory with a `PostgresTableSource` so the renderer\n * qualifies the table name with the optional schema prefix.\n *\n * ```ts\n * const marker = pgTable(\n * { name: 'marker', schema: 'prisma_contract' },\n * { space: text(), core_hash: text(), updated_at: timestamptz() },\n * );\n * ```\n */\nexport function pgTable<Schema extends ColumnSchema>(\n source: { readonly name: string; readonly schema?: string; readonly alias?: string },\n columns: Schema,\n): TableHandle<Schema> {\n return table(new PostgresTableSource(source), columns);\n}\n","import { APP_SPACE_ID } from '@prisma-next/framework-components/control';\nimport type { DdlNode } from '@prisma-next/sql-relational-core/ast';\nimport { col, fn, lit } from '@prisma-next/sql-relational-core/contract-free';\nimport { createSchema, createTable } from './ddl';\n\nconst markerColumns = [\n col('space', 'text', { notNull: true, primaryKey: true, default: lit(APP_SPACE_ID) }),\n col('core_hash', 'text', { notNull: true }),\n col('profile_hash', 'text', { notNull: true }),\n col('contract_json', 'jsonb'),\n col('canonical_version', 'int'),\n col('updated_at', 'timestamptz', { notNull: true, default: fn('now()') }),\n col('app_tag', 'text'),\n col('meta', 'jsonb', { notNull: true, default: lit('{}') }),\n col('invariants', 'text[]', { notNull: true, default: lit('{}') }),\n] as const;\n\nconst ledgerColumns = [\n col('id', 'bigserial', { primaryKey: true }),\n col('created_at', 'timestamptz', { notNull: true, default: fn('now()') }),\n col('space', 'text', { notNull: true }),\n col('migration_name', 'text', { notNull: true }),\n col('migration_hash', 'text', { notNull: true }),\n col('origin_core_hash', 'text'),\n col('origin_profile_hash', 'text'),\n col('destination_core_hash', 'text', { notNull: true }),\n col('destination_profile_hash', 'text'),\n col('contract_json_before', 'jsonb'),\n col('contract_json_after', 'jsonb'),\n col('operations', 'jsonb', { notNull: true }),\n] as const;\n\nconst markerTable = createTable({\n schema: 'prisma_contract',\n table: 'marker',\n ifNotExists: true,\n columns: markerColumns,\n});\n\nconst ledgerTable = createTable({\n schema: 'prisma_contract',\n table: 'ledger',\n ifNotExists: true,\n columns: ledgerColumns,\n});\n\nconst controlSchema = createSchema({ schema: 'prisma_contract', ifNotExists: true });\n\nexport function buildSignMarkerBootstrapQueries(): readonly DdlNode[] {\n return [controlSchema, markerTable];\n}\n\nexport function buildControlTableBootstrapQueries(): readonly DdlNode[] {\n return [controlSchema, markerTable, ledgerTable];\n}\n"],"mappings":";;;;;;AAkBA,MAAM,QAAQ,SAAiB,UAAsC;CACnE;CACA,UAAU,MAAM,YAAY;AAC9B;AAEA,MAAa,QAAQ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ACjC,IAAI,yBAAyB,QAAQ,EAAE,SAAS,KAAK,CAAC;CACtD,IAAI,4BAA4B,MAAM;CACtC,IAAI,wBAAwB,OAAO;CACnC,IAAI,uBAAuB,OAAO;CAClC,IAAI,cAAc,SAAS,EAAE,SAAS,KAAK,CAAC;AAC9C;AAEA,MAAM,cAAc,YAAY;CAC9B,QAAQ;CACR,OAAO;CACP,aAAa;CACb,SAAS;AACX,CAAC;AAED,MAAM,cAAc,YAAY;CAC9B,QAAQ;CACR,OAAO;CACP,aAAa;CACb,SAAS;AACX,CAAC;AAED,MAAM,gBAAgB,aAAa;CAAE,QAAQ;CAAmB,aAAa;AAAK,CAAC;AAEnF,SAAgB,kCAAsD;CACpE,OAAO,CAAC,eAAe,WAAW;AACpC;AAEA,SAAgB,oCAAwD;CACtE,OAAO;EAAC;EAAe;EAAa;CAAW;AACjD"}
|
package/dist/control.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as postgresTargetDescriptorMeta } from "./descriptor-meta-BKma_hQ5.mjs";
|
|
2
2
|
import { t as parsePostgresDefault } from "./default-normalizer-DyyCHQWs.mjs";
|
|
3
3
|
import { t as normalizeSchemaNativeType } from "./native-type-normalizer-Bc9XJzWC.mjs";
|
|
4
|
-
import { t as createPostgresMigrationPlanner } from "./planner-
|
|
4
|
+
import { t as createPostgresMigrationPlanner } from "./planner-DS5XBhmi.mjs";
|
|
5
5
|
import { a as renderDefaultLiteral } from "./planner-ddl-builders-B2wOwLqI.mjs";
|
|
6
|
-
import { t as PostgresContractSerializer } from "./postgres-contract-serializer-
|
|
6
|
+
import { t as PostgresContractSerializer } from "./postgres-contract-serializer-E92REOFk.mjs";
|
|
7
7
|
import { blindCast } from "@prisma-next/utils/casts";
|
|
8
8
|
import { contractToSchemaIR, extractCodecControlHooks, runnerFailure, runnerSuccess } from "@prisma-next/family-sql/control";
|
|
9
9
|
import { ifDefined } from "@prisma-next/utils/defined";
|
|
@@ -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,CA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