@prisma-next/target-postgres 0.12.0-dev.17 → 0.12.0-dev.3
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-BEVQ-gO4.d.mts → codec-ids-DliyCWPY.d.mts} +1 -1
- package/dist/{codec-ids-BEVQ-gO4.d.mts.map → codec-ids-DliyCWPY.d.mts.map} +1 -1
- package/dist/codec-ids.d.mts +1 -1
- package/dist/{codec-types-ClVgENiR.d.mts → codec-types-BF1DXTPs.d.mts} +2 -2
- package/dist/{codec-types-ClVgENiR.d.mts.map → codec-types-BF1DXTPs.d.mts.map} +1 -1
- package/dist/codec-types.d.mts +1 -1
- package/dist/{codecs-BHrYhAZc.d.mts → codecs-DuP3d9Au.d.mts} +2 -2
- package/dist/{codecs-BHrYhAZc.d.mts.map → codecs-DuP3d9Au.d.mts.map} +1 -1
- package/dist/codecs.d.mts +1 -1
- package/dist/control.d.mts +1 -1
- package/dist/control.mjs +25 -45
- package/dist/control.mjs.map +1 -1
- package/dist/{data-transform-C1ZpoMCt.d.mts → data-transform-CAPmAdxS.d.mts} +2 -2
- package/dist/{data-transform-C1ZpoMCt.d.mts.map → data-transform-CAPmAdxS.d.mts.map} +1 -1
- package/dist/{data-transform-4QL41_vQ.mjs → data-transform-CRkv2T_U.mjs} +1 -1
- package/dist/{data-transform-4QL41_vQ.mjs.map → data-transform-CRkv2T_U.mjs.map} +1 -1
- package/dist/data-transform.d.mts +1 -1
- package/dist/data-transform.mjs +1 -1
- package/dist/{default-normalizer-DFHtpCPH.mjs → default-normalizer-DaAhmzBV.mjs} +1 -1
- package/dist/{default-normalizer-DFHtpCPH.mjs.map → default-normalizer-DaAhmzBV.mjs.map} +1 -1
- package/dist/default-normalizer.mjs +1 -1
- package/dist/{descriptor-meta-BqATo5Dz.mjs → descriptor-meta-Uu8QaClr.mjs} +2 -3
- package/dist/descriptor-meta-Uu8QaClr.mjs.map +1 -0
- package/dist/{descriptor-meta-runtime-BBL7VdnR.mjs → descriptor-meta-runtime-DMRX39kp.mjs} +2 -2
- package/dist/{descriptor-meta-runtime-BBL7VdnR.mjs.map → descriptor-meta-runtime-DMRX39kp.mjs.map} +1 -1
- package/dist/{enum-planning-DHQE3zSH.mjs → enum-planning-DRA9LaMU.mjs} +0 -0
- package/dist/{enum-planning-DHQE3zSH.mjs.map → enum-planning-DRA9LaMU.mjs.map} +1 -1
- package/dist/enum-planning.d.mts +1 -1
- package/dist/enum-planning.mjs +1 -1
- package/dist/{errors-BhiZYTWZ.mjs → errors-BbnITmAD.mjs} +1 -1
- package/dist/{errors-BhiZYTWZ.mjs.map → errors-BbnITmAD.mjs.map} +1 -1
- package/dist/errors.mjs +1 -1
- package/dist/{issue-planner-D4YAegxk.mjs → issue-planner-BtaL6OfW.mjs} +10 -10
- package/dist/{issue-planner-D4YAegxk.mjs.map → issue-planner-BtaL6OfW.mjs.map} +1 -1
- package/dist/issue-planner.d.mts +1 -1
- package/dist/issue-planner.mjs +1 -1
- package/dist/migration.d.mts +3 -3
- package/dist/migration.mjs +3 -3
- package/dist/{native-type-normalizer-BUUe8USD.mjs → native-type-normalizer-BNEQ9VDs.mjs} +1 -1
- package/dist/{native-type-normalizer-BUUe8USD.mjs.map → native-type-normalizer-BNEQ9VDs.mjs.map} +1 -1
- package/dist/native-type-normalizer.mjs +1 -1
- package/dist/{op-factory-call-B9mYdDex.d.mts → op-factory-call-CDlImOF_.d.mts} +3 -3
- package/dist/{op-factory-call-B9mYdDex.d.mts.map → op-factory-call-CDlImOF_.d.mts.map} +1 -1
- package/dist/{op-factory-call-CGkVFW1s.mjs → op-factory-call-ewOd5q6L.mjs} +2 -2
- package/dist/{op-factory-call-CGkVFW1s.mjs.map → op-factory-call-ewOd5q6L.mjs.map} +1 -1
- package/dist/op-factory-call.d.mts +1 -1
- package/dist/op-factory-call.mjs +1 -1
- package/dist/pack.d.mts +2 -3
- package/dist/pack.d.mts.map +1 -1
- package/dist/pack.mjs +1 -1
- package/dist/{planner-B2pK98MX.mjs → planner-Bjz5pnLa.mjs} +7 -9
- package/dist/planner-Bjz5pnLa.mjs.map +1 -0
- package/dist/{planner-ddl-builders-CB8nSNnB.mjs → planner-ddl-builders-BNMfSE9r.mjs} +3 -3
- package/dist/{planner-ddl-builders-CB8nSNnB.mjs.map → planner-ddl-builders-BNMfSE9r.mjs.map} +1 -1
- package/dist/planner-ddl-builders.d.mts +1 -1
- package/dist/planner-ddl-builders.mjs +1 -1
- package/dist/{planner-identity-values-DfiMb2C9.mjs → planner-identity-values-nhVj0hp-.mjs} +1 -1
- package/dist/{planner-identity-values-DfiMb2C9.mjs.map → planner-identity-values-nhVj0hp-.mjs.map} +1 -1
- package/dist/planner-identity-values.mjs +1 -1
- package/dist/{planner-produced-postgres-migration-RdjC7aUC.d.mts → planner-produced-postgres-migration-D02NOhVQ.d.mts} +3 -3
- package/dist/{planner-produced-postgres-migration-RdjC7aUC.d.mts.map → planner-produced-postgres-migration-D02NOhVQ.d.mts.map} +1 -1
- package/dist/{planner-produced-postgres-migration-x3hafaGC.mjs → planner-produced-postgres-migration-D_nsXbhl.mjs} +4 -4
- package/dist/{planner-produced-postgres-migration-x3hafaGC.mjs.map → planner-produced-postgres-migration-D_nsXbhl.mjs.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-schema-lookup-DLJbkU7-.mjs → planner-schema-lookup-CGxxYfnD.mjs} +1 -1
- package/dist/{planner-schema-lookup-DLJbkU7-.mjs.map → planner-schema-lookup-CGxxYfnD.mjs.map} +1 -1
- package/dist/planner-schema-lookup.mjs +1 -1
- package/dist/{planner-sql-checks-BTr4eC5x.mjs → planner-sql-checks-CfEiTXoQ.mjs} +3 -3
- package/dist/{planner-sql-checks-BTr4eC5x.mjs.map → planner-sql-checks-CfEiTXoQ.mjs.map} +1 -1
- package/dist/planner-sql-checks.mjs +1 -1
- package/dist/{planner-target-details-C1Ye0hb6.d.mts → planner-target-details-a_wuOiYf.d.mts} +1 -1
- package/dist/{planner-target-details-C1Ye0hb6.d.mts.map → planner-target-details-a_wuOiYf.d.mts.map} +1 -1
- package/dist/planner-target-details.d.mts +1 -1
- package/dist/planner.d.mts +1 -1
- package/dist/planner.d.mts.map +1 -1
- package/dist/planner.mjs +1 -1
- package/dist/{postgres-contract-serializer-BYpK6TkY.mjs → postgres-contract-serializer-BnOboPWs.mjs} +3 -3
- package/dist/{postgres-contract-serializer-BYpK6TkY.mjs.map → postgres-contract-serializer-BnOboPWs.mjs.map} +1 -1
- package/dist/{postgres-enum-type-CaGZ2mfI.mjs → postgres-enum-type-BMgyxNyy.mjs} +1 -1
- package/dist/{postgres-enum-type-CaGZ2mfI.mjs.map → postgres-enum-type-BMgyxNyy.mjs.map} +1 -1
- package/dist/{postgres-enum-type-Bl6THBPg.d.mts → postgres-enum-type-CSzsvXrO.d.mts} +1 -1
- package/dist/{postgres-enum-type-Bl6THBPg.d.mts.map → postgres-enum-type-CSzsvXrO.d.mts.map} +1 -1
- package/dist/{postgres-migration-BDaWGYDu.mjs → postgres-migration-BatbEvU6.mjs} +3 -3
- package/dist/{postgres-migration-BDaWGYDu.mjs.map → postgres-migration-BatbEvU6.mjs.map} +1 -1
- package/dist/{postgres-migration-DLZtVVDM.d.mts → postgres-migration-DRY8V-bQ.d.mts} +3 -3
- package/dist/{postgres-migration-DLZtVVDM.d.mts.map → postgres-migration-DRY8V-bQ.d.mts.map} +1 -1
- package/dist/{postgres-schema-Dky_Jff8.mjs → postgres-schema-BxAuNFX0.mjs} +3 -3
- package/dist/{postgres-schema-Dky_Jff8.mjs.map → postgres-schema-BxAuNFX0.mjs.map} +1 -1
- package/dist/{render-ops-Da7bQcyv.mjs → render-ops-XhICjX_P.mjs} +1 -1
- package/dist/{render-ops-Da7bQcyv.mjs.map → render-ops-XhICjX_P.mjs.map} +1 -1
- package/dist/render-ops.d.mts +1 -1
- package/dist/render-ops.mjs +1 -1
- package/dist/{render-typescript-DTpTcoNZ.mjs → render-typescript-K125n-RZ.mjs} +1 -1
- package/dist/{render-typescript-DTpTcoNZ.mjs.map → render-typescript-K125n-RZ.mjs.map} +1 -1
- package/dist/render-typescript.mjs +1 -1
- package/dist/runtime.mjs +2 -2
- package/dist/{shared-wRIzOjdd.d.mts → shared-Do_a5ymU.d.mts} +2 -2
- package/dist/{shared-wRIzOjdd.d.mts.map → shared-Do_a5ymU.d.mts.map} +1 -1
- package/dist/{sql-utils-DR_F9aHR.mjs → sql-utils-CggjWNij.mjs} +1 -1
- package/dist/{sql-utils-DR_F9aHR.mjs.map → sql-utils-CggjWNij.mjs.map} +1 -1
- package/dist/sql-utils.mjs +1 -1
- package/dist/{statement-builders-Cd311EDF.mjs → statement-builders-DVI5IVAa.mjs} +4 -16
- package/dist/statement-builders-DVI5IVAa.mjs.map +1 -0
- package/dist/statement-builders.d.mts.map +1 -1
- package/dist/statement-builders.mjs +1 -1
- package/dist/{tables-BNa9HIqY.mjs → tables-DoA39Yqo.mjs} +3 -3
- package/dist/{tables-BNa9HIqY.mjs.map → tables-DoA39Yqo.mjs.map} +1 -1
- package/dist/{types-DncetAjv.d.mts → types-O40IcFV9.d.mts} +1 -1
- package/dist/types-O40IcFV9.d.mts.map +1 -0
- package/dist/types.d.mts +2 -2
- package/dist/types.mjs +2 -2
- package/package.json +17 -20
- package/src/core/descriptor-meta.ts +0 -1
- package/src/core/migrations/planner.ts +0 -2
- package/src/core/migrations/runner.ts +27 -66
- package/src/core/migrations/statement-builders.ts +3 -18
- package/dist/column-type-compatibility-Dzxz_CkP.mjs +0 -11
- package/dist/column-type-compatibility-Dzxz_CkP.mjs.map +0 -1
- package/dist/column-type-compatibility.d.mts +0 -5
- package/dist/column-type-compatibility.d.mts.map +0 -1
- package/dist/column-type-compatibility.mjs +0 -2
- package/dist/contract-free.d.mts +0 -35
- package/dist/contract-free.d.mts.map +0 -1
- package/dist/contract-free.mjs +0 -97
- package/dist/contract-free.mjs.map +0 -1
- package/dist/ddl.d.mts +0 -2
- package/dist/ddl.mjs +0 -2
- package/dist/descriptor-meta-BqATo5Dz.mjs.map +0 -1
- package/dist/nodes-BS8vS8gv.d.mts +0 -38
- package/dist/nodes-BS8vS8gv.d.mts.map +0 -1
- package/dist/nodes-BYSqasmC.mjs +0 -42
- package/dist/nodes-BYSqasmC.mjs.map +0 -1
- package/dist/planner-B2pK98MX.mjs.map +0 -1
- package/dist/statement-builders-Cd311EDF.mjs.map +0 -1
- package/dist/types-DncetAjv.d.mts.map +0 -1
- package/src/contract-free/control-bootstrap.ts +0 -55
- package/src/contract-free/ddl.ts +0 -32
- package/src/core/column-type-compatibility.ts +0 -13
- package/src/core/ddl/nodes.ts +0 -59
- package/src/exports/column-type-compatibility.ts +0 -1
- package/src/exports/contract-free.ts +0 -5
- package/src/exports/ddl.ts +0 -7
package/dist/contract-free.d.mts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { n as PostgresCreateSchema, r as PostgresCreateTable } from "./nodes-BS8vS8gv.mjs";
|
|
2
|
-
import { DdlColumn, DdlNode } from "@prisma-next/sql-relational-core/ast";
|
|
3
|
-
|
|
4
|
-
//#region src/contract-free/control-bootstrap.d.ts
|
|
5
|
-
declare function buildSignMarkerBootstrapQueries(): readonly DdlNode[];
|
|
6
|
-
declare function buildControlTableBootstrapQueries(): readonly DdlNode[];
|
|
7
|
-
//#endregion
|
|
8
|
-
//#region src/contract-free/ddl.d.ts
|
|
9
|
-
/**
|
|
10
|
-
* Build a Postgres `CREATE TABLE` query node.
|
|
11
|
-
*
|
|
12
|
-
* Precondition: identifiers (`table`, `schema`, column names/types) are
|
|
13
|
-
* emitted to SQL verbatim — they are not quoted or escaped, so callers must
|
|
14
|
-
* pass pre-trusted values (e.g. fixed control-plane identifiers). String-literal
|
|
15
|
-
* default values, by contrast, are single-quote-escaped (embedded `'` doubled)
|
|
16
|
-
* by the renderer. Identifier quoting for untrusted identifiers is added when
|
|
17
|
-
* the migration planner adopts this lowering path.
|
|
18
|
-
*/
|
|
19
|
-
declare function createTable(options: {
|
|
20
|
-
readonly table: string;
|
|
21
|
-
readonly schema?: string;
|
|
22
|
-
readonly ifNotExists?: boolean;
|
|
23
|
-
readonly columns: readonly DdlColumn[];
|
|
24
|
-
}): PostgresCreateTable;
|
|
25
|
-
/**
|
|
26
|
-
* Build a Postgres `CREATE SCHEMA` query node. See {@link createTable} for the
|
|
27
|
-
* pre-trusted-identifier precondition.
|
|
28
|
-
*/
|
|
29
|
-
declare function createSchema(options: {
|
|
30
|
-
readonly schema: string;
|
|
31
|
-
readonly ifNotExists?: boolean;
|
|
32
|
-
}): PostgresCreateSchema;
|
|
33
|
-
//#endregion
|
|
34
|
-
export { buildControlTableBootstrapQueries, buildSignMarkerBootstrapQueries, createSchema, createTable };
|
|
35
|
-
//# sourceMappingURL=contract-free.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contract-free.d.mts","names":[],"sources":["../src/contract-free/control-bootstrap.ts","../src/contract-free/ddl.ts"],"mappings":";;;;iBAgDgB,+BAAA,CAAA,YAA4C,OAAO;AAAA,iBAInD,iCAAA,CAAA,YAA8C,OAAO;;;;;AAJrE;;;;AAAmE;AAInE;;;iBCvCgB,WAAA,CAAY,OAAA;EAAA,SACjB,KAAA;EAAA,SACA,MAAA;EAAA,SACA,WAAA;EAAA,SACA,OAAA,WAAkB,SAAA;AAAA,IACzB,mBAAmB;;;;;iBAQP,YAAA,CAAa,OAAA;EAAA,SAClB,MAAA;EAAA,SACA,WAAA;AAAA,IACP,oBAAoB"}
|
package/dist/contract-free.mjs
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { n as PostgresCreateTable, t as PostgresCreateSchema } from "./nodes-BYSqasmC.mjs";
|
|
2
|
-
import { APP_SPACE_ID } from "@prisma-next/framework-components/control";
|
|
3
|
-
import { col, fn, lit } from "@prisma-next/sql-relational-core/contract-free";
|
|
4
|
-
//#region src/contract-free/ddl.ts
|
|
5
|
-
/**
|
|
6
|
-
* Build a Postgres `CREATE TABLE` query node.
|
|
7
|
-
*
|
|
8
|
-
* Precondition: identifiers (`table`, `schema`, column names/types) are
|
|
9
|
-
* emitted to SQL verbatim — they are not quoted or escaped, so callers must
|
|
10
|
-
* pass pre-trusted values (e.g. fixed control-plane identifiers). String-literal
|
|
11
|
-
* default values, by contrast, are single-quote-escaped (embedded `'` doubled)
|
|
12
|
-
* by the renderer. Identifier quoting for untrusted identifiers is added when
|
|
13
|
-
* the migration planner adopts this lowering path.
|
|
14
|
-
*/
|
|
15
|
-
function createTable(options) {
|
|
16
|
-
return new PostgresCreateTable(options);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Build a Postgres `CREATE SCHEMA` query node. See {@link createTable} for the
|
|
20
|
-
* pre-trusted-identifier precondition.
|
|
21
|
-
*/
|
|
22
|
-
function createSchema(options) {
|
|
23
|
-
return new PostgresCreateSchema(options);
|
|
24
|
-
}
|
|
25
|
-
//#endregion
|
|
26
|
-
//#region src/contract-free/control-bootstrap.ts
|
|
27
|
-
const markerColumns = [
|
|
28
|
-
col("space", "text", {
|
|
29
|
-
notNull: true,
|
|
30
|
-
primaryKey: true,
|
|
31
|
-
default: lit(APP_SPACE_ID)
|
|
32
|
-
}),
|
|
33
|
-
col("core_hash", "text", { notNull: true }),
|
|
34
|
-
col("profile_hash", "text", { notNull: true }),
|
|
35
|
-
col("contract_json", "jsonb"),
|
|
36
|
-
col("canonical_version", "int"),
|
|
37
|
-
col("updated_at", "timestamptz", {
|
|
38
|
-
notNull: true,
|
|
39
|
-
default: fn("now()")
|
|
40
|
-
}),
|
|
41
|
-
col("app_tag", "text"),
|
|
42
|
-
col("meta", "jsonb", {
|
|
43
|
-
notNull: true,
|
|
44
|
-
default: lit("{}")
|
|
45
|
-
}),
|
|
46
|
-
col("invariants", "text[]", {
|
|
47
|
-
notNull: true,
|
|
48
|
-
default: lit("{}")
|
|
49
|
-
})
|
|
50
|
-
];
|
|
51
|
-
const ledgerColumns = [
|
|
52
|
-
col("id", "bigserial", { primaryKey: true }),
|
|
53
|
-
col("created_at", "timestamptz", {
|
|
54
|
-
notNull: true,
|
|
55
|
-
default: fn("now()")
|
|
56
|
-
}),
|
|
57
|
-
col("space", "text", { notNull: true }),
|
|
58
|
-
col("migration_name", "text", { notNull: true }),
|
|
59
|
-
col("migration_hash", "text", { notNull: true }),
|
|
60
|
-
col("origin_core_hash", "text"),
|
|
61
|
-
col("origin_profile_hash", "text"),
|
|
62
|
-
col("destination_core_hash", "text", { notNull: true }),
|
|
63
|
-
col("destination_profile_hash", "text"),
|
|
64
|
-
col("contract_json_before", "jsonb"),
|
|
65
|
-
col("contract_json_after", "jsonb"),
|
|
66
|
-
col("operations", "jsonb", { notNull: true })
|
|
67
|
-
];
|
|
68
|
-
const markerTable = createTable({
|
|
69
|
-
schema: "prisma_contract",
|
|
70
|
-
table: "marker",
|
|
71
|
-
ifNotExists: true,
|
|
72
|
-
columns: markerColumns
|
|
73
|
-
});
|
|
74
|
-
const ledgerTable = createTable({
|
|
75
|
-
schema: "prisma_contract",
|
|
76
|
-
table: "ledger",
|
|
77
|
-
ifNotExists: true,
|
|
78
|
-
columns: ledgerColumns
|
|
79
|
-
});
|
|
80
|
-
const controlSchema = createSchema({
|
|
81
|
-
schema: "prisma_contract",
|
|
82
|
-
ifNotExists: true
|
|
83
|
-
});
|
|
84
|
-
function buildSignMarkerBootstrapQueries() {
|
|
85
|
-
return [controlSchema, markerTable];
|
|
86
|
-
}
|
|
87
|
-
function buildControlTableBootstrapQueries() {
|
|
88
|
-
return [
|
|
89
|
-
controlSchema,
|
|
90
|
-
markerTable,
|
|
91
|
-
ledgerTable
|
|
92
|
-
];
|
|
93
|
-
}
|
|
94
|
-
//#endregion
|
|
95
|
-
export { buildControlTableBootstrapQueries, buildSignMarkerBootstrapQueries, createSchema, createTable };
|
|
96
|
-
|
|
97
|
-
//# sourceMappingURL=contract-free.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contract-free.mjs","names":[],"sources":["../src/contract-free/ddl.ts","../src/contract-free/control-bootstrap.ts"],"sourcesContent":["import type { DdlColumn } from '@prisma-next/sql-relational-core/ast';\nimport { PostgresCreateSchema, PostgresCreateTable } from '../core/ddl/nodes';\n\n/**\n * Build a Postgres `CREATE TABLE` query node.\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}): 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","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":";;;;;;;;;;;;;;AAaA,SAAgB,YAAY,SAKJ;CACtB,OAAO,IAAI,oBAAoB,OAAO;AACxC;;;;;AAMA,SAAgB,aAAa,SAGJ;CACvB,OAAO,IAAI,qBAAqB,OAAO;AACzC;;;AC1BA,MAAM,gBAAgB;CACpB,IAAI,SAAS,QAAQ;EAAE,SAAS;EAAM,YAAY;EAAM,SAAS,IAAI,YAAY;CAAE,CAAC;CACpF,IAAI,aAAa,QAAQ,EAAE,SAAS,KAAK,CAAC;CAC1C,IAAI,gBAAgB,QAAQ,EAAE,SAAS,KAAK,CAAC;CAC7C,IAAI,iBAAiB,OAAO;CAC5B,IAAI,qBAAqB,KAAK;CAC9B,IAAI,cAAc,eAAe;EAAE,SAAS;EAAM,SAAS,GAAG,OAAO;CAAE,CAAC;CACxE,IAAI,WAAW,MAAM;CACrB,IAAI,QAAQ,SAAS;EAAE,SAAS;EAAM,SAAS,IAAI,IAAI;CAAE,CAAC;CAC1D,IAAI,cAAc,UAAU;EAAE,SAAS;EAAM,SAAS,IAAI,IAAI;CAAE,CAAC;AACnE;AAEA,MAAM,gBAAgB;CACpB,IAAI,MAAM,aAAa,EAAE,YAAY,KAAK,CAAC;CAC3C,IAAI,cAAc,eAAe;EAAE,SAAS;EAAM,SAAS,GAAG,OAAO;CAAE,CAAC;CACxE,IAAI,SAAS,QAAQ,EAAE,SAAS,KAAK,CAAC;CACtC,IAAI,kBAAkB,QAAQ,EAAE,SAAS,KAAK,CAAC;CAC/C,IAAI,kBAAkB,QAAQ,EAAE,SAAS,KAAK,CAAC;CAC/C,IAAI,oBAAoB,MAAM;CAC9B,IAAI,uBAAuB,MAAM;CACjC,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/ddl.d.mts
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { a as PostgresDdlVisitor, i as PostgresDdlNode, n as PostgresCreateSchema, r as PostgresCreateTable, t as AnyPostgresDdlNode } from "./nodes-BS8vS8gv.mjs";
|
|
2
|
-
export { type AnyPostgresDdlNode, PostgresCreateSchema, PostgresCreateTable, PostgresDdlNode, type PostgresDdlVisitor };
|
package/dist/ddl.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"descriptor-meta-BqATo5Dz.mjs","names":[],"sources":["../src/core/descriptor-meta.ts"],"sourcesContent":["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":";AAkBA,MAAa,+BAET;CAXF,GAAG;CACH,oBAAoB;CACpB,WAAW;EACT,MAAM;EACN,OAAO;EACP,aAAa;CACf;AAKE"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { DdlColumn, DdlNode } from "@prisma-next/sql-relational-core/ast";
|
|
2
|
-
|
|
3
|
-
//#region src/core/ddl/nodes.d.ts
|
|
4
|
-
interface PostgresDdlVisitor<R> {
|
|
5
|
-
createTable(node: PostgresCreateTable): R;
|
|
6
|
-
createSchema(node: PostgresCreateSchema): R;
|
|
7
|
-
}
|
|
8
|
-
declare abstract class PostgresDdlNode extends DdlNode {
|
|
9
|
-
abstract accept<R>(visitor: PostgresDdlVisitor<R>): R;
|
|
10
|
-
}
|
|
11
|
-
declare class PostgresCreateTable extends PostgresDdlNode {
|
|
12
|
-
readonly kind: "create-table";
|
|
13
|
-
readonly table: string;
|
|
14
|
-
readonly schema: string | undefined;
|
|
15
|
-
readonly ifNotExists: boolean | undefined;
|
|
16
|
-
readonly columns: ReadonlyArray<DdlColumn>;
|
|
17
|
-
constructor(options: {
|
|
18
|
-
readonly table: string;
|
|
19
|
-
readonly schema?: string;
|
|
20
|
-
readonly ifNotExists?: boolean;
|
|
21
|
-
readonly columns: readonly DdlColumn[];
|
|
22
|
-
});
|
|
23
|
-
accept<R>(visitor: PostgresDdlVisitor<R>): R;
|
|
24
|
-
}
|
|
25
|
-
declare class PostgresCreateSchema extends PostgresDdlNode {
|
|
26
|
-
readonly kind: "create-schema";
|
|
27
|
-
readonly schema: string;
|
|
28
|
-
readonly ifNotExists: boolean | undefined;
|
|
29
|
-
constructor(options: {
|
|
30
|
-
readonly schema: string;
|
|
31
|
-
readonly ifNotExists?: boolean;
|
|
32
|
-
});
|
|
33
|
-
accept<R>(visitor: PostgresDdlVisitor<R>): R;
|
|
34
|
-
}
|
|
35
|
-
type AnyPostgresDdlNode = PostgresCreateTable | PostgresCreateSchema;
|
|
36
|
-
//#endregion
|
|
37
|
-
export { PostgresDdlVisitor as a, PostgresDdlNode as i, PostgresCreateSchema as n, PostgresCreateTable as r, AnyPostgresDdlNode as t };
|
|
38
|
-
//# sourceMappingURL=nodes-BS8vS8gv.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nodes-BS8vS8gv.d.mts","names":[],"sources":["../src/core/ddl/nodes.ts"],"mappings":";;;UAEiB,kBAAA;EACf,WAAA,CAAY,IAAA,EAAM,mBAAA,GAAsB,CAAA;EACxC,YAAA,CAAa,IAAA,EAAM,oBAAA,GAAuB,CAAA;AAAA;AAAA,uBAGtB,eAAA,SAAwB,OAAA;EAAA,SACnC,MAAA,GAAA,CAAU,OAAA,EAAS,kBAAA,CAAmB,CAAA,IAAK,CAAA;AAAA;AAAA,cAOzC,mBAAA,SAA4B,eAAA;EAAA,SAC9B,IAAA;EAAA,SACA,KAAA;EAAA,SACA,MAAA;EAAA,SACA,WAAA;EAAA,SACA,OAAA,EAAS,aAAA,CAAc,SAAA;cAEpB,OAAA;IAAA,SACD,KAAA;IAAA,SACA,MAAA;IAAA,SACA,WAAA;IAAA,SACA,OAAA,WAAkB,SAAA;EAAA;EAUpB,MAAA,GAAA,CAAU,OAAA,EAAS,kBAAA,CAAmB,CAAA,IAAK,CAAA;AAAA;AAAA,cAKzC,oBAAA,SAA6B,eAAA;EAAA,SAC/B,IAAA;EAAA,SACA,MAAA;EAAA,SACA,WAAA;cAEG,OAAA;IAAA,SAAoB,MAAA;IAAA,SAAyB,WAAA;EAAA;EAOhD,MAAA,GAAA,CAAU,OAAA,EAAS,kBAAA,CAAmB,CAAA,IAAK,CAAA;AAAA;AAAA,KAK1C,kBAAA,GAAqB,mBAAA,GAAsB,oBAAoB"}
|
package/dist/nodes-BYSqasmC.mjs
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { DdlNode } from "@prisma-next/sql-relational-core/ast";
|
|
2
|
-
//#region src/core/ddl/nodes.ts
|
|
3
|
-
var PostgresDdlNode = class extends DdlNode {};
|
|
4
|
-
function freezeDdlColumns(columns) {
|
|
5
|
-
return Object.freeze([...columns]);
|
|
6
|
-
}
|
|
7
|
-
var PostgresCreateTable = class extends PostgresDdlNode {
|
|
8
|
-
kind = "create-table";
|
|
9
|
-
table;
|
|
10
|
-
schema;
|
|
11
|
-
ifNotExists;
|
|
12
|
-
columns;
|
|
13
|
-
constructor(options) {
|
|
14
|
-
super();
|
|
15
|
-
this.table = options.table;
|
|
16
|
-
this.schema = options.schema;
|
|
17
|
-
this.ifNotExists = options.ifNotExists;
|
|
18
|
-
this.columns = freezeDdlColumns(options.columns);
|
|
19
|
-
this.freeze();
|
|
20
|
-
}
|
|
21
|
-
accept(visitor) {
|
|
22
|
-
return visitor.createTable(this);
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
var PostgresCreateSchema = class extends PostgresDdlNode {
|
|
26
|
-
kind = "create-schema";
|
|
27
|
-
schema;
|
|
28
|
-
ifNotExists;
|
|
29
|
-
constructor(options) {
|
|
30
|
-
super();
|
|
31
|
-
this.schema = options.schema;
|
|
32
|
-
this.ifNotExists = options.ifNotExists;
|
|
33
|
-
this.freeze();
|
|
34
|
-
}
|
|
35
|
-
accept(visitor) {
|
|
36
|
-
return visitor.createSchema(this);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
//#endregion
|
|
40
|
-
export { PostgresCreateTable as n, PostgresDdlNode as r, PostgresCreateSchema as t };
|
|
41
|
-
|
|
42
|
-
//# sourceMappingURL=nodes-BYSqasmC.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nodes-BYSqasmC.mjs","names":[],"sources":["../src/core/ddl/nodes.ts"],"sourcesContent":["import { type DdlColumn, DdlNode } from '@prisma-next/sql-relational-core/ast';\n\nexport interface PostgresDdlVisitor<R> {\n createTable(node: PostgresCreateTable): R;\n createSchema(node: PostgresCreateSchema): R;\n}\n\nexport abstract class PostgresDdlNode extends DdlNode {\n abstract accept<R>(visitor: PostgresDdlVisitor<R>): R;\n}\n\nfunction freezeDdlColumns(columns: readonly DdlColumn[]): ReadonlyArray<DdlColumn> {\n return Object.freeze([...columns]);\n}\n\nexport class PostgresCreateTable extends PostgresDdlNode {\n readonly kind = 'create-table' as const;\n readonly table: string;\n readonly schema: string | undefined;\n readonly ifNotExists: boolean | undefined;\n readonly columns: ReadonlyArray<DdlColumn>;\n\n constructor(options: {\n readonly table: string;\n readonly schema?: string;\n readonly ifNotExists?: boolean;\n readonly columns: readonly DdlColumn[];\n }) {\n super();\n this.table = options.table;\n this.schema = options.schema;\n this.ifNotExists = options.ifNotExists;\n this.columns = freezeDdlColumns(options.columns);\n this.freeze();\n }\n\n override accept<R>(visitor: PostgresDdlVisitor<R>): R {\n return visitor.createTable(this);\n }\n}\n\nexport class PostgresCreateSchema extends PostgresDdlNode {\n readonly kind = 'create-schema' as const;\n readonly schema: string;\n readonly ifNotExists: boolean | undefined;\n\n constructor(options: { readonly schema: string; readonly ifNotExists?: boolean }) {\n super();\n this.schema = options.schema;\n this.ifNotExists = options.ifNotExists;\n this.freeze();\n }\n\n override accept<R>(visitor: PostgresDdlVisitor<R>): R {\n return visitor.createSchema(this);\n }\n}\n\nexport type AnyPostgresDdlNode = PostgresCreateTable | PostgresCreateSchema;\n"],"mappings":";;AAOA,IAAsB,kBAAtB,cAA8C,QAAQ,CAEtD;AAEA,SAAS,iBAAiB,SAAyD;CACjF,OAAO,OAAO,OAAO,CAAC,GAAG,OAAO,CAAC;AACnC;AAEA,IAAa,sBAAb,cAAyC,gBAAgB;CACvD,OAAgB;CAChB;CACA;CACA;CACA;CAEA,YAAY,SAKT;EACD,MAAM;EACN,KAAK,QAAQ,QAAQ;EACrB,KAAK,SAAS,QAAQ;EACtB,KAAK,cAAc,QAAQ;EAC3B,KAAK,UAAU,iBAAiB,QAAQ,OAAO;EAC/C,KAAK,OAAO;CACd;CAEA,OAAmB,SAAmC;EACpD,OAAO,QAAQ,YAAY,IAAI;CACjC;AACF;AAEA,IAAa,uBAAb,cAA0C,gBAAgB;CACxD,OAAgB;CAChB;CACA;CAEA,YAAY,SAAsE;EAChF,MAAM;EACN,KAAK,SAAS,QAAQ;EACtB,KAAK,cAAc,QAAQ;EAC3B,KAAK,OAAO;CACd;CAEA,OAAmB,SAAmC;EACpD,OAAO,QAAQ,aAAa,IAAI;CAClC;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"planner-B2pK98MX.mjs","names":[],"sources":["../src/core/migrations/verify-postgres-namespaces.ts","../src/core/migrations/planner.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport type { SchemaIssue } from '@prisma-next/framework-components/control';\nimport { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';\nimport { isPostgresSchema } from '../postgres-schema';\n\n/**\n * Resolves the live-database schema name for a given namespace\n * coordinate. Mirrors `resolveDdlSchemaForNamespace` in\n * `planner-strategies.ts` so the verifier's projection and the\n * planner's projection always agree — Postgres-aware namespaces (the\n * production path) dispatch to `ddlSchemaName(storage)`, and bare\n * object payloads (used by some tests) fall back to the coordinate\n * itself.\n */\nfunction resolveDdlSchemaName(storage: SqlStorage, namespaceId: string): string {\n const namespace = storage.namespaces[namespaceId];\n if (isPostgresSchema(namespace)) {\n return namespace.ddlSchemaName(storage);\n }\n return namespaceId;\n}\n\n/**\n * Reads the introspected list of schema names from the Postgres-flavoured\n * annotations slot on the schema IR. Defaults to the always-present\n * `public` schema when introspection did not populate the slot — a fresh\n * Postgres database always carries `public` (unless an operator dropped\n * it manually), so any verifier path that runs without an enriched\n * introspection still suppresses the redundant `CREATE SCHEMA \"public\"`.\n *\n * Production introspection (`PostgresControlAdapter.introspect`) is the\n * authoritative source: it queries `pg_namespace` and writes every\n * non-system schema into `annotations.pg.existingSchemas`. Tests that\n * want to assert against a richer initial state pass the slot\n * explicitly via the schema IR.\n */\nfunction existingSchemasFromSchema(schema: SqlSchemaIR): readonly string[] {\n const annotations = (schema as { annotations?: { pg?: { existingSchemas?: unknown } } })\n .annotations;\n const slot = annotations?.pg?.existingSchemas;\n if (Array.isArray(slot)) {\n return slot.filter((s): s is string => typeof s === 'string');\n }\n return ['public'];\n}\n\n/**\n * Emits a `missing_schema` issue for every contract-declared Postgres\n * namespace whose live container does not yet exist.\n *\n * A namespace's live container is the schema returned by its\n * polymorphic `ddlSchemaName(storage)` method — named schemas resolve\n * to their own id; the unbound singleton returns `UNBOUND_NAMESPACE_ID`\n * and is skipped explicitly (late-bound namespaces have no fixed DDL\n * schema). Issues are emitted only when the resolved name is a real,\n * creatable schema (not the unbound sentinel) and is missing from the\n * introspected list. `public` is suppressed implicitly because the\n * introspection (or its sensible default) always carries it.\n *\n * Each emitted issue stamps `namespaceId` with the contract namespace\n * coordinate so the downstream `mapIssueToCall` re-resolves the DDL\n * schema name through the same polymorphic path — keeping the\n * coordinate, not the resolved name, as the issue's stable identity.\n */\nexport function verifyPostgresNamespacePresence(input: {\n readonly contract: Contract<SqlStorage>;\n readonly schema: SqlSchemaIR;\n}): readonly SchemaIssue[] {\n const { contract, schema } = input;\n const existing = new Set(existingSchemasFromSchema(schema));\n const issues: SchemaIssue[] = [];\n const namespaceIds = Object.keys(contract.storage.namespaces).sort();\n for (const namespaceId of namespaceIds) {\n if (namespaceId === UNBOUND_NAMESPACE_ID) continue;\n const ddlName = resolveDdlSchemaName(contract.storage, namespaceId);\n if (ddlName === UNBOUND_NAMESPACE_ID) continue;\n if (existing.has(ddlName)) continue;\n issues.push({\n kind: 'missing_schema',\n namespaceId,\n message: `Schema \"${ddlName}\" is missing from database`,\n });\n }\n return issues;\n}\n","import type { Contract } from '@prisma-next/contract/types';\nimport type {\n MigrationOperationPolicy,\n SqlMigrationPlannerPlanOptions,\n SqlPlannerFailureResult,\n} from '@prisma-next/family-sql/control';\nimport {\n extractCodecControlHooks,\n planFieldEventOperations,\n plannerFailure,\n} from '@prisma-next/family-sql/control';\nimport { verifySqlSchema } from '@prisma-next/family-sql/schema-verify';\nimport type { TargetBoundComponentDescriptor } from '@prisma-next/framework-components/components';\nimport type {\n MigrationPlanner,\n MigrationPlanWithAuthoringSurface,\n MigrationScaffoldContext,\n SchemaIssue,\n} from '@prisma-next/framework-components/control';\nimport { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport { postgresColumnsCompatible } from '../column-type-compatibility';\nimport { parsePostgresDefault } from '../default-normalizer';\nimport { normalizeSchemaNativeType } from '../native-type-normalizer';\nimport { createResolveExistingEnumValues } from './enum-planning';\nimport { planIssues } from './issue-planner';\nimport { TypeScriptRenderablePostgresMigration } from './planner-produced-postgres-migration';\nimport { postgresPlannerStrategies } from './planner-strategies';\nimport { verifyPostgresNamespacePresence } from './verify-postgres-namespaces';\n\ntype PlannerFrameworkComponents = SqlMigrationPlannerPlanOptions extends {\n readonly frameworkComponents: infer T;\n}\n ? T\n : ReadonlyArray<unknown>;\n\ntype PlannerOptionsWithComponents = SqlMigrationPlannerPlanOptions & {\n readonly frameworkComponents: PlannerFrameworkComponents;\n};\n\ntype VerifySqlSchemaOptionsWithComponents = Parameters<typeof verifySqlSchema>[0] & {\n readonly frameworkComponents: PlannerFrameworkComponents;\n};\n\nexport function createPostgresMigrationPlanner(): PostgresMigrationPlanner {\n return new PostgresMigrationPlanner();\n}\n\n/**\n * Result of `PostgresMigrationPlanner.plan()`. A discriminated union whose\n * success variant carries a `TypeScriptRenderablePostgresMigration` — a\n * migration object that both the CLI (via `renderTypeScript()`) and the\n * SQL-typed callers (via `operations`, `describe()`, etc.) consume\n * uniformly.\n */\nexport type PostgresPlanResult =\n | { readonly kind: 'success'; readonly plan: TypeScriptRenderablePostgresMigration }\n | SqlPlannerFailureResult;\n\n/**\n * Postgres migration planner — a thin wrapper over `planIssues`.\n *\n * `plan()` verifies the live schema against the target contract (producing\n * `SchemaIssue[]`) and delegates to `planIssues` with the unified\n * `postgresPlannerStrategies` list: enum-change, NOT-NULL backfill,\n * type-change, nullable-tightening, codec-hook storage types,\n * component-declared dependency installs, and shared-temp-default /\n * empty-table-guarded NOT-NULL add-column. The same strategy list runs for\n * `migration plan`, `db update`, and `db init`; behavior diverges purely on\n * `policy.allowedOperationClasses` (the data-safe strategies short-circuit\n * when `'data'` is excluded). The issue planner applies operation-class\n * policy gates and emits a single `PostgresOpFactoryCall[]` that drives both\n * the runtime-ops view (via `renderOps`) and the `renderTypeScript()`\n * authoring surface.\n */\nexport class PostgresMigrationPlanner implements MigrationPlanner<'sql', 'postgres'> {\n plan(options: {\n readonly contract: unknown;\n readonly schema: unknown;\n readonly policy: MigrationOperationPolicy;\n /**\n * The \"from\" contract (state the planner assumes the database starts\n * at), or `null` for reconciliation flows. Only `migration plan` ever\n * supplies a non-null value; `db update` / `db init` reconcile against\n * the live schema and pass `null`. When present alongside the\n * `'data'` operation class, strategies that need from/to column-shape\n * comparisons (unsafe type change, nullability tightening) activate.\n *\n * Typed as the framework `Contract | null` to satisfy the\n * `MigrationPlanner` interface contract; `planSql` narrows to the SQL\n * shape via `SqlMigrationPlannerPlanOptions`. Used to populate\n * `describe().from` on the produced plan as\n * `fromContract?.storage.storageHash ?? null`.\n */\n readonly fromContract: Contract | null;\n readonly schemaName?: string;\n readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;\n /**\n * Contract space this plan applies to. Stamped onto the produced\n * {@link TypeScriptRenderablePostgresMigration.spaceId} so the runner keys\n * the marker row by the right space.\n */\n readonly spaceId: string;\n }): PostgresPlanResult {\n return this.planSql(options as SqlMigrationPlannerPlanOptions);\n }\n\n emptyMigration(\n context: MigrationScaffoldContext,\n spaceId: string,\n ): MigrationPlanWithAuthoringSurface {\n return new TypeScriptRenderablePostgresMigration(\n [],\n {\n from: context.fromHash,\n to: context.toHash,\n },\n spaceId,\n );\n }\n\n private planSql(options: SqlMigrationPlannerPlanOptions): PostgresPlanResult {\n const schemaName =\n options.schemaName ??\n Object.keys(options.contract.storage.namespaces).find((id) => id !== UNBOUND_NAMESPACE_ID) ??\n UNBOUND_NAMESPACE_ID;\n const policyResult = this.ensureAdditivePolicy(options.policy);\n if (policyResult) {\n return policyResult;\n }\n\n const schemaIssues = this.collectSchemaIssues(options);\n const codecHooks = extractCodecControlHooks(options.frameworkComponents);\n const storageTypes = options.contract.storage.types ?? {};\n\n const result = planIssues({\n issues: schemaIssues,\n toContract: options.contract,\n // `fromContract` is only supplied by `migration plan`. It is `null` for\n // `db update` / `db init`, which means data-safety strategies needing\n // from/to comparisons (unsafe type change, nullable tightening) are\n // inapplicable there — reconciliation falls through to\n // `mapIssueToCall`'s direct destructive handlers.\n fromContract: options.fromContract,\n schemaName,\n codecHooks,\n storageTypes,\n schema: options.schema,\n policy: options.policy,\n frameworkComponents: options.frameworkComponents,\n strategies: postgresPlannerStrategies,\n });\n\n if (!result.ok) {\n return plannerFailure(result.failure);\n }\n\n // Inline `onFieldEvent`-emitted ops after structural DDL. The fixed\n // ordering is `structural → added → dropped → altered`, with\n // within-group sorting by `(tableName, fieldName)` so re-emits are\n // byte-stable. The hook fires only at the application emitter —\n // extension-space planning never reaches this helper.\n const fieldEventOps = planFieldEventOperations({\n priorContract: options.fromContract,\n newContract: options.contract,\n codecHooks,\n });\n // Codec-emitted calls already conform to `OpFactoryCall` — render +\n // toOp + importRequirements ride directly through the same emit path\n // as structural ops, no `RawSqlCall` wrap.\n const calls = [...result.value.calls, ...fieldEventOps];\n\n return Object.freeze({\n kind: 'success' as const,\n plan: new TypeScriptRenderablePostgresMigration(\n calls,\n {\n from: options.fromContract?.storage.storageHash ?? null,\n to: options.contract.storage.storageHash,\n },\n options.spaceId,\n ),\n });\n }\n\n private ensureAdditivePolicy(policy: MigrationOperationPolicy) {\n if (!policy.allowedOperationClasses.includes('additive')) {\n return plannerFailure([\n {\n kind: 'unsupportedOperation',\n summary: 'Migration planner requires additive operations be allowed',\n why: 'The planner requires the \"additive\" operation class to be allowed in the policy.',\n },\n ]);\n }\n return null;\n }\n\n private collectSchemaIssues(options: PlannerOptionsWithComponents): readonly SchemaIssue[] {\n // `db init` uses additive-only policy and intentionally ignores extra\n // schema objects. Any reconciliation-capable policy (widening or\n // destructive) must inspect extras to reconcile strict equality.\n const allowed = options.policy.allowedOperationClasses;\n const strict = allowed.includes('widening') || allowed.includes('destructive');\n const verifyOptions: VerifySqlSchemaOptionsWithComponents = {\n contract: options.contract,\n schema: options.schema,\n strict,\n typeMetadataRegistry: new Map(),\n frameworkComponents: options.frameworkComponents,\n normalizeDefault: parsePostgresDefault,\n normalizeNativeType: normalizeSchemaNativeType,\n columnsCompatible: postgresColumnsCompatible,\n resolveExistingEnumValues: createResolveExistingEnumValues(options.contract.storage),\n };\n const verifyResult = verifySqlSchema(verifyOptions);\n // Schema presence is a Postgres-specific concern (no equivalent in\n // SQLite / Mongo), so the issue emission lives in the target layer\n // rather than in the family verifier. Stitch it in here so a single\n // `SchemaIssue[]` flows through `planIssues` and the planner emits\n // CREATE SCHEMA in the dep bucket before any CreateTableCall.\n const namespaceIssues = verifyPostgresNamespacePresence({\n contract: options.contract,\n schema: options.schema,\n });\n if (namespaceIssues.length === 0) {\n return verifyResult.schema.issues;\n }\n return [...namespaceIssues, ...verifyResult.schema.issues];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAgBA,SAAS,qBAAqB,SAAqB,aAA6B;CAC9E,MAAM,YAAY,QAAQ,WAAW;CACrC,IAAI,iBAAiB,SAAS,GAC5B,OAAO,UAAU,cAAc,OAAO;CAExC,OAAO;AACT;;;;;;;;;;;;;;;AAgBA,SAAS,0BAA0B,QAAwC;CAGzE,MAAM,OAFe,OAClB,aACuB,IAAI;CAC9B,IAAI,MAAM,QAAQ,IAAI,GACpB,OAAO,KAAK,QAAQ,MAAmB,OAAO,MAAM,QAAQ;CAE9D,OAAO,CAAC,QAAQ;AAClB;;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,gCAAgC,OAGrB;CACzB,MAAM,EAAE,UAAU,WAAW;CAC7B,MAAM,WAAW,IAAI,IAAI,0BAA0B,MAAM,CAAC;CAC1D,MAAM,SAAwB,CAAC;CAC/B,MAAM,eAAe,OAAO,KAAK,SAAS,QAAQ,UAAU,EAAE,KAAK;CACnE,KAAK,MAAM,eAAe,cAAc;EACtC,IAAI,gBAAgB,sBAAsB;EAC1C,MAAM,UAAU,qBAAqB,SAAS,SAAS,WAAW;EAClE,IAAI,YAAY,sBAAsB;EACtC,IAAI,SAAS,IAAI,OAAO,GAAG;EAC3B,OAAO,KAAK;GACV,MAAM;GACN;GACA,SAAS,WAAW,QAAQ;EAC9B,CAAC;CACH;CACA,OAAO;AACT;;;AC3CA,SAAgB,iCAA2D;CACzE,OAAO,IAAI,yBAAyB;AACtC;;;;;;;;;;;;;;;;;AA6BA,IAAa,2BAAb,MAAqF;CACnF,KAAK,SA2BkB;EACrB,OAAO,KAAK,QAAQ,OAAyC;CAC/D;CAEA,eACE,SACA,SACmC;EACnC,OAAO,IAAI,sCACT,CAAC,GACD;GACE,MAAM,QAAQ;GACd,IAAI,QAAQ;EACd,GACA,OACF;CACF;CAEA,QAAgB,SAA6D;EAC3E,MAAM,aACJ,QAAQ,cACR,OAAO,KAAK,QAAQ,SAAS,QAAQ,UAAU,EAAE,MAAM,OAAO,OAAO,oBAAoB,KACzF;EACF,MAAM,eAAe,KAAK,qBAAqB,QAAQ,MAAM;EAC7D,IAAI,cACF,OAAO;EAGT,MAAM,eAAe,KAAK,oBAAoB,OAAO;EACrD,MAAM,aAAa,yBAAyB,QAAQ,mBAAmB;EACvE,MAAM,eAAe,QAAQ,SAAS,QAAQ,SAAS,CAAC;EAExD,MAAM,SAAS,WAAW;GACxB,QAAQ;GACR,YAAY,QAAQ;GAMpB,cAAc,QAAQ;GACtB;GACA;GACA;GACA,QAAQ,QAAQ;GAChB,QAAQ,QAAQ;GAChB,qBAAqB,QAAQ;GAC7B,YAAY;EACd,CAAC;EAED,IAAI,CAAC,OAAO,IACV,OAAO,eAAe,OAAO,OAAO;EAQtC,MAAM,gBAAgB,yBAAyB;GAC7C,eAAe,QAAQ;GACvB,aAAa,QAAQ;GACrB;EACF,CAAC;EAID,MAAM,QAAQ,CAAC,GAAG,OAAO,MAAM,OAAO,GAAG,aAAa;EAEtD,OAAO,OAAO,OAAO;GACnB,MAAM;GACN,MAAM,IAAI,sCACR,OACA;IACE,MAAM,QAAQ,cAAc,QAAQ,eAAe;IACnD,IAAI,QAAQ,SAAS,QAAQ;GAC/B,GACA,QAAQ,OACV;EACF,CAAC;CACH;CAEA,qBAA6B,QAAkC;EAC7D,IAAI,CAAC,OAAO,wBAAwB,SAAS,UAAU,GACrD,OAAO,eAAe,CACpB;GACE,MAAM;GACN,SAAS;GACT,KAAK;EACP,CACF,CAAC;EAEH,OAAO;CACT;CAEA,oBAA4B,SAA+D;EAIzF,MAAM,UAAU,QAAQ,OAAO;EAC/B,MAAM,SAAS,QAAQ,SAAS,UAAU,KAAK,QAAQ,SAAS,aAAa;EAY7E,MAAM,eAAe,gBAAgB;GAVnC,UAAU,QAAQ;GAClB,QAAQ,QAAQ;GAChB;GACA,sCAAsB,IAAI,IAAI;GAC9B,qBAAqB,QAAQ;GAC7B,kBAAkB;GAClB,qBAAqB;GACrB,mBAAmB;GACnB,2BAA2B,gCAAgC,QAAQ,SAAS,OAAO;EAEpC,CAAC;EAMlD,MAAM,kBAAkB,gCAAgC;GACtD,UAAU,QAAQ;GAClB,QAAQ,QAAQ;EAClB,CAAC;EACD,IAAI,gBAAgB,WAAW,GAC7B,OAAO,aAAa,OAAO;EAE7B,OAAO,CAAC,GAAG,iBAAiB,GAAG,aAAa,OAAO,MAAM;CAC3D;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"statement-builders-Cd311EDF.mjs","names":["APP_SPACE_ID"],"sources":["../src/core/migrations/statement-builders.ts"],"sourcesContent":["import { APP_SPACE_ID } from '@prisma-next/framework-components/control';\n\nexport { APP_SPACE_ID };\n\nexport interface SqlStatement {\n readonly sql: string;\n readonly params: readonly unknown[];\n}\n\nexport const ensurePrismaContractSchemaStatement: SqlStatement = {\n sql: 'create schema if not exists prisma_contract',\n params: [],\n};\n\n/**\n * Schema for `prisma_contract.marker`. The `space text` primary key\n * supports one row per loaded contract space (`'app'`,\n * `'<extension-id>'`, …); on a brand-new database `CREATE TABLE IF NOT\n * EXISTS` produces this shape directly. The migration runner detects\n * pre-1.0 single-row markers (no `space` column) at boot and fails with\n * a structured `LEGACY_MARKER_SHAPE` error rather than auto-migrating —\n * see `specs/framework-mechanism.spec.md § 2`.\n */\nexport const ensureMarkerTableStatement: SqlStatement = {\n sql: `create table if not exists prisma_contract.marker (\n space text not null primary key default '${APP_SPACE_ID}',\n core_hash text not null,\n profile_hash text not null,\n contract_json jsonb,\n canonical_version int,\n updated_at timestamptz not null default now(),\n app_tag text,\n meta jsonb not null default '{}',\n invariants text[] not null default '{}'\n )`,\n params: [],\n};\n\nexport const ensureLedgerTableStatement: SqlStatement = {\n sql: `create table if not exists prisma_contract.ledger (\n id bigserial primary key,\n created_at timestamptz not null default now(),\n space text not null,\n migration_name text not null,\n migration_hash text not null,\n origin_core_hash text,\n origin_profile_hash text,\n destination_core_hash text not null,\n destination_profile_hash text,\n contract_json_before jsonb,\n contract_json_after jsonb,\n operations jsonb not null\n )`,\n params: [],\n};\n\nexport interface MergeMarkerInput {\n /**\n * Logical space identifier for this marker row. Required at every\n * call site so the type system surfaces every place that needs to\n * thread the value (rather than letting an `?? APP_SPACE_ID`\n * fall-through silently collapse per-space markers onto the\n * `'app'` row). App-plan callers pass {@link APP_SPACE_ID}\n * (`'app'`); per-extension callers (planner / runner / verifier\n * extensions over contract spaces) pass the extension's space id.\n */\n readonly space: string;\n readonly storageHash: string;\n readonly profileHash: string;\n readonly contractJson?: unknown;\n readonly canonicalVersion?: number | null;\n readonly appTag?: string | null;\n readonly meta?: Record<string, unknown>;\n /**\n * Invariants to merge into `marker.invariants`. INSERT writes them as\n * the initial value (callers are expected to pass a sorted, deduped\n * array). UPDATE merges them with the existing column server-side via\n * a single atomic SQL expression.\n */\n readonly invariants: readonly string[];\n}\n\nexport function buildMergeMarkerStatements(input: MergeMarkerInput): {\n readonly insert: SqlStatement;\n readonly update: SqlStatement;\n} {\n const params: readonly unknown[] = [\n input.space,\n input.storageHash,\n input.profileHash,\n jsonParam(input.contractJson),\n input.canonicalVersion ?? null,\n input.appTag ?? null,\n jsonParam(input.meta ?? {}),\n input.invariants,\n ];\n\n return {\n insert: {\n sql: `insert into prisma_contract.marker (\n space,\n core_hash,\n profile_hash,\n contract_json,\n canonical_version,\n updated_at,\n app_tag,\n meta,\n invariants\n ) values (\n $1,\n $2,\n $3,\n $4::jsonb,\n $5,\n now(),\n $6,\n $7::jsonb,\n $8::text[]\n )`,\n params,\n },\n update: {\n // `invariants = array(select distinct unnest(invariants || $8::text[]) order by 1)`\n // reads the current column value under the UPDATE's row lock, unions\n // with the incoming array, dedupes, and sorts ascending — single\n // statement, atomic, no read-then-write window.\n sql: `update prisma_contract.marker set\n core_hash = $2,\n profile_hash = $3,\n contract_json = $4::jsonb,\n canonical_version = $5,\n updated_at = now(),\n app_tag = $6,\n meta = $7::jsonb,\n invariants = array(select distinct unnest(invariants || $8::text[]) order by 1)\n where space = $1`,\n params,\n },\n };\n}\n\nexport interface LedgerInsertInput {\n readonly space: string;\n readonly migrationName: string;\n readonly migrationHash: string;\n readonly originStorageHash?: string | null;\n readonly originProfileHash?: string | null;\n readonly destinationStorageHash: string;\n readonly destinationProfileHash?: string | null;\n readonly contractJsonBefore?: unknown;\n readonly contractJsonAfter?: unknown;\n readonly operations: unknown;\n}\n\nexport function buildLedgerInsertStatement(input: LedgerInsertInput): SqlStatement {\n return {\n sql: `insert into prisma_contract.ledger (\n space,\n migration_name,\n migration_hash,\n origin_core_hash,\n origin_profile_hash,\n destination_core_hash,\n destination_profile_hash,\n contract_json_before,\n contract_json_after,\n operations\n ) values (\n $1,\n $2,\n $3,\n $4,\n $5,\n $6,\n $7,\n $8::jsonb,\n $9::jsonb,\n $10::jsonb\n )`,\n params: [\n input.space,\n input.migrationName,\n input.migrationHash,\n input.originStorageHash ?? null,\n input.originProfileHash ?? null,\n input.destinationStorageHash,\n input.destinationProfileHash ?? null,\n jsonParam(input.contractJsonBefore),\n jsonParam(input.contractJsonAfter),\n jsonParam(input.operations),\n ],\n };\n}\n\nfunction jsonParam(value: unknown): string {\n return JSON.stringify(value ?? null);\n}\n"],"mappings":";;AASA,MAAa,sCAAoD;CAC/D,KAAK;CACL,QAAQ,CAAC;AACX;;;;;;;;;;AAWA,MAAa,6BAA2C;CACtD,KAAK;+CACwCA,eAAa;;;;;;;;;;CAU1D,QAAQ,CAAC;AACX;AAEA,MAAa,6BAA2C;CACtD,KAAK;;;;;;;;;;;;;;CAcL,QAAQ,CAAC;AACX;AA4BA,SAAgB,2BAA2B,OAGzC;CACA,MAAM,SAA6B;EACjC,MAAM;EACN,MAAM;EACN,MAAM;EACN,UAAU,MAAM,YAAY;EAC5B,MAAM,oBAAoB;EAC1B,MAAM,UAAU;EAChB,UAAU,MAAM,QAAQ,CAAC,CAAC;EAC1B,MAAM;CACR;CAEA,OAAO;EACL,QAAQ;GACN,KAAK;;;;;;;;;;;;;;;;;;;;;GAqBL;EACF;EACA,QAAQ;GAKN,KAAK;;;;;;;;;;GAUL;EACF;CACF;AACF;AAeA,SAAgB,2BAA2B,OAAwC;CACjF,OAAO;EACL,KAAK;;;;;;;;;;;;;;;;;;;;;;;EAuBL,QAAQ;GACN,MAAM;GACN,MAAM;GACN,MAAM;GACN,MAAM,qBAAqB;GAC3B,MAAM,qBAAqB;GAC3B,MAAM;GACN,MAAM,0BAA0B;GAChC,UAAU,MAAM,kBAAkB;GAClC,UAAU,MAAM,iBAAiB;GACjC,UAAU,MAAM,UAAU;EAC5B;CACF;AACF;AAEA,SAAS,UAAU,OAAwB;CACzC,OAAO,KAAK,UAAU,SAAS,IAAI;AACrC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types-DncetAjv.d.mts","names":[],"sources":["../src/core/types.ts"],"mappings":";;;KAEY,qBAAA,GACR,aAAa;EAAA,SACF,IAAA;EAAA,SAA2B,IAAA;AAAA"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { APP_SPACE_ID } from '@prisma-next/framework-components/control';
|
|
2
|
-
import type { DdlNode } from '@prisma-next/sql-relational-core/ast';
|
|
3
|
-
import { col, fn, lit } from '@prisma-next/sql-relational-core/contract-free';
|
|
4
|
-
import { createSchema, createTable } from './ddl';
|
|
5
|
-
|
|
6
|
-
const markerColumns = [
|
|
7
|
-
col('space', 'text', { notNull: true, primaryKey: true, default: lit(APP_SPACE_ID) }),
|
|
8
|
-
col('core_hash', 'text', { notNull: true }),
|
|
9
|
-
col('profile_hash', 'text', { notNull: true }),
|
|
10
|
-
col('contract_json', 'jsonb'),
|
|
11
|
-
col('canonical_version', 'int'),
|
|
12
|
-
col('updated_at', 'timestamptz', { notNull: true, default: fn('now()') }),
|
|
13
|
-
col('app_tag', 'text'),
|
|
14
|
-
col('meta', 'jsonb', { notNull: true, default: lit('{}') }),
|
|
15
|
-
col('invariants', 'text[]', { notNull: true, default: lit('{}') }),
|
|
16
|
-
] as const;
|
|
17
|
-
|
|
18
|
-
const ledgerColumns = [
|
|
19
|
-
col('id', 'bigserial', { primaryKey: true }),
|
|
20
|
-
col('created_at', 'timestamptz', { notNull: true, default: fn('now()') }),
|
|
21
|
-
col('space', 'text', { notNull: true }),
|
|
22
|
-
col('migration_name', 'text', { notNull: true }),
|
|
23
|
-
col('migration_hash', 'text', { notNull: true }),
|
|
24
|
-
col('origin_core_hash', 'text'),
|
|
25
|
-
col('origin_profile_hash', 'text'),
|
|
26
|
-
col('destination_core_hash', 'text', { notNull: true }),
|
|
27
|
-
col('destination_profile_hash', 'text'),
|
|
28
|
-
col('contract_json_before', 'jsonb'),
|
|
29
|
-
col('contract_json_after', 'jsonb'),
|
|
30
|
-
col('operations', 'jsonb', { notNull: true }),
|
|
31
|
-
] as const;
|
|
32
|
-
|
|
33
|
-
const markerTable = createTable({
|
|
34
|
-
schema: 'prisma_contract',
|
|
35
|
-
table: 'marker',
|
|
36
|
-
ifNotExists: true,
|
|
37
|
-
columns: markerColumns,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const ledgerTable = createTable({
|
|
41
|
-
schema: 'prisma_contract',
|
|
42
|
-
table: 'ledger',
|
|
43
|
-
ifNotExists: true,
|
|
44
|
-
columns: ledgerColumns,
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
const controlSchema = createSchema({ schema: 'prisma_contract', ifNotExists: true });
|
|
48
|
-
|
|
49
|
-
export function buildSignMarkerBootstrapQueries(): readonly DdlNode[] {
|
|
50
|
-
return [controlSchema, markerTable];
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export function buildControlTableBootstrapQueries(): readonly DdlNode[] {
|
|
54
|
-
return [controlSchema, markerTable, ledgerTable];
|
|
55
|
-
}
|
package/src/contract-free/ddl.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { DdlColumn } from '@prisma-next/sql-relational-core/ast';
|
|
2
|
-
import { PostgresCreateSchema, PostgresCreateTable } from '../core/ddl/nodes';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Build a Postgres `CREATE TABLE` query node.
|
|
6
|
-
*
|
|
7
|
-
* Precondition: identifiers (`table`, `schema`, column names/types) are
|
|
8
|
-
* emitted to SQL verbatim — they are not quoted or escaped, so callers must
|
|
9
|
-
* pass pre-trusted values (e.g. fixed control-plane identifiers). String-literal
|
|
10
|
-
* default values, by contrast, are single-quote-escaped (embedded `'` doubled)
|
|
11
|
-
* by the renderer. Identifier quoting for untrusted identifiers is added when
|
|
12
|
-
* the migration planner adopts this lowering path.
|
|
13
|
-
*/
|
|
14
|
-
export function createTable(options: {
|
|
15
|
-
readonly table: string;
|
|
16
|
-
readonly schema?: string;
|
|
17
|
-
readonly ifNotExists?: boolean;
|
|
18
|
-
readonly columns: readonly DdlColumn[];
|
|
19
|
-
}): PostgresCreateTable {
|
|
20
|
-
return new PostgresCreateTable(options);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Build a Postgres `CREATE SCHEMA` query node. See {@link createTable} for the
|
|
25
|
-
* pre-trusted-identifier precondition.
|
|
26
|
-
*/
|
|
27
|
-
export function createSchema(options: {
|
|
28
|
-
readonly schema: string;
|
|
29
|
-
readonly ifNotExists?: boolean;
|
|
30
|
-
}): PostgresCreateSchema {
|
|
31
|
-
return new PostgresCreateSchema(options);
|
|
32
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
const EXPLICIT_COMPATIBLE_TYPE_PAIRS: ReadonlyArray<readonly [string, string]> = [];
|
|
2
|
-
|
|
3
|
-
export function postgresColumnsCompatible(declared: string, live: string): boolean {
|
|
4
|
-
if (declared === live) {
|
|
5
|
-
return true;
|
|
6
|
-
}
|
|
7
|
-
for (const [a, b] of EXPLICIT_COMPATIBLE_TYPE_PAIRS) {
|
|
8
|
-
if ((declared === a && live === b) || (declared === b && live === a)) {
|
|
9
|
-
return true;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
return false;
|
|
13
|
-
}
|
package/src/core/ddl/nodes.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { type DdlColumn, DdlNode } from '@prisma-next/sql-relational-core/ast';
|
|
2
|
-
|
|
3
|
-
export interface PostgresDdlVisitor<R> {
|
|
4
|
-
createTable(node: PostgresCreateTable): R;
|
|
5
|
-
createSchema(node: PostgresCreateSchema): R;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export abstract class PostgresDdlNode extends DdlNode {
|
|
9
|
-
abstract accept<R>(visitor: PostgresDdlVisitor<R>): R;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function freezeDdlColumns(columns: readonly DdlColumn[]): ReadonlyArray<DdlColumn> {
|
|
13
|
-
return Object.freeze([...columns]);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export class PostgresCreateTable extends PostgresDdlNode {
|
|
17
|
-
readonly kind = 'create-table' as const;
|
|
18
|
-
readonly table: string;
|
|
19
|
-
readonly schema: string | undefined;
|
|
20
|
-
readonly ifNotExists: boolean | undefined;
|
|
21
|
-
readonly columns: ReadonlyArray<DdlColumn>;
|
|
22
|
-
|
|
23
|
-
constructor(options: {
|
|
24
|
-
readonly table: string;
|
|
25
|
-
readonly schema?: string;
|
|
26
|
-
readonly ifNotExists?: boolean;
|
|
27
|
-
readonly columns: readonly DdlColumn[];
|
|
28
|
-
}) {
|
|
29
|
-
super();
|
|
30
|
-
this.table = options.table;
|
|
31
|
-
this.schema = options.schema;
|
|
32
|
-
this.ifNotExists = options.ifNotExists;
|
|
33
|
-
this.columns = freezeDdlColumns(options.columns);
|
|
34
|
-
this.freeze();
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
override accept<R>(visitor: PostgresDdlVisitor<R>): R {
|
|
38
|
-
return visitor.createTable(this);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export class PostgresCreateSchema extends PostgresDdlNode {
|
|
43
|
-
readonly kind = 'create-schema' as const;
|
|
44
|
-
readonly schema: string;
|
|
45
|
-
readonly ifNotExists: boolean | undefined;
|
|
46
|
-
|
|
47
|
-
constructor(options: { readonly schema: string; readonly ifNotExists?: boolean }) {
|
|
48
|
-
super();
|
|
49
|
-
this.schema = options.schema;
|
|
50
|
-
this.ifNotExists = options.ifNotExists;
|
|
51
|
-
this.freeze();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
override accept<R>(visitor: PostgresDdlVisitor<R>): R {
|
|
55
|
-
return visitor.createSchema(this);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export type AnyPostgresDdlNode = PostgresCreateTable | PostgresCreateSchema;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { postgresColumnsCompatible } from '../core/column-type-compatibility';
|