@prisma-next/target-postgres 0.12.0-dev.16 → 0.12.0-dev.2
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-Ocb2dZ9O.d.mts → codec-ids-DliyCWPY.d.mts} +1 -1
- package/dist/{codec-ids-Ocb2dZ9O.d.mts.map → codec-ids-DliyCWPY.d.mts.map} +1 -1
- package/dist/codec-ids.d.mts +1 -1
- package/dist/{codec-types-CJHFnwDh.d.mts → codec-types-BF1DXTPs.d.mts} +2 -2
- package/dist/{codec-types-CJHFnwDh.d.mts.map → codec-types-BF1DXTPs.d.mts.map} +1 -1
- package/dist/codec-types.d.mts +1 -1
- package/dist/{codecs-CrKVVQjP.d.mts → codecs-DuP3d9Au.d.mts} +2 -2
- package/dist/{codecs-CrKVVQjP.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 +23 -41
- package/dist/control.mjs.map +1 -1
- package/dist/{data-transform-5gLOgP68.d.mts → data-transform-CAPmAdxS.d.mts} +2 -2
- package/dist/{data-transform-5gLOgP68.d.mts.map → data-transform-CAPmAdxS.d.mts.map} +1 -1
- package/dist/data-transform.d.mts +1 -1
- package/dist/{descriptor-meta-C_03xPpF.mjs → descriptor-meta-Dvr_77Z3.mjs} +2 -3
- package/dist/descriptor-meta-Dvr_77Z3.mjs.map +1 -0
- package/dist/{descriptor-meta-runtime-DMRX39kp.mjs → descriptor-meta-runtime-ByjztWgs.mjs} +2 -2
- package/dist/{descriptor-meta-runtime-DMRX39kp.mjs.map → descriptor-meta-runtime-ByjztWgs.mjs.map} +1 -1
- package/dist/{enum-planning-DRA9LaMU.mjs → enum-planning-DrNWCtCp.mjs} +0 -0
- package/dist/{enum-planning-DRA9LaMU.mjs.map → enum-planning-DrNWCtCp.mjs.map} +1 -1
- package/dist/enum-planning.d.mts +1 -1
- package/dist/enum-planning.mjs +1 -1
- package/dist/{issue-planner-BtaL6OfW.mjs → issue-planner-2RgYsjUJ.mjs} +7 -7
- package/dist/{issue-planner-BtaL6OfW.mjs.map → issue-planner-2RgYsjUJ.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 +1 -1
- package/dist/{op-factory-call-B-HEOf41.d.mts → op-factory-call-CDlImOF_.d.mts} +3 -3
- package/dist/{op-factory-call-B-HEOf41.d.mts.map → op-factory-call-CDlImOF_.d.mts.map} +1 -1
- package/dist/{op-factory-call-ewOd5q6L.mjs → op-factory-call-C_K5ibAY.mjs} +2 -2
- package/dist/{op-factory-call-ewOd5q6L.mjs.map → op-factory-call-C_K5ibAY.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 -4
- package/dist/pack.d.mts.map +1 -1
- package/dist/pack.mjs +1 -1
- package/dist/{planner-Bjz5pnLa.mjs → planner-CC3r_uNJ.mjs} +4 -4
- package/dist/{planner-Bjz5pnLa.mjs.map → planner-CC3r_uNJ.mjs.map} +1 -1
- package/dist/{planner-ddl-builders-BNMfSE9r.mjs → planner-ddl-builders-DgyqpFji.mjs} +2 -2
- package/dist/{planner-ddl-builders-BNMfSE9r.mjs.map → planner-ddl-builders-DgyqpFji.mjs.map} +1 -1
- package/dist/planner-ddl-builders.d.mts +1 -1
- package/dist/planner-ddl-builders.mjs +1 -1
- package/dist/{planner-produced-postgres-migration-Co71_VbU.d.mts → planner-produced-postgres-migration-D02NOhVQ.d.mts} +3 -3
- package/dist/{planner-produced-postgres-migration-Co71_VbU.d.mts.map → planner-produced-postgres-migration-D02NOhVQ.d.mts.map} +1 -1
- package/dist/planner-produced-postgres-migration.d.mts +1 -1
- package/dist/{planner-sql-checks-CfEiTXoQ.mjs → planner-sql-checks-BMu3fiMc.mjs} +2 -2
- package/dist/{planner-sql-checks-CfEiTXoQ.mjs.map → planner-sql-checks-BMu3fiMc.mjs.map} +1 -1
- package/dist/planner-sql-checks.mjs +1 -1
- package/dist/{planner-target-details-Dv5N6x6k.d.mts → planner-target-details-a_wuOiYf.d.mts} +1 -1
- package/dist/{planner-target-details-Dv5N6x6k.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.mjs +1 -1
- package/dist/{postgres-contract-serializer-BnOboPWs.mjs → postgres-contract-serializer-C0UtIDB8.mjs} +3 -3
- package/dist/{postgres-contract-serializer-BnOboPWs.mjs.map → postgres-contract-serializer-C0UtIDB8.mjs.map} +1 -1
- package/dist/{postgres-enum-type-CWwVGBNK.d.mts → postgres-enum-type-5MBoKsIj.d.mts} +1 -4
- package/dist/postgres-enum-type-5MBoKsIj.d.mts.map +1 -0
- package/dist/{postgres-enum-type-BMgyxNyy.mjs → postgres-enum-type-DS-KLVRH.mjs} +1 -2
- package/dist/postgres-enum-type-DS-KLVRH.mjs.map +1 -0
- package/dist/{postgres-migration-BcKS2Lqq.d.mts → postgres-migration-DRY8V-bQ.d.mts} +3 -3
- package/dist/{postgres-migration-BcKS2Lqq.d.mts.map → postgres-migration-DRY8V-bQ.d.mts.map} +1 -1
- package/dist/{postgres-schema-BxAuNFX0.mjs → postgres-schema-vp5rvbYg.mjs} +2 -2
- package/dist/{postgres-schema-BxAuNFX0.mjs.map → postgres-schema-vp5rvbYg.mjs.map} +1 -1
- package/dist/render-ops.d.mts +1 -1
- package/dist/runtime.mjs +2 -2
- package/dist/{shared-CMqM-2BA.d.mts → shared-Do_a5ymU.d.mts} +2 -2
- package/dist/{shared-CMqM-2BA.d.mts.map → shared-Do_a5ymU.d.mts.map} +1 -1
- package/dist/{statement-builders-DgYQooDR.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-DoA39Yqo.mjs → tables-C8RrPLUq.mjs} +2 -2
- package/dist/{tables-DoA39Yqo.mjs.map → tables-C8RrPLUq.mjs.map} +1 -1
- package/dist/{types-kggVJs6C.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 -19
- package/src/core/descriptor-meta.ts +0 -1
- package/src/core/migrations/runner.ts +27 -64
- package/src/core/migrations/statement-builders.ts +3 -18
- package/src/core/postgres-enum-type.ts +0 -4
- 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-C_03xPpF.mjs.map +0 -1
- package/dist/nodes-DCC8-DhV.mjs +0 -42
- package/dist/nodes-DCC8-DhV.mjs.map +0 -1
- package/dist/nodes-DflxwrE8.d.mts +0 -38
- package/dist/nodes-DflxwrE8.d.mts.map +0 -1
- package/dist/postgres-enum-type-BMgyxNyy.mjs.map +0 -1
- package/dist/postgres-enum-type-CWwVGBNK.d.mts.map +0 -1
- package/dist/statement-builders-DgYQooDR.mjs.map +0 -1
- package/dist/types-kggVJs6C.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/ddl/nodes.ts +0 -59
- package/src/exports/contract-free.ts +0 -5
- package/src/exports/ddl.ts +0 -7
package/dist/contract-free.mjs
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { n as PostgresCreateTable, t as PostgresCreateSchema } from "./nodes-DCC8-DhV.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-DflxwrE8.mjs";
|
|
2
|
-
export { type AnyPostgresDdlNode, PostgresCreateSchema, PostgresCreateTable, PostgresDdlNode, type PostgresDdlVisitor };
|
package/dist/ddl.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"descriptor-meta-C_03xPpF.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"}
|
package/dist/nodes-DCC8-DhV.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-DCC8-DhV.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nodes-DCC8-DhV.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,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-DflxwrE8.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nodes-DflxwrE8.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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-enum-type-BMgyxNyy.mjs","names":[],"sources":["../src/core/postgres-enum-type.ts"],"sourcesContent":["import type { ControlPolicy } from '@prisma-next/contract/types';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from '@prisma-next/sql-contract/types';\n\nexport interface PostgresEnumTypeInput<\n TName extends string = string,\n TValues extends readonly string[] = readonly string[],\n> {\n /**\n * Contract-level enum name (e.g. `'Role'`). Used as the key in\n * `SqlStorage.types` and as the contract-facing identifier in\n * planner / verifier diagnostics.\n */\n readonly name: TName;\n /**\n * Postgres-side native type name created by `CREATE TYPE … AS ENUM`.\n * Defaults to `name` when not overridden via PSL `@map(...)` or the\n * TS authoring surface.\n */\n readonly nativeType?: string;\n readonly values: TValues;\n readonly control?: ControlPolicy;\n}\n\n/** Codec id used by Postgres enum-typed columns (text wire format). */\nconst PG_ENUM_CODEC_ID = 'pg/enum@1';\n\n/**\n * Postgres IR class for the `CREATE TYPE … AS ENUM` concept.\n *\n * Per Decision 18, enum is a target-only concept (Postgres alone today;\n * SQLite emulates via CHECK constraints). There is no family-layer\n * enum abstract — the abstract-earns-existence rule keeps the IR class\n * hierarchy minimal: this class extends `SqlNode` directly and is the\n * single concrete representation of the polymorphic `'postgres-enum'`\n * slot variant.\n *\n * Carries Postgres-specific resolution (`nativeType` defaults to\n * `name`; `values` is frozen at construction time). Constructor calls\n * `freezeNode(this)` per Decision 8 — the instance is fully immutable,\n * JSON-clean, and dispatchable on its enumerable `kind: 'postgres-enum'`\n * literal.\n *\n * The family-layer slot dispatch (verifier, planner, lowering, etc.)\n * narrows polymorphic `StorageType` entries via the `kind` literal\n * (e.g. `isPostgresEnumStorageEntry`) — SQL-domain code must not import\n * `target-postgres` directly (cross-domain layering rule). The\n * structural interface lives at the family layer for that purpose;\n * this class is the runtime concrete that satisfies it.\n */\nexport class PostgresEnumType<\n TName extends string = string,\n TValues extends readonly string[] = readonly string[],\n> extends SqlNode {\n override readonly kind = 'postgres-enum' as const;\n readonly name: TName;\n readonly nativeType: string;\n readonly values: TValues;\n /**\n * Enumerable own property so the persisted JSON envelope carries\n * `codecId: 'pg/enum@1'` alongside `kind: 'postgres-enum'`. The\n * runtime path (`codecRefForStorageColumn`, `assertColumnCodecIntegrity`)\n * receives JSON-shaped contracts (e.g. inside a user-written\n * `migration.ts` that loads `endContract` from `end-contract.json`)\n * and reads `codecId` directly from the envelope rather than\n * dispatching through the prototype-only `codecBinding` accessor.\n */\n readonly codecId: typeof PG_ENUM_CODEC_ID = PG_ENUM_CODEC_ID;\n declare readonly control?: ControlPolicy;\n\n constructor(input: PostgresEnumTypeInput<TName, TValues>) {\n super();\n this.name = input.name;\n this.nativeType = input.nativeType ?? input.name;\n // `Object.freeze` returns `Readonly<string[]>`, widening past the\n // `TValues` literal tuple. Cast preserves the caller-supplied\n // tuple shape so inferred contract types retain literal narrowing.\n this.values = Object.freeze([...input.values] as unknown as TValues);\n if (input.control !== undefined) this.control = input.control;\n freezeNode(this);\n }\n\n get codecBinding(): {\n readonly codecId: typeof PG_ENUM_CODEC_ID;\n readonly typeParams: { readonly values: TValues };\n } {\n return { codecId: PG_ENUM_CODEC_ID, typeParams: { values: this.values } };\n }\n}\n"],"mappings":";;;;AAyBA,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;AAyBzB,IAAa,mBAAb,cAGU,QAAQ;CAChB,OAAyB;CACzB;CACA;CACA;;;;;;;;;;CAUA,UAA4C;CAG5C,YAAY,OAA8C;EACxD,MAAM;EACN,KAAK,OAAO,MAAM;EAClB,KAAK,aAAa,MAAM,cAAc,MAAM;EAI5C,KAAK,SAAS,OAAO,OAAO,CAAC,GAAG,MAAM,MAAM,CAAuB;EACnE,IAAI,MAAM,YAAY,KAAA,GAAW,KAAK,UAAU,MAAM;EACtD,WAAW,IAAI;CACjB;CAEA,IAAI,eAGF;EACA,OAAO;GAAE,SAAS;GAAkB,YAAY,EAAE,QAAQ,KAAK,OAAO;EAAE;CAC1E;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-enum-type-CWwVGBNK.d.mts","names":[],"sources":["../src/core/postgres-enum-type.ts"],"mappings":";;;;UAIiB,qBAAA;;AAAjB;;;;WASW,IAAA,EAAM,KAAA;EAQI;;;;;EAAA,SAFV,UAAA;EAAA,SACA,MAAA,EAAQ,OAAA;EAAA,SACR,OAAA,GAAU,aAAA;AAAA;;cAIf,gBAAA;;;AAJ4B;AACjC;;;;AAGqB;AAyBtB;;;;;;;;;;;;;;;cAAa,gBAAA,+FAGH,OAAA;EAAA,SACU,IAAA;EAAA,SACT,IAAA,EAAM,KAAA;EAAA,SACN,UAAA;EAAA,SACA,MAAA,EAAQ,OAAA;EAFF;;;;;;;;;EAAA,SAYN,OAAA,SAAgB,gBAAA;EAAA,SACR,OAAA,GAAU,aAAA;cAEf,KAAA,EAAO,qBAAA,CAAsB,KAAA,EAAO,OAAA;EAAA,IAY5C,YAAA,CAAA;IAAA,SACO,OAAA,SAAgB,gBAAA;IAAA,SAChB,UAAA;MAAA,SAAuB,MAAA,EAAQ,OAAA;IAAA;EAAA;AAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"statement-builders-DgYQooDR.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-kggVJs6C.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
|
-
}
|
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;
|