@prisma-next/target-postgres 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{codec-ids-CTikp1if.mjs → codec-ids-BvytN2P8.mjs} +3 -3
- package/dist/codec-ids-BvytN2P8.mjs.map +1 -0
- package/dist/{codec-ids-B1vOchLE.d.mts → codec-ids-CnXu9Qy3.d.mts} +3 -3
- package/dist/codec-ids-CnXu9Qy3.d.mts.map +1 -0
- package/dist/codec-ids.d.mts +2 -2
- package/dist/codec-ids.mjs +2 -2
- package/dist/{codec-types-CnFiNML4.d.mts → codec-types-DHCkwPKE.d.mts} +3 -3
- package/dist/{codec-types-CnFiNML4.d.mts.map → codec-types-DHCkwPKE.d.mts.map} +1 -1
- package/dist/codec-types.d.mts +1 -1
- package/dist/{codecs-CBpEv4s5.d.mts → codecs--0A5_4Bq.d.mts} +26 -23
- package/dist/codecs--0A5_4Bq.d.mts.map +1 -0
- package/dist/codecs.d.mts +2 -2
- package/dist/codecs.mjs +28 -35
- package/dist/codecs.mjs.map +1 -1
- package/dist/contract-free.d.mts +163 -15
- package/dist/contract-free.d.mts.map +1 -1
- package/dist/contract-free.mjs +4 -17
- package/dist/contract-free.mjs.map +1 -1
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +21 -27
- package/dist/control.mjs.map +1 -1
- package/dist/{data-transform-D25tLeYU.mjs → data-transform-BOWpliq8.mjs} +9 -17
- package/dist/data-transform-BOWpliq8.mjs.map +1 -0
- package/dist/{data-transform-DGOqcLrf.d.mts → data-transform-DDgWdB5o.d.mts} +2 -2
- package/dist/data-transform-DDgWdB5o.d.mts.map +1 -0
- package/dist/data-transform.d.mts +1 -1
- package/dist/data-transform.mjs +1 -1
- package/dist/ddl-QDyOSeLc.mjs +251 -0
- package/dist/ddl-QDyOSeLc.mjs.map +1 -0
- package/dist/ddl.d.mts +2 -2
- package/dist/ddl.mjs +2 -2
- package/dist/descriptor-meta-CpGygXpI.mjs +140 -0
- package/dist/descriptor-meta-CpGygXpI.mjs.map +1 -0
- package/dist/{issue-planner-Br0pt1Ea.mjs → issue-planner-DL6g3CmE.mjs} +52 -366
- package/dist/issue-planner-DL6g3CmE.mjs.map +1 -0
- package/dist/issue-planner.d.mts +8 -11
- package/dist/issue-planner.d.mts.map +1 -1
- package/dist/issue-planner.mjs +1 -1
- package/dist/migration.d.mts +5 -92
- package/dist/migration.d.mts.map +1 -1
- package/dist/migration.mjs +4 -4
- package/dist/{nodes-DZk2JZG3.mjs → nodes-Bbhs2rwj.mjs} +31 -2
- package/dist/nodes-Bbhs2rwj.mjs.map +1 -0
- package/dist/{nodes-779hmCfL.d.mts → nodes-pLeLgdis.d.mts} +30 -3
- package/dist/nodes-pLeLgdis.d.mts.map +1 -0
- package/dist/{op-factory-call-D2aAUhmS.mjs → op-factory-call-D_p5vxwt.mjs} +601 -418
- package/dist/op-factory-call-D_p5vxwt.mjs.map +1 -0
- package/dist/{op-factory-call-DMA86_2D.d.mts → op-factory-call-DmQEc3XV.d.mts} +119 -72
- package/dist/op-factory-call-DmQEc3XV.d.mts.map +1 -0
- package/dist/op-factory-call.d.mts +2 -2
- package/dist/op-factory-call.mjs +2 -2
- package/dist/pack.d.mts +36 -15
- package/dist/pack.d.mts.map +1 -1
- package/dist/pack.mjs +1 -1
- package/dist/{planner-CAYPJObw.mjs → planner-Bs_baQax.mjs} +25 -45
- package/dist/planner-Bs_baQax.mjs.map +1 -0
- package/dist/{planner-ddl-builders-Cw2n2llW.mjs → planner-ddl-builders-B2wOwLqI.mjs} +2 -2
- package/dist/planner-ddl-builders-B2wOwLqI.mjs.map +1 -0
- package/dist/planner-ddl-builders.d.mts +4 -4
- package/dist/planner-ddl-builders.d.mts.map +1 -1
- package/dist/planner-ddl-builders.mjs +1 -1
- package/dist/{planner-identity-values-BIpa5p2I.mjs → planner-identity-values-CJPha2Sz.mjs} +3 -9
- package/dist/planner-identity-values-CJPha2Sz.mjs.map +1 -0
- package/dist/planner-identity-values.d.mts +1 -1
- package/dist/planner-identity-values.d.mts.map +1 -1
- package/dist/planner-identity-values.mjs +1 -1
- package/dist/{planner-produced-postgres-migration-NSEhWL0L.mjs → planner-produced-postgres-migration-Cji5vxUf.mjs} +6 -4
- package/dist/planner-produced-postgres-migration-Cji5vxUf.mjs.map +1 -0
- package/dist/{planner-produced-postgres-migration-B4EDvLdz.d.mts → planner-produced-postgres-migration-QqHa2C2l.d.mts} +5 -6
- package/dist/planner-produced-postgres-migration-QqHa2C2l.d.mts.map +1 -0
- package/dist/planner-produced-postgres-migration.d.mts +1 -1
- package/dist/planner-produced-postgres-migration.mjs +1 -1
- package/dist/planner-sql-checks-jqUUGyQR.mjs +152 -0
- package/dist/planner-sql-checks-jqUUGyQR.mjs.map +1 -0
- package/dist/planner-sql-checks.d.mts +3 -49
- package/dist/planner-sql-checks.d.mts.map +1 -1
- package/dist/planner-sql-checks.mjs +2 -2
- package/dist/{planner-type-resolution-836DExFN.mjs → planner-type-resolution-Bt2f_q-F.mjs} +1 -6
- package/dist/planner-type-resolution-Bt2f_q-F.mjs.map +1 -0
- package/dist/planner.d.mts +4 -4
- package/dist/planner.d.mts.map +1 -1
- package/dist/planner.mjs +1 -1
- package/dist/{postgres-contract-serializer-DYTyXjPf.mjs → postgres-contract-serializer-k3TAcPMY.mjs} +30 -37
- package/dist/postgres-contract-serializer-k3TAcPMY.mjs.map +1 -0
- package/dist/postgres-migration-B5jKrXv3.mjs +145 -0
- package/dist/postgres-migration-B5jKrXv3.mjs.map +1 -0
- package/dist/postgres-migration-Y4YBJqkS.d.mts +181 -0
- package/dist/postgres-migration-Y4YBJqkS.d.mts.map +1 -0
- package/dist/{postgres-schema-BuxCxbvB.mjs → postgres-schema-COGZ1ark.mjs} +82 -23
- package/dist/postgres-schema-COGZ1ark.mjs.map +1 -0
- package/dist/{render-ops-BpjstrKQ.mjs → render-ops-BREh1kHe.mjs} +10 -5
- package/dist/render-ops-BREh1kHe.mjs.map +1 -0
- package/dist/render-ops.d.mts +2 -2
- package/dist/render-ops.d.mts.map +1 -1
- package/dist/render-ops.mjs +1 -1
- package/dist/runtime.d.mts +1 -0
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +2 -2
- package/dist/table-source-BvFo7gVs.d.mts +15 -0
- package/dist/table-source-BvFo7gVs.d.mts.map +1 -0
- package/dist/types.d.mts +34 -19
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +2 -3
- package/package.json +17 -18
- package/src/contract-free/checks.ts +363 -0
- package/src/contract-free/ddl.ts +28 -1
- package/src/core/authoring.ts +43 -44
- package/src/core/codec-helpers.ts +0 -17
- package/src/core/codec-ids.ts +1 -1
- package/src/core/codec-type-map.ts +2 -2
- package/src/core/codecs.ts +43 -48
- package/src/core/ddl/nodes.ts +59 -1
- package/src/core/migrations/control-policy.ts +17 -47
- package/src/core/migrations/issue-planner.ts +34 -70
- package/src/core/migrations/op-factory-call.ts +486 -215
- package/src/core/migrations/operations/columns.ts +175 -140
- package/src/core/migrations/operations/constraints.ts +79 -108
- package/src/core/migrations/operations/data-transform.ts +15 -18
- package/src/core/migrations/operations/dependencies.ts +16 -14
- package/src/core/migrations/operations/indexes.ts +31 -28
- package/src/core/migrations/operations/shared.ts +2 -2
- package/src/core/migrations/operations/tables.ts +13 -14
- package/src/core/migrations/planner-ddl-builders.ts +3 -4
- package/src/core/migrations/planner-identity-values.ts +4 -28
- package/src/core/migrations/planner-produced-postgres-migration.ts +15 -7
- package/src/core/migrations/planner-recipes.ts +44 -39
- package/src/core/migrations/planner-sql-checks.ts +3 -178
- package/src/core/migrations/planner-strategies.ts +76 -449
- package/src/core/migrations/planner-type-resolution.ts +2 -20
- package/src/core/migrations/planner.ts +6 -6
- package/src/core/migrations/postgres-migration.ts +287 -7
- package/src/core/migrations/render-ops.ts +26 -13
- package/src/core/migrations/runner.ts +26 -20
- package/src/core/postgres-contract-serializer.ts +37 -54
- package/src/core/postgres-enum-type-schema.ts +17 -0
- package/src/core/postgres-schema.ts +86 -46
- package/src/exports/codecs.ts +2 -2
- package/src/exports/contract-free.ts +22 -1
- package/src/exports/control.ts +0 -22
- package/src/exports/ddl.ts +4 -0
- package/src/exports/migration.ts +1 -29
- package/src/exports/op-factory-call.ts +0 -4
- package/src/exports/planner-sql-checks.ts +0 -7
- package/src/exports/types.ts +0 -1
- package/dist/codec-ids-B1vOchLE.d.mts.map +0 -1
- package/dist/codec-ids-CTikp1if.mjs.map +0 -1
- package/dist/codecs-CBpEv4s5.d.mts.map +0 -1
- package/dist/data-transform-D25tLeYU.mjs.map +0 -1
- package/dist/data-transform-DGOqcLrf.d.mts.map +0 -1
- package/dist/ddl-77SyXgFt.mjs +0 -30
- package/dist/ddl-77SyXgFt.mjs.map +0 -1
- package/dist/descriptor-meta-DKmj-IMN.mjs +0 -14
- package/dist/descriptor-meta-DKmj-IMN.mjs.map +0 -1
- package/dist/descriptor-meta-runtime-My8_s4cs.mjs +0 -130
- package/dist/descriptor-meta-runtime-My8_s4cs.mjs.map +0 -1
- package/dist/enum-planning-BCyvlFHk.mjs +0 -0
- package/dist/enum-planning-BCyvlFHk.mjs.map +0 -1
- package/dist/enum-planning.d.mts +0 -86
- package/dist/enum-planning.d.mts.map +0 -1
- package/dist/enum-planning.mjs +0 -2
- package/dist/issue-planner-Br0pt1Ea.mjs.map +0 -1
- package/dist/nodes-779hmCfL.d.mts.map +0 -1
- package/dist/nodes-DZk2JZG3.mjs.map +0 -1
- package/dist/op-factory-call-D2aAUhmS.mjs.map +0 -1
- package/dist/op-factory-call-DMA86_2D.d.mts.map +0 -1
- package/dist/planner-CAYPJObw.mjs.map +0 -1
- package/dist/planner-ddl-builders-Cw2n2llW.mjs.map +0 -1
- package/dist/planner-identity-values-BIpa5p2I.mjs.map +0 -1
- package/dist/planner-produced-postgres-migration-B4EDvLdz.d.mts.map +0 -1
- package/dist/planner-produced-postgres-migration-NSEhWL0L.mjs.map +0 -1
- package/dist/planner-sql-checks-DAdhnI2c.mjs +0 -272
- package/dist/planner-sql-checks-DAdhnI2c.mjs.map +0 -1
- package/dist/planner-type-resolution-836DExFN.mjs.map +0 -1
- package/dist/postgres-contract-serializer-DYTyXjPf.mjs.map +0 -1
- package/dist/postgres-enum-type-BVn63a89.d.mts +0 -72
- package/dist/postgres-enum-type-BVn63a89.d.mts.map +0 -1
- package/dist/postgres-enum-type-DPKqCBem.mjs +0 -62
- package/dist/postgres-enum-type-DPKqCBem.mjs.map +0 -1
- package/dist/postgres-migration-COore9Mz.mjs +0 -71
- package/dist/postgres-migration-COore9Mz.mjs.map +0 -1
- package/dist/postgres-migration-DZ_gLUOW.d.mts +0 -72
- package/dist/postgres-migration-DZ_gLUOW.d.mts.map +0 -1
- package/dist/postgres-schema-BuxCxbvB.mjs.map +0 -1
- package/dist/render-ops-BpjstrKQ.mjs.map +0 -1
- package/dist/shared-DarONYBZ.d.mts +0 -43
- package/dist/shared-DarONYBZ.d.mts.map +0 -1
- package/src/core/migrations/enum-planning.ts +0 -213
- package/src/core/migrations/operations/enums.ts +0 -114
- package/src/core/postgres-enum-type.ts +0 -89
- package/src/exports/enum-planning.ts +0 -11
package/dist/{postgres-contract-serializer-DYTyXjPf.mjs → postgres-contract-serializer-k3TAcPMY.mjs}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { r as isPostgresSchema, t as PostgresSchema } from "./postgres-schema-
|
|
3
|
-
import { NamespaceBase, UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir";
|
|
1
|
+
import { r as postgresAuthoringEntityTypes, t as postgresTargetDescriptorMeta } from "./descriptor-meta-CpGygXpI.mjs";
|
|
2
|
+
import { r as isPostgresSchema, t as PostgresSchema } from "./postgres-schema-COGZ1ark.mjs";
|
|
4
3
|
import { blindCast } from "@prisma-next/utils/casts";
|
|
4
|
+
import { NamespaceBase, UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir";
|
|
5
5
|
import { SqlContractSerializerBase } from "@prisma-next/family-sql/ir";
|
|
6
6
|
import { isAuthoringEntityTypeDescriptor } from "@prisma-next/framework-components/authoring";
|
|
7
7
|
//#region src/core/postgres-contract-serializer.ts
|
|
@@ -13,57 +13,49 @@ function isAuthoringEntityTypeFactoryOutput(output) {
|
|
|
13
13
|
return typeof output === "object" && output !== null && typeof output.factory === "function";
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* Walks a pack's entity-type namespace tree and emits
|
|
17
|
-
*
|
|
18
|
-
*
|
|
16
|
+
* Walks a pack's entity-type namespace tree and emits hydration factories
|
|
17
|
+
* keyed by the descriptor's `discriminator`. Used for `storage.types`
|
|
18
|
+
* (codec-triple hydration). Namespace entries hydration dispatches by
|
|
19
|
+
* entries key, not discriminator — handled by `hydrateNamespaceEntities`.
|
|
19
20
|
*/
|
|
20
|
-
function
|
|
21
|
-
const
|
|
22
|
-
const validatorFragments = /* @__PURE__ */ new Map();
|
|
21
|
+
function collectStorageTypesHydrators(namespace) {
|
|
22
|
+
const registry = /* @__PURE__ */ new Map();
|
|
23
23
|
const walk = (node) => {
|
|
24
24
|
for (const value of Object.values(node)) {
|
|
25
25
|
if (isAuthoringEntityTypeDescriptor(value)) {
|
|
26
26
|
if (isAuthoringEntityTypeFactoryOutput(value.output)) {
|
|
27
27
|
const { factory } = value.output;
|
|
28
|
-
|
|
28
|
+
registry.set(value.discriminator, (raw) => factory(raw, POSTGRES_AUTHORING_CTX));
|
|
29
29
|
}
|
|
30
|
-
if (value.validatorSchema !== void 0) validatorFragments.set(value.discriminator, value.validatorSchema);
|
|
31
30
|
continue;
|
|
32
31
|
}
|
|
33
32
|
if (typeof value === "object" && value !== null) walk(value);
|
|
34
33
|
}
|
|
35
34
|
};
|
|
36
35
|
walk(namespace);
|
|
37
|
-
return
|
|
38
|
-
entityTypeRegistry,
|
|
39
|
-
validatorFragments
|
|
40
|
-
};
|
|
36
|
+
return registry;
|
|
41
37
|
}
|
|
42
38
|
var PostgresContractSerializer = class extends SqlContractSerializerBase {
|
|
43
39
|
constructor() {
|
|
44
|
-
const
|
|
45
|
-
super(
|
|
40
|
+
const storageTypesHydrators = collectStorageTypesHydrators(postgresAuthoringEntityTypes);
|
|
41
|
+
super(storageTypesHydrators);
|
|
42
|
+
}
|
|
43
|
+
get defaultNamespaceId() {
|
|
44
|
+
return postgresTargetDescriptorMeta.defaultNamespaceId;
|
|
46
45
|
}
|
|
47
46
|
hydrateSqlNamespaceEntry(nsId, raw) {
|
|
48
47
|
if (raw instanceof NamespaceBase) return raw;
|
|
49
48
|
const { id, entries } = blindCast(super.hydrateSqlNamespaceEntry(nsId, raw));
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (rawTypeSlot !== null && typeof rawTypeSlot === "object" && !Array.isArray(rawTypeSlot)) {
|
|
55
|
-
const enumFactory = this.entityTypeRegistry.get("postgres-enum");
|
|
56
|
-
typeSlot = Object.fromEntries(Object.entries(rawTypeSlot).map(([name, entry]) => [name, blindCast(enumFactory !== void 0 ? enumFactory(entry) : entry)]));
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
const emptyTables = Object.keys(entries.table).length === 0;
|
|
60
|
-
const emptyTypes = !typeSlot || Object.keys(typeSlot).length === 0;
|
|
61
|
-
if (id === UNBOUND_NAMESPACE_ID && emptyTables && emptyTypes) return PostgresSchema.unbound;
|
|
49
|
+
const valueSetSlot = entries["valueSet"];
|
|
50
|
+
const hasValueSets = valueSetSlot !== void 0 && Object.keys(valueSetSlot).length > 0;
|
|
51
|
+
const emptyTables = Object.keys(entries["table"] ?? {}).length === 0;
|
|
52
|
+
if (id === UNBOUND_NAMESPACE_ID && emptyTables && !hasValueSets) return PostgresSchema.unbound;
|
|
62
53
|
return new PostgresSchema({
|
|
63
54
|
id,
|
|
64
55
|
entries: {
|
|
65
|
-
|
|
66
|
-
|
|
56
|
+
...entries,
|
|
57
|
+
table: entries["table"] ?? {},
|
|
58
|
+
...hasValueSets ? { valueSet: valueSetSlot } : {}
|
|
67
59
|
}
|
|
68
60
|
});
|
|
69
61
|
}
|
|
@@ -74,7 +66,7 @@ var PostgresContractSerializer = class extends SqlContractSerializerBase {
|
|
|
74
66
|
else namespacesJson[nsId] = {
|
|
75
67
|
id: nsId,
|
|
76
68
|
kind: nsId === UNBOUND_NAMESPACE_ID ? "postgres-unbound-schema" : "postgres-schema",
|
|
77
|
-
entries: { table: Object.fromEntries(Object.entries(ns.entries.table).map(([tableName, table]) => [tableName, this.serializeJsonValue(table)])) }
|
|
69
|
+
entries: { table: Object.fromEntries(Object.entries(ns.entries.table ?? {}).map(([tableName, table]) => [tableName, this.serializeJsonValue(table)])) }
|
|
78
70
|
};
|
|
79
71
|
const storageOut = {
|
|
80
72
|
storageHash: String(storage.storageHash),
|
|
@@ -92,15 +84,16 @@ var PostgresContractSerializer = class extends SqlContractSerializerBase {
|
|
|
92
84
|
}
|
|
93
85
|
serializePostgresNamespace(ns, isUnboundSlot) {
|
|
94
86
|
const tablesOut = {};
|
|
95
|
-
for (const [tableName, table] of Object.entries(ns.
|
|
96
|
-
const
|
|
97
|
-
|
|
87
|
+
for (const [tableName, table] of Object.entries(ns.table)) tablesOut[tableName] = this.serializeJsonValue(table);
|
|
88
|
+
const valueSetEntries = ns.valueSet;
|
|
89
|
+
const valueSetOut = {};
|
|
90
|
+
if (valueSetEntries !== void 0) for (const [valueSetName, valueSet] of Object.entries(valueSetEntries)) valueSetOut[valueSetName] = blindCast(this.serializeJsonValue(valueSet));
|
|
98
91
|
return {
|
|
99
92
|
id: ns.id,
|
|
100
93
|
kind: isUnboundSlot ? "postgres-unbound-schema" : "postgres-schema",
|
|
101
94
|
entries: {
|
|
102
95
|
table: tablesOut,
|
|
103
|
-
|
|
96
|
+
...Object.keys(valueSetOut).length > 0 ? { valueSet: valueSetOut } : {}
|
|
104
97
|
}
|
|
105
98
|
};
|
|
106
99
|
}
|
|
@@ -111,4 +104,4 @@ var PostgresContractSerializer = class extends SqlContractSerializerBase {
|
|
|
111
104
|
//#endregion
|
|
112
105
|
export { PostgresContractSerializer as t };
|
|
113
106
|
|
|
114
|
-
//# sourceMappingURL=postgres-contract-serializer-
|
|
107
|
+
//# sourceMappingURL=postgres-contract-serializer-k3TAcPMY.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-contract-serializer-k3TAcPMY.mjs","names":[],"sources":["../src/core/postgres-contract-serializer.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport {\n SqlContractSerializerBase,\n type SqlEntityHydrationFactory,\n} from '@prisma-next/family-sql/ir';\nimport {\n type AuthoringEntityContext,\n type AuthoringEntityTypeFactoryOutput,\n type AuthoringEntityTypeNamespace,\n isAuthoringEntityTypeDescriptor,\n} from '@prisma-next/framework-components/authoring';\nimport {\n type Namespace,\n NamespaceBase,\n UNBOUND_NAMESPACE_ID,\n} from '@prisma-next/framework-components/ir';\nimport type { SqlNamespaceTablesInput, SqlStorage } from '@prisma-next/sql-contract/types';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport type { JsonObject } from '@prisma-next/utils/json';\nimport { postgresAuthoringEntityTypes } from './authoring';\nimport { postgresTargetDescriptorMeta } from './descriptor-meta';\nimport { isPostgresSchema, PostgresSchema } from './postgres-schema';\n\nconst POSTGRES_AUTHORING_CTX: AuthoringEntityContext = {\n family: 'sql',\n target: 'postgres',\n};\n\nfunction isAuthoringEntityTypeFactoryOutput(\n output: unknown,\n): output is AuthoringEntityTypeFactoryOutput<unknown, unknown> {\n return (\n typeof output === 'object' &&\n output !== null &&\n typeof (output as AuthoringEntityTypeFactoryOutput).factory === 'function'\n );\n}\n\n/**\n * Walks a pack's entity-type namespace tree and emits hydration factories\n * keyed by the descriptor's `discriminator`. Used for `storage.types`\n * (codec-triple hydration). Namespace entries hydration dispatches by\n * entries key, not discriminator — handled by `hydrateNamespaceEntities`.\n */\nfunction collectStorageTypesHydrators(\n namespace: AuthoringEntityTypeNamespace,\n): ReadonlyMap<string, SqlEntityHydrationFactory> {\n const registry = new Map<string, SqlEntityHydrationFactory>();\n const walk = (node: AuthoringEntityTypeNamespace): void => {\n for (const value of Object.values(node)) {\n if (isAuthoringEntityTypeDescriptor(value)) {\n if (isAuthoringEntityTypeFactoryOutput(value.output)) {\n const { factory } = value.output;\n registry.set(value.discriminator, (raw) => factory(raw, POSTGRES_AUTHORING_CTX));\n }\n continue;\n }\n if (typeof value === 'object' && value !== null) {\n walk(value);\n }\n }\n };\n walk(namespace);\n return registry;\n}\n\nexport class PostgresContractSerializer extends SqlContractSerializerBase<Contract<SqlStorage>> {\n constructor() {\n const storageTypesHydrators = collectStorageTypesHydrators(postgresAuthoringEntityTypes);\n super(storageTypesHydrators);\n }\n\n protected override get defaultNamespaceId(): string {\n return postgresTargetDescriptorMeta.defaultNamespaceId;\n }\n\n protected override hydrateSqlNamespaceEntry(\n nsId: string,\n raw: Namespace | Record<string, unknown>,\n ): Namespace | SqlNamespaceTablesInput {\n if (raw instanceof NamespaceBase) {\n return raw;\n }\n const hydrated = blindCast<\n SqlNamespaceTablesInput,\n 'super.hydrateSqlNamespaceEntry returns SqlNamespaceTablesInput when raw is not a NamespaceBase'\n >(super.hydrateSqlNamespaceEntry(nsId, raw));\n const { id, entries } = hydrated;\n\n const valueSetSlot = entries['valueSet'];\n const hasValueSets = valueSetSlot !== undefined && Object.keys(valueSetSlot).length > 0;\n const emptyTables = Object.keys(entries['table'] ?? {}).length === 0;\n if (id === UNBOUND_NAMESPACE_ID && emptyTables && !hasValueSets) {\n return PostgresSchema.unbound;\n }\n return new PostgresSchema({\n id,\n entries: {\n ...entries,\n table: entries['table'] ?? {},\n ...(hasValueSets ? { valueSet: valueSetSlot } : {}),\n },\n });\n }\n\n override serializeContract(contract: Contract<SqlStorage>): JsonObject {\n const { storage, ...rest } = contract;\n const namespacesJson: Record<string, JsonObject> = {};\n for (const [nsId, ns] of Object.entries(storage.namespaces)) {\n if (isPostgresSchema(ns)) {\n namespacesJson[nsId] = this.serializePostgresNamespace(ns, ns.id === UNBOUND_NAMESPACE_ID);\n } else {\n const isUnboundSlot = nsId === UNBOUND_NAMESPACE_ID;\n namespacesJson[nsId] = {\n id: nsId,\n kind: isUnboundSlot ? 'postgres-unbound-schema' : 'postgres-schema',\n entries: {\n table: Object.fromEntries(\n Object.entries(ns.entries.table ?? {}).map(([tableName, table]) => [\n tableName,\n this.serializeJsonValue(table) as JsonObject,\n ]),\n ),\n },\n };\n }\n }\n const storageOut: Record<string, unknown> = {\n storageHash: String(storage.storageHash),\n namespaces: namespacesJson,\n };\n if (storage.types !== undefined) {\n const typesOut: Record<string, JsonObject> = {};\n for (const [name, entry] of Object.entries(storage.types)) {\n typesOut[name] = this.serializeJsonValue(entry) as JsonObject;\n }\n storageOut['types'] = typesOut;\n }\n return {\n ...rest,\n storage: storageOut,\n } as unknown as JsonObject;\n }\n\n private serializePostgresNamespace(ns: PostgresSchema, isUnboundSlot: boolean): JsonObject {\n const tablesOut: Record<string, JsonObject> = {};\n for (const [tableName, table] of Object.entries(ns.table)) {\n tablesOut[tableName] = this.serializeJsonValue(table) as JsonObject;\n }\n const valueSetEntries = ns.valueSet;\n const valueSetOut: Record<string, JsonObject> = {};\n if (valueSetEntries !== undefined) {\n for (const [valueSetName, valueSet] of Object.entries(valueSetEntries)) {\n valueSetOut[valueSetName] = blindCast<\n JsonObject,\n 'serializeJsonValue round-trips the value-set node through JSON, yielding a JsonObject'\n >(this.serializeJsonValue(valueSet));\n }\n }\n return {\n id: ns.id,\n kind: isUnboundSlot ? 'postgres-unbound-schema' : 'postgres-schema',\n entries: {\n table: tablesOut,\n ...(Object.keys(valueSetOut).length > 0 ? { valueSet: valueSetOut } : {}),\n },\n };\n }\n\n private serializeJsonValue(value: unknown): unknown {\n return JSON.parse(JSON.stringify(value)) as unknown;\n }\n}\n"],"mappings":";;;;;;;AAuBA,MAAM,yBAAiD;CACrD,QAAQ;CACR,QAAQ;AACV;AAEA,SAAS,mCACP,QAC8D;CAC9D,OACE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B,OAAyB;EAClD,OAAO,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC;CACzC;AACF"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { C as SetNotNullCall, D as installExtension, S as SetDefaultCall, _ as DropDefaultCall, b as DropTableCall, c as AlterColumnTypeCall, d as CreateSchemaCall, f as CreateTableCall, g as DropConstraintCall, h as DropColumnCall, m as DropCheckConstraintCall, n as AddColumnCall, o as AddPrimaryKeyCall, r as AddForeignKeyCall, s as AddUniqueCall, t as AddCheckConstraintCall, u as CreateIndexCall, v as DropIndexCall, y as DropNotNullCall } from "./op-factory-call-D_p5vxwt.mjs";
|
|
2
|
+
import { t as errorPostgresMigrationStackMissing } from "./errors-CUk87ByX.mjs";
|
|
3
|
+
import { t as dataTransform } from "./data-transform-BOWpliq8.mjs";
|
|
4
|
+
import { Migration } from "@prisma-next/family-sql/migration";
|
|
5
|
+
//#region src/core/migrations/postgres-migration.ts
|
|
6
|
+
/**
|
|
7
|
+
* Target-owned base class for Postgres migrations.
|
|
8
|
+
*
|
|
9
|
+
* Fixes the `SqlMigration` generic to `PostgresPlanTargetDetails` and the
|
|
10
|
+
* abstract `targetId` to the Postgres target-id string literal, so both
|
|
11
|
+
* user-authored migrations and renderer-generated scaffolds (the output of
|
|
12
|
+
* `renderCallsToTypeScript`) can extend `PostgresMigration` directly without
|
|
13
|
+
* redeclaring target-local identity.
|
|
14
|
+
*
|
|
15
|
+
* Mirrors `MongoMigration` in `@prisma-next/family-mongo`: the renderer
|
|
16
|
+
* emits `extends Migration` against a facade re-export of this class
|
|
17
|
+
* from `@prisma-next/postgres/migration`, keeping the authoring surface
|
|
18
|
+
* target-scoped rather than family-scoped.
|
|
19
|
+
*
|
|
20
|
+
* The constructor materializes a single Postgres `SqlControlAdapter` from
|
|
21
|
+
* `stack.adapter.create(stack)` and stores it; the protected `dataTransform`
|
|
22
|
+
* instance method forwards to the free `dataTransform` factory with that
|
|
23
|
+
* stored adapter, so user migrations can write `this.dataTransform(...)`
|
|
24
|
+
* without threading the adapter through every call.
|
|
25
|
+
*
|
|
26
|
+
* Every method requires an explicit `schema`. Postgres migrations name their
|
|
27
|
+
* schema deliberately — there is no default and no `search_path`-relative
|
|
28
|
+
* option. A migration that left the schema unspecified would resolve against
|
|
29
|
+
* whatever `search_path` the connection happened to carry, and that ambiguity
|
|
30
|
+
* is an antipattern in a migration. (The unbound/unspecified namespace concept
|
|
31
|
+
* remains for SQLite, which has no schemas, and for Mongo's connection `db`.)
|
|
32
|
+
*/
|
|
33
|
+
var PostgresMigration = class extends Migration {
|
|
34
|
+
targetId = "postgres";
|
|
35
|
+
/**
|
|
36
|
+
* Materialized Postgres control adapter, created once per migration
|
|
37
|
+
* instance from the injected stack. `undefined` only when the migration
|
|
38
|
+
* was instantiated without a stack (test fixtures); `dataTransform`
|
|
39
|
+
* throws in that case to surface the misuse.
|
|
40
|
+
*/
|
|
41
|
+
controlAdapter;
|
|
42
|
+
constructor(stack) {
|
|
43
|
+
super(stack);
|
|
44
|
+
this.controlAdapter = stack?.adapter ? stack.adapter.create(stack) : void 0;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Instance-method wrapper around the free `dataTransform` factory that
|
|
48
|
+
* supplies the stored control adapter. Authors call this from inside
|
|
49
|
+
* `get operations()`; the adapter argument is hidden from the call site.
|
|
50
|
+
*/
|
|
51
|
+
dataTransform(contract, name, options) {
|
|
52
|
+
if (!this.controlAdapter) throw errorPostgresMigrationStackMissing();
|
|
53
|
+
return dataTransform(contract, name, options, this.controlAdapter);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Emit a `CREATE TABLE` migration operation. Builds a typed DDL node from
|
|
57
|
+
* the supplied options and lowers it through the stored control adapter.
|
|
58
|
+
* Throws if no adapter is present (i.e. migration instantiated without a stack).
|
|
59
|
+
*/
|
|
60
|
+
createTable(options) {
|
|
61
|
+
if (!this.controlAdapter) throw errorPostgresMigrationStackMissing();
|
|
62
|
+
return new CreateTableCall(options.schema, options.table, options.columns, options.constraints).toOp(this.controlAdapter);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Emit a `CREATE SCHEMA` migration operation. Builds a typed DDL node from
|
|
66
|
+
* the supplied options and lowers it through the stored control adapter.
|
|
67
|
+
* Throws if no adapter is present (i.e. migration instantiated without a stack).
|
|
68
|
+
*/
|
|
69
|
+
createSchema(options) {
|
|
70
|
+
if (!this.controlAdapter) throw errorPostgresMigrationStackMissing();
|
|
71
|
+
return new CreateSchemaCall(options.schema).toOp(this.controlAdapter);
|
|
72
|
+
}
|
|
73
|
+
addColumn(options) {
|
|
74
|
+
if (!this.controlAdapter) throw errorPostgresMigrationStackMissing();
|
|
75
|
+
return new AddColumnCall(options.schema, options.table, options.column).toOp(this.controlAdapter);
|
|
76
|
+
}
|
|
77
|
+
addPrimaryKey(options) {
|
|
78
|
+
if (!this.controlAdapter) throw errorPostgresMigrationStackMissing();
|
|
79
|
+
return new AddPrimaryKeyCall(options.schema, options.table, options.constraint, options.columns).toOp(this.controlAdapter);
|
|
80
|
+
}
|
|
81
|
+
addUnique(options) {
|
|
82
|
+
if (!this.controlAdapter) throw errorPostgresMigrationStackMissing();
|
|
83
|
+
return new AddUniqueCall(options.schema, options.table, options.constraint, options.columns).toOp(this.controlAdapter);
|
|
84
|
+
}
|
|
85
|
+
addForeignKey(options) {
|
|
86
|
+
if (!this.controlAdapter) throw errorPostgresMigrationStackMissing();
|
|
87
|
+
return new AddForeignKeyCall(options.schema, options.table, options.foreignKey).toOp(this.controlAdapter);
|
|
88
|
+
}
|
|
89
|
+
addCheckConstraint(options) {
|
|
90
|
+
if (!this.controlAdapter) throw errorPostgresMigrationStackMissing();
|
|
91
|
+
return new AddCheckConstraintCall(options.schema, options.table, options.constraint, options.column, options.values).toOp(this.controlAdapter);
|
|
92
|
+
}
|
|
93
|
+
dropCheckConstraint(options) {
|
|
94
|
+
if (!this.controlAdapter) throw errorPostgresMigrationStackMissing();
|
|
95
|
+
return new DropCheckConstraintCall(options.schema, options.table, options.constraint).toOp(this.controlAdapter);
|
|
96
|
+
}
|
|
97
|
+
dropConstraint(options) {
|
|
98
|
+
if (!this.controlAdapter) throw errorPostgresMigrationStackMissing();
|
|
99
|
+
return new DropConstraintCall(options.schema, options.table, options.constraint, options.kind ?? "unique").toOp(this.controlAdapter);
|
|
100
|
+
}
|
|
101
|
+
dropTable(options) {
|
|
102
|
+
if (!this.controlAdapter) throw errorPostgresMigrationStackMissing();
|
|
103
|
+
return new DropTableCall(options.schema, options.table).toOp(this.controlAdapter);
|
|
104
|
+
}
|
|
105
|
+
dropColumn(options) {
|
|
106
|
+
if (!this.controlAdapter) throw errorPostgresMigrationStackMissing();
|
|
107
|
+
return new DropColumnCall(options.schema, options.table, options.column).toOp(this.controlAdapter);
|
|
108
|
+
}
|
|
109
|
+
alterColumnType(options) {
|
|
110
|
+
if (!this.controlAdapter) throw errorPostgresMigrationStackMissing();
|
|
111
|
+
return new AlterColumnTypeCall(options.schema, options.table, options.column, options.options).toOp(this.controlAdapter);
|
|
112
|
+
}
|
|
113
|
+
setNotNull(options) {
|
|
114
|
+
if (!this.controlAdapter) throw errorPostgresMigrationStackMissing();
|
|
115
|
+
return new SetNotNullCall(options.schema, options.table, options.column).toOp(this.controlAdapter);
|
|
116
|
+
}
|
|
117
|
+
dropNotNull(options) {
|
|
118
|
+
if (!this.controlAdapter) throw errorPostgresMigrationStackMissing();
|
|
119
|
+
return new DropNotNullCall(options.schema, options.table, options.column).toOp(this.controlAdapter);
|
|
120
|
+
}
|
|
121
|
+
setDefault(options) {
|
|
122
|
+
if (!this.controlAdapter) throw errorPostgresMigrationStackMissing();
|
|
123
|
+
return new SetDefaultCall(options.schema, options.table, options.column, options.defaultSql, options.operationClass).toOp(this.controlAdapter);
|
|
124
|
+
}
|
|
125
|
+
dropDefault(options) {
|
|
126
|
+
if (!this.controlAdapter) throw errorPostgresMigrationStackMissing();
|
|
127
|
+
return new DropDefaultCall(options.schema, options.table, options.column).toOp(this.controlAdapter);
|
|
128
|
+
}
|
|
129
|
+
createIndex(options) {
|
|
130
|
+
if (!this.controlAdapter) throw errorPostgresMigrationStackMissing();
|
|
131
|
+
return new CreateIndexCall(options.schema, options.table, options.index, options.columns, options.extras).toOp(this.controlAdapter);
|
|
132
|
+
}
|
|
133
|
+
dropIndex(options) {
|
|
134
|
+
if (!this.controlAdapter) throw errorPostgresMigrationStackMissing();
|
|
135
|
+
return new DropIndexCall(options.schema, options.table, options.index).toOp(this.controlAdapter);
|
|
136
|
+
}
|
|
137
|
+
installExtension(options) {
|
|
138
|
+
if (!this.controlAdapter) throw errorPostgresMigrationStackMissing();
|
|
139
|
+
return installExtension(options, this.controlAdapter);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
//#endregion
|
|
143
|
+
export { PostgresMigration as t };
|
|
144
|
+
|
|
145
|
+
//# sourceMappingURL=postgres-migration-B5jKrXv3.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-migration-B5jKrXv3.mjs","names":["SqlMigration"],"sources":["../src/core/migrations/postgres-migration.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { SqlControlAdapter } from '@prisma-next/family-sql/control-adapter';\nimport { Migration as SqlMigration } from '@prisma-next/family-sql/migration';\nimport type { ControlStack } from '@prisma-next/framework-components/control';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { DdlColumn, DdlTableConstraint } from '@prisma-next/sql-relational-core/ast';\nimport { errorPostgresMigrationStackMissing } from '../errors';\nimport {\n AddCheckConstraintCall,\n AddColumnCall,\n AddForeignKeyCall,\n AddPrimaryKeyCall,\n AddUniqueCall,\n AlterColumnTypeCall,\n type AlterColumnTypeOptions,\n CreateIndexCall,\n CreateSchemaCall,\n CreateTableCall,\n DropCheckConstraintCall,\n DropColumnCall,\n DropConstraintCall,\n DropDefaultCall,\n DropIndexCall,\n DropNotNullCall,\n DropTableCall,\n SetDefaultCall,\n SetNotNullCall,\n} from './op-factory-call';\nimport { type DataTransformOptions, dataTransform } from './operations/data-transform';\nimport { installExtension } from './operations/dependencies';\nimport type { CreateIndexExtras } from './operations/indexes';\nimport type { ForeignKeySpec } from './operations/shared';\nimport type { PostgresPlanTargetDetails } from './planner-target-details';\n\n/**\n * Target-owned base class for Postgres migrations.\n *\n * Fixes the `SqlMigration` generic to `PostgresPlanTargetDetails` and the\n * abstract `targetId` to the Postgres target-id string literal, so both\n * user-authored migrations and renderer-generated scaffolds (the output of\n * `renderCallsToTypeScript`) can extend `PostgresMigration` directly without\n * redeclaring target-local identity.\n *\n * Mirrors `MongoMigration` in `@prisma-next/family-mongo`: the renderer\n * emits `extends Migration` against a facade re-export of this class\n * from `@prisma-next/postgres/migration`, keeping the authoring surface\n * target-scoped rather than family-scoped.\n *\n * The constructor materializes a single Postgres `SqlControlAdapter` from\n * `stack.adapter.create(stack)` and stores it; the protected `dataTransform`\n * instance method forwards to the free `dataTransform` factory with that\n * stored adapter, so user migrations can write `this.dataTransform(...)`\n * without threading the adapter through every call.\n *\n * Every method requires an explicit `schema`. Postgres migrations name their\n * schema deliberately — there is no default and no `search_path`-relative\n * option. A migration that left the schema unspecified would resolve against\n * whatever `search_path` the connection happened to carry, and that ambiguity\n * is an antipattern in a migration. (The unbound/unspecified namespace concept\n * remains for SQLite, which has no schemas, and for Mongo's connection `db`.)\n */\nexport abstract class PostgresMigration extends SqlMigration<\n PostgresPlanTargetDetails,\n 'postgres'\n> {\n readonly targetId = 'postgres' as const;\n\n /**\n * Materialized Postgres control adapter, created once per migration\n * instance from the injected stack. `undefined` only when the migration\n * was instantiated without a stack (test fixtures); `dataTransform`\n * throws in that case to surface the misuse.\n */\n protected readonly controlAdapter: SqlControlAdapter<'postgres'> | undefined;\n\n constructor(stack?: ControlStack<'sql', 'postgres'>) {\n super(stack);\n // The descriptor `create()` is typed as the wider `ControlAdapterInstance`;\n // the Postgres descriptor concretely returns a `SqlControlAdapter<'postgres'>`,\n // so the cast holds for any Postgres-target stack assembled at runtime.\n this.controlAdapter = stack?.adapter\n ? (stack.adapter.create(stack) as SqlControlAdapter<'postgres'>)\n : undefined;\n }\n\n /**\n * Instance-method wrapper around the free `dataTransform` factory that\n * supplies the stored control adapter. Authors call this from inside\n * `get operations()`; the adapter argument is hidden from the call site.\n */\n protected dataTransform<TContract extends Contract<SqlStorage>>(\n contract: TContract,\n name: string,\n options: DataTransformOptions,\n ): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return dataTransform(contract, name, options, this.controlAdapter);\n }\n\n /**\n * Emit a `CREATE TABLE` migration operation. Builds a typed DDL node from\n * the supplied options and lowers it through the stored control adapter.\n * Throws if no adapter is present (i.e. migration instantiated without a stack).\n */\n protected createTable(options: {\n readonly schema: string;\n readonly table: string;\n readonly ifNotExists?: boolean;\n readonly columns: readonly DdlColumn[];\n readonly constraints?: readonly DdlTableConstraint[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new CreateTableCall(\n options.schema,\n options.table,\n options.columns,\n options.constraints,\n ).toOp(this.controlAdapter);\n }\n\n /**\n * Emit a `CREATE SCHEMA` migration operation. Builds a typed DDL node from\n * the supplied options and lowers it through the stored control adapter.\n * Throws if no adapter is present (i.e. migration instantiated without a stack).\n */\n protected createSchema(options: {\n readonly schema: string;\n readonly ifNotExists?: boolean;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new CreateSchemaCall(options.schema).toOp(this.controlAdapter);\n }\n\n protected addColumn(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: DdlColumn;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new AddColumnCall(options.schema, options.table, options.column).toOp(\n this.controlAdapter,\n );\n }\n\n protected addPrimaryKey(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly columns: readonly string[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new AddPrimaryKeyCall(\n options.schema,\n options.table,\n options.constraint,\n options.columns,\n ).toOp(this.controlAdapter);\n }\n\n protected addUnique(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly columns: readonly string[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new AddUniqueCall(\n options.schema,\n options.table,\n options.constraint,\n options.columns,\n ).toOp(this.controlAdapter);\n }\n\n protected addForeignKey(options: {\n readonly schema: string;\n readonly table: string;\n readonly foreignKey: ForeignKeySpec;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new AddForeignKeyCall(options.schema, options.table, options.foreignKey).toOp(\n this.controlAdapter,\n );\n }\n\n protected addCheckConstraint(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly column: string;\n readonly values: readonly string[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new AddCheckConstraintCall(\n options.schema,\n options.table,\n options.constraint,\n options.column,\n options.values,\n ).toOp(this.controlAdapter);\n }\n\n protected dropCheckConstraint(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropCheckConstraintCall(options.schema, options.table, options.constraint).toOp(\n this.controlAdapter,\n );\n }\n\n protected dropConstraint(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly kind?: 'foreignKey' | 'unique' | 'primaryKey';\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropConstraintCall(\n options.schema,\n options.table,\n options.constraint,\n options.kind ?? 'unique',\n ).toOp(this.controlAdapter);\n }\n\n protected dropTable(options: {\n readonly schema: string;\n readonly table: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropTableCall(options.schema, options.table).toOp(this.controlAdapter);\n }\n\n protected dropColumn(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropColumnCall(options.schema, options.table, options.column).toOp(\n this.controlAdapter,\n );\n }\n\n protected alterColumnType(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n readonly options: AlterColumnTypeOptions;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new AlterColumnTypeCall(\n options.schema,\n options.table,\n options.column,\n options.options,\n ).toOp(this.controlAdapter);\n }\n\n protected setNotNull(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new SetNotNullCall(options.schema, options.table, options.column).toOp(\n this.controlAdapter,\n );\n }\n\n protected dropNotNull(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropNotNullCall(options.schema, options.table, options.column).toOp(\n this.controlAdapter,\n );\n }\n\n protected setDefault(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n readonly defaultSql: string;\n readonly operationClass?: 'additive' | 'widening';\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new SetDefaultCall(\n options.schema,\n options.table,\n options.column,\n options.defaultSql,\n options.operationClass,\n ).toOp(this.controlAdapter);\n }\n\n protected dropDefault(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropDefaultCall(options.schema, options.table, options.column).toOp(\n this.controlAdapter,\n );\n }\n\n protected createIndex(options: {\n readonly schema: string;\n readonly table: string;\n readonly index: string;\n readonly columns: readonly string[];\n readonly extras?: CreateIndexExtras;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new CreateIndexCall(\n options.schema,\n options.table,\n options.index,\n options.columns,\n options.extras,\n ).toOp(this.controlAdapter);\n }\n\n protected dropIndex(options: {\n readonly schema: string;\n readonly table: string;\n readonly index: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new DropIndexCall(options.schema, options.table, options.index).toOp(\n this.controlAdapter,\n );\n }\n\n protected installExtension(options: {\n readonly extensionName: string;\n readonly invariantId: string;\n readonly id: string;\n readonly label?: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return installExtension(options, this.controlAdapter);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;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,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,MAAM,CAAC,CAAC,KACvE,KAAK,cACP;CACF;CAEA,YAAsB,SAI4C;EAChE,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,IAAI,gBAAgB,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,MAAM,CAAC,CAAC,KACxE,KAAK,cACP;CACF;CAEA,WAAqB,SAM6C;EAChE,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,IAAI,eACT,QAAQ,QACR,QAAQ,OACR,QAAQ,QACR,QAAQ,YACR,QAAQ,cACV,CAAC,CAAC,KAAK,KAAK,cAAc;CAC5B;CAEA,YAAsB,SAI4C;EAChE,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,IAAI,gBAAgB,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,MAAM,CAAC,CAAC,KACxE,KAAK,cACP;CACF;CAEA,YAAsB,SAM4C;EAChE,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,IAAI,gBACT,QAAQ,QACR,QAAQ,OACR,QAAQ,OACR,QAAQ,SACR,QAAQ,MACV,CAAC,CAAC,KAAK,KAAK,cAAc;CAC5B;CAEA,UAAoB,SAI8C;EAChE,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,IAAI,cAAc,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,KAAK,CAAC,CAAC,KACrE,KAAK,cACP;CACF;CAEA,iBAA2B,SAKuC;EAChE,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,iBAAiB,SAAS,KAAK,cAAc;CACtD;AACF"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { t as PostgresPlanTargetDetails } from "./planner-target-details-CIY6tLeo.mjs";
|
|
2
|
+
import { n as DataTransformOptions } from "./data-transform-DDgWdB5o.mjs";
|
|
3
|
+
import { s as AlterColumnTypeOptions, w as ForeignKeySpec } from "./op-factory-call-DmQEc3XV.mjs";
|
|
4
|
+
import { DdlColumn, DdlTableConstraint } from "@prisma-next/sql-relational-core/ast";
|
|
5
|
+
import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
|
|
6
|
+
import { SqlStorage } from "@prisma-next/sql-contract/types";
|
|
7
|
+
import { Migration } from "@prisma-next/family-sql/migration";
|
|
8
|
+
import { ControlStack } from "@prisma-next/framework-components/control";
|
|
9
|
+
import { Contract } from "@prisma-next/contract/types";
|
|
10
|
+
import { ExecuteRequestLowerer, SqlControlAdapter } from "@prisma-next/family-sql/control-adapter";
|
|
11
|
+
|
|
12
|
+
//#region src/core/migrations/operations/indexes.d.ts
|
|
13
|
+
interface CreateIndexExtras {
|
|
14
|
+
readonly type?: string;
|
|
15
|
+
readonly options?: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/core/migrations/postgres-migration.d.ts
|
|
19
|
+
/**
|
|
20
|
+
* Target-owned base class for Postgres migrations.
|
|
21
|
+
*
|
|
22
|
+
* Fixes the `SqlMigration` generic to `PostgresPlanTargetDetails` and the
|
|
23
|
+
* abstract `targetId` to the Postgres target-id string literal, so both
|
|
24
|
+
* user-authored migrations and renderer-generated scaffolds (the output of
|
|
25
|
+
* `renderCallsToTypeScript`) can extend `PostgresMigration` directly without
|
|
26
|
+
* redeclaring target-local identity.
|
|
27
|
+
*
|
|
28
|
+
* Mirrors `MongoMigration` in `@prisma-next/family-mongo`: the renderer
|
|
29
|
+
* emits `extends Migration` against a facade re-export of this class
|
|
30
|
+
* from `@prisma-next/postgres/migration`, keeping the authoring surface
|
|
31
|
+
* target-scoped rather than family-scoped.
|
|
32
|
+
*
|
|
33
|
+
* The constructor materializes a single Postgres `SqlControlAdapter` from
|
|
34
|
+
* `stack.adapter.create(stack)` and stores it; the protected `dataTransform`
|
|
35
|
+
* instance method forwards to the free `dataTransform` factory with that
|
|
36
|
+
* stored adapter, so user migrations can write `this.dataTransform(...)`
|
|
37
|
+
* without threading the adapter through every call.
|
|
38
|
+
*
|
|
39
|
+
* Every method requires an explicit `schema`. Postgres migrations name their
|
|
40
|
+
* schema deliberately — there is no default and no `search_path`-relative
|
|
41
|
+
* option. A migration that left the schema unspecified would resolve against
|
|
42
|
+
* whatever `search_path` the connection happened to carry, and that ambiguity
|
|
43
|
+
* is an antipattern in a migration. (The unbound/unspecified namespace concept
|
|
44
|
+
* remains for SQLite, which has no schemas, and for Mongo's connection `db`.)
|
|
45
|
+
*/
|
|
46
|
+
declare abstract class PostgresMigration extends Migration<PostgresPlanTargetDetails, 'postgres'> {
|
|
47
|
+
readonly targetId: "postgres";
|
|
48
|
+
/**
|
|
49
|
+
* Materialized Postgres control adapter, created once per migration
|
|
50
|
+
* instance from the injected stack. `undefined` only when the migration
|
|
51
|
+
* was instantiated without a stack (test fixtures); `dataTransform`
|
|
52
|
+
* throws in that case to surface the misuse.
|
|
53
|
+
*/
|
|
54
|
+
protected readonly controlAdapter: SqlControlAdapter<'postgres'> | undefined;
|
|
55
|
+
constructor(stack?: ControlStack<'sql', 'postgres'>);
|
|
56
|
+
/**
|
|
57
|
+
* Instance-method wrapper around the free `dataTransform` factory that
|
|
58
|
+
* supplies the stored control adapter. Authors call this from inside
|
|
59
|
+
* `get operations()`; the adapter argument is hidden from the call site.
|
|
60
|
+
*/
|
|
61
|
+
protected dataTransform<TContract extends Contract<SqlStorage>>(contract: TContract, name: string, options: DataTransformOptions): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
|
|
62
|
+
/**
|
|
63
|
+
* Emit a `CREATE TABLE` migration operation. Builds a typed DDL node from
|
|
64
|
+
* the supplied options and lowers it through the stored control adapter.
|
|
65
|
+
* Throws if no adapter is present (i.e. migration instantiated without a stack).
|
|
66
|
+
*/
|
|
67
|
+
protected createTable(options: {
|
|
68
|
+
readonly schema: string;
|
|
69
|
+
readonly table: string;
|
|
70
|
+
readonly ifNotExists?: boolean;
|
|
71
|
+
readonly columns: readonly DdlColumn[];
|
|
72
|
+
readonly constraints?: readonly DdlTableConstraint[];
|
|
73
|
+
}): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
|
|
74
|
+
/**
|
|
75
|
+
* Emit a `CREATE SCHEMA` migration operation. Builds a typed DDL node from
|
|
76
|
+
* the supplied options and lowers it through the stored control adapter.
|
|
77
|
+
* Throws if no adapter is present (i.e. migration instantiated without a stack).
|
|
78
|
+
*/
|
|
79
|
+
protected createSchema(options: {
|
|
80
|
+
readonly schema: string;
|
|
81
|
+
readonly ifNotExists?: boolean;
|
|
82
|
+
}): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
|
|
83
|
+
protected addColumn(options: {
|
|
84
|
+
readonly schema: string;
|
|
85
|
+
readonly table: string;
|
|
86
|
+
readonly column: DdlColumn;
|
|
87
|
+
}): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
|
|
88
|
+
protected addPrimaryKey(options: {
|
|
89
|
+
readonly schema: string;
|
|
90
|
+
readonly table: string;
|
|
91
|
+
readonly constraint: string;
|
|
92
|
+
readonly columns: readonly string[];
|
|
93
|
+
}): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
|
|
94
|
+
protected addUnique(options: {
|
|
95
|
+
readonly schema: string;
|
|
96
|
+
readonly table: string;
|
|
97
|
+
readonly constraint: string;
|
|
98
|
+
readonly columns: readonly string[];
|
|
99
|
+
}): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
|
|
100
|
+
protected addForeignKey(options: {
|
|
101
|
+
readonly schema: string;
|
|
102
|
+
readonly table: string;
|
|
103
|
+
readonly foreignKey: ForeignKeySpec;
|
|
104
|
+
}): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
|
|
105
|
+
protected addCheckConstraint(options: {
|
|
106
|
+
readonly schema: string;
|
|
107
|
+
readonly table: string;
|
|
108
|
+
readonly constraint: string;
|
|
109
|
+
readonly column: string;
|
|
110
|
+
readonly values: readonly string[];
|
|
111
|
+
}): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
|
|
112
|
+
protected dropCheckConstraint(options: {
|
|
113
|
+
readonly schema: string;
|
|
114
|
+
readonly table: string;
|
|
115
|
+
readonly constraint: string;
|
|
116
|
+
}): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
|
|
117
|
+
protected dropConstraint(options: {
|
|
118
|
+
readonly schema: string;
|
|
119
|
+
readonly table: string;
|
|
120
|
+
readonly constraint: string;
|
|
121
|
+
readonly kind?: 'foreignKey' | 'unique' | 'primaryKey';
|
|
122
|
+
}): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
|
|
123
|
+
protected dropTable(options: {
|
|
124
|
+
readonly schema: string;
|
|
125
|
+
readonly table: string;
|
|
126
|
+
}): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
|
|
127
|
+
protected dropColumn(options: {
|
|
128
|
+
readonly schema: string;
|
|
129
|
+
readonly table: string;
|
|
130
|
+
readonly column: string;
|
|
131
|
+
}): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
|
|
132
|
+
protected alterColumnType(options: {
|
|
133
|
+
readonly schema: string;
|
|
134
|
+
readonly table: string;
|
|
135
|
+
readonly column: string;
|
|
136
|
+
readonly options: AlterColumnTypeOptions;
|
|
137
|
+
}): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
|
|
138
|
+
protected setNotNull(options: {
|
|
139
|
+
readonly schema: string;
|
|
140
|
+
readonly table: string;
|
|
141
|
+
readonly column: string;
|
|
142
|
+
}): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
|
|
143
|
+
protected dropNotNull(options: {
|
|
144
|
+
readonly schema: string;
|
|
145
|
+
readonly table: string;
|
|
146
|
+
readonly column: string;
|
|
147
|
+
}): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
|
|
148
|
+
protected setDefault(options: {
|
|
149
|
+
readonly schema: string;
|
|
150
|
+
readonly table: string;
|
|
151
|
+
readonly column: string;
|
|
152
|
+
readonly defaultSql: string;
|
|
153
|
+
readonly operationClass?: 'additive' | 'widening';
|
|
154
|
+
}): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
|
|
155
|
+
protected dropDefault(options: {
|
|
156
|
+
readonly schema: string;
|
|
157
|
+
readonly table: string;
|
|
158
|
+
readonly column: string;
|
|
159
|
+
}): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
|
|
160
|
+
protected createIndex(options: {
|
|
161
|
+
readonly schema: string;
|
|
162
|
+
readonly table: string;
|
|
163
|
+
readonly index: string;
|
|
164
|
+
readonly columns: readonly string[];
|
|
165
|
+
readonly extras?: CreateIndexExtras;
|
|
166
|
+
}): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
|
|
167
|
+
protected dropIndex(options: {
|
|
168
|
+
readonly schema: string;
|
|
169
|
+
readonly table: string;
|
|
170
|
+
readonly index: string;
|
|
171
|
+
}): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
|
|
172
|
+
protected installExtension(options: {
|
|
173
|
+
readonly extensionName: string;
|
|
174
|
+
readonly invariantId: string;
|
|
175
|
+
readonly id: string;
|
|
176
|
+
readonly label?: string;
|
|
177
|
+
}): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
|
|
178
|
+
}
|
|
179
|
+
//#endregion
|
|
180
|
+
export { PostgresMigration as t };
|
|
181
|
+
//# sourceMappingURL=postgres-migration-Y4YBJqkS.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-migration-Y4YBJqkS.d.mts","names":[],"sources":["../src/core/migrations/operations/indexes.ts","../src/core/migrations/postgres-migration.ts"],"mappings":";;;;;;;;;;;;UAmBiB,iBAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA,GAAU,MAAM;AAAA;;;AAF3B;;;;;;;;AAE2B;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