@prisma-next/family-sql 0.3.0-dev.12 → 0.3.0-dev.122
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/LICENSE +201 -0
- package/README.md +34 -7
- package/dist/assembly-Dzumaba1.mjs +159 -0
- package/dist/assembly-Dzumaba1.mjs.map +1 -0
- package/dist/control-adapter.d.mts +60 -0
- package/dist/control-adapter.d.mts.map +1 -0
- package/dist/control-adapter.mjs +1 -0
- package/dist/control-instance-BKuHINR7.d.mts +411 -0
- package/dist/control-instance-BKuHINR7.d.mts.map +1 -0
- package/dist/control.d.mts +128 -0
- package/dist/control.d.mts.map +1 -0
- package/dist/control.mjs +683 -0
- package/dist/control.mjs.map +1 -0
- package/dist/runtime.d.mts +27 -0
- package/dist/runtime.d.mts.map +1 -0
- package/dist/runtime.mjs +38 -0
- package/dist/runtime.mjs.map +1 -0
- package/dist/schema-verify.d.mts +48 -0
- package/dist/schema-verify.d.mts.map +1 -0
- package/dist/schema-verify.mjs +4 -0
- package/dist/test-utils.d.mts +2 -0
- package/dist/test-utils.mjs +3 -0
- package/dist/verify-BfMETJcM.mjs +108 -0
- package/dist/verify-BfMETJcM.mjs.map +1 -0
- package/dist/verify-sql-schema-C3Pit9o4.mjs +1085 -0
- package/dist/verify-sql-schema-C3Pit9o4.mjs.map +1 -0
- package/dist/verify-sql-schema-DhHnkpPa.d.mts +67 -0
- package/dist/verify-sql-schema-DhHnkpPa.d.mts.map +1 -0
- package/dist/verify.d.mts +31 -0
- package/dist/verify.d.mts.map +1 -0
- package/dist/verify.mjs +3 -0
- package/package.json +35 -46
- package/src/core/assembly.ts +265 -59
- package/src/core/control-adapter.ts +15 -0
- package/src/core/{descriptor.ts → control-descriptor.ts} +15 -11
- package/src/core/{instance.ts → control-instance.ts} +106 -248
- package/src/core/migrations/contract-to-schema-ir.ts +265 -0
- package/src/core/migrations/types.ts +193 -168
- package/src/core/runtime-descriptor.ts +19 -41
- package/src/core/runtime-instance.ts +11 -133
- package/src/core/schema-verify/verify-helpers.ts +201 -105
- package/src/core/schema-verify/verify-sql-schema.ts +918 -413
- package/src/core/verify.ts +4 -13
- package/src/exports/control.ts +29 -6
- package/src/exports/runtime.ts +2 -6
- package/src/exports/schema-verify.ts +10 -2
- package/src/exports/test-utils.ts +1 -1
- package/dist/chunk-BHEGVBY7.js +0 -772
- package/dist/chunk-BHEGVBY7.js.map +0 -1
- package/dist/chunk-SQ2VWYDV.js +0 -589
- package/dist/chunk-SQ2VWYDV.js.map +0 -1
- package/dist/chunk-SU7LN2UH.js +0 -96
- package/dist/chunk-SU7LN2UH.js.map +0 -1
- package/dist/core/assembly.d.ts +0 -25
- package/dist/core/assembly.d.ts.map +0 -1
- package/dist/core/control-adapter.d.ts +0 -42
- package/dist/core/control-adapter.d.ts.map +0 -1
- package/dist/core/descriptor.d.ts +0 -24
- package/dist/core/descriptor.d.ts.map +0 -1
- package/dist/core/instance.d.ts +0 -140
- package/dist/core/instance.d.ts.map +0 -1
- package/dist/core/migrations/plan-helpers.d.ts +0 -20
- package/dist/core/migrations/plan-helpers.d.ts.map +0 -1
- package/dist/core/migrations/policies.d.ts +0 -6
- package/dist/core/migrations/policies.d.ts.map +0 -1
- package/dist/core/migrations/types.d.ts +0 -280
- package/dist/core/migrations/types.d.ts.map +0 -1
- package/dist/core/runtime-descriptor.d.ts +0 -19
- package/dist/core/runtime-descriptor.d.ts.map +0 -1
- package/dist/core/runtime-instance.d.ts +0 -54
- package/dist/core/runtime-instance.d.ts.map +0 -1
- package/dist/core/schema-verify/verify-helpers.d.ts +0 -50
- package/dist/core/schema-verify/verify-helpers.d.ts.map +0 -1
- package/dist/core/schema-verify/verify-sql-schema.d.ts +0 -45
- package/dist/core/schema-verify/verify-sql-schema.d.ts.map +0 -1
- package/dist/core/verify.d.ts +0 -39
- package/dist/core/verify.d.ts.map +0 -1
- package/dist/exports/control-adapter.d.ts +0 -2
- package/dist/exports/control-adapter.d.ts.map +0 -1
- package/dist/exports/control-adapter.js +0 -1
- package/dist/exports/control-adapter.js.map +0 -1
- package/dist/exports/control.d.ts +0 -13
- package/dist/exports/control.d.ts.map +0 -1
- package/dist/exports/control.js +0 -149
- package/dist/exports/control.js.map +0 -1
- package/dist/exports/runtime.d.ts +0 -8
- package/dist/exports/runtime.d.ts.map +0 -1
- package/dist/exports/runtime.js +0 -64
- package/dist/exports/runtime.js.map +0 -1
- package/dist/exports/schema-verify.d.ts +0 -11
- package/dist/exports/schema-verify.d.ts.map +0 -1
- package/dist/exports/schema-verify.js +0 -11
- package/dist/exports/schema-verify.js.map +0 -1
- package/dist/exports/test-utils.d.ts +0 -7
- package/dist/exports/test-utils.d.ts.map +0 -1
- package/dist/exports/test-utils.js +0 -17
- package/dist/exports/test-utils.js.map +0 -1
- package/dist/exports/verify.d.ts +0 -2
- package/dist/exports/verify.d.ts.map +0 -1
- package/dist/exports/verify.js +0 -11
- package/dist/exports/verify.js.map +0 -1
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SQL-specific migration types.
|
|
3
|
-
*
|
|
4
|
-
* These types extend the canonical migration types from the framework control plane
|
|
5
|
-
* with SQL-specific fields for execution (precheck SQL, execute SQL, etc.).
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
1
|
import type { TargetBoundComponentDescriptor } from '@prisma-next/contract/framework-components';
|
|
2
|
+
import type { ColumnDefault, ExecutionMutationDefaultValue } from '@prisma-next/contract/types';
|
|
9
3
|
import type {
|
|
4
|
+
ControlAdapterDescriptor,
|
|
10
5
|
ControlDriverInstance,
|
|
11
6
|
ControlExtensionDescriptor,
|
|
12
7
|
ControlTargetDescriptor,
|
|
@@ -23,109 +18,229 @@ import type {
|
|
|
23
18
|
OperationContext,
|
|
24
19
|
SchemaIssue,
|
|
25
20
|
} from '@prisma-next/core-control-plane/types';
|
|
26
|
-
import type { SqlContract, SqlStorage } from '@prisma-next/sql-contract/types';
|
|
21
|
+
import type { SqlContract, SqlStorage, StorageTypeInstance } from '@prisma-next/sql-contract/types';
|
|
22
|
+
import type { SqlOperationSignature } from '@prisma-next/sql-operations';
|
|
27
23
|
import type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';
|
|
28
24
|
import type { Result } from '@prisma-next/utils/result';
|
|
29
|
-
import type { SqlControlFamilyInstance } from '../instance';
|
|
25
|
+
import type { SqlControlFamilyInstance } from '../control-instance';
|
|
30
26
|
|
|
31
27
|
export type AnyRecord = Readonly<Record<string, unknown>>;
|
|
32
28
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
type ControlMutationDefaultSpan = {
|
|
30
|
+
readonly start: {
|
|
31
|
+
readonly offset: number;
|
|
32
|
+
readonly line: number;
|
|
33
|
+
readonly column: number;
|
|
34
|
+
};
|
|
35
|
+
readonly end: {
|
|
36
|
+
readonly offset: number;
|
|
37
|
+
readonly line: number;
|
|
38
|
+
readonly column: number;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
type ControlMutationDefaultFunctionCall = {
|
|
43
|
+
readonly name: string;
|
|
44
|
+
readonly raw: string;
|
|
45
|
+
readonly args: readonly {
|
|
46
|
+
readonly raw: string;
|
|
47
|
+
readonly span: ControlMutationDefaultSpan;
|
|
48
|
+
}[];
|
|
49
|
+
readonly span: ControlMutationDefaultSpan;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
type ControlMutationDefaultLoweringContext = {
|
|
53
|
+
readonly sourceId: string;
|
|
54
|
+
readonly modelName: string;
|
|
55
|
+
readonly fieldName: string;
|
|
56
|
+
readonly columnCodecId?: string;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export type ControlMutationDefaultFunctionResult =
|
|
60
|
+
| {
|
|
61
|
+
readonly ok: true;
|
|
62
|
+
readonly value:
|
|
63
|
+
| { readonly kind: 'storage'; readonly defaultValue: ColumnDefault }
|
|
64
|
+
| { readonly kind: 'execution'; readonly generated: ExecutionMutationDefaultValue };
|
|
65
|
+
}
|
|
66
|
+
| {
|
|
67
|
+
readonly ok: false;
|
|
68
|
+
readonly diagnostic: {
|
|
69
|
+
readonly code: string;
|
|
70
|
+
readonly message: string;
|
|
71
|
+
readonly sourceId?: string;
|
|
72
|
+
readonly span?: ControlMutationDefaultSpan;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export type ControlMutationDefaultFunctionHandler = (input: {
|
|
77
|
+
readonly call: ControlMutationDefaultFunctionCall;
|
|
78
|
+
readonly context: ControlMutationDefaultLoweringContext;
|
|
79
|
+
}) => ControlMutationDefaultFunctionResult;
|
|
80
|
+
|
|
81
|
+
export interface ControlMutationDefaultFunctionEntry {
|
|
82
|
+
readonly lower: ControlMutationDefaultFunctionHandler;
|
|
83
|
+
readonly usageSignatures?: readonly string[];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface ControlMutationDefaultGeneratorDescriptor {
|
|
87
|
+
readonly id: string;
|
|
88
|
+
readonly applicableCodecIds: readonly string[];
|
|
89
|
+
readonly resolveGeneratedColumnDescriptor?: (input: {
|
|
90
|
+
readonly generated: {
|
|
91
|
+
readonly kind: string;
|
|
92
|
+
readonly id: string;
|
|
93
|
+
readonly params?: Record<string, unknown>;
|
|
94
|
+
};
|
|
95
|
+
}) =>
|
|
96
|
+
| {
|
|
97
|
+
readonly codecId: string;
|
|
98
|
+
readonly nativeType: string;
|
|
99
|
+
readonly typeRef?: string;
|
|
100
|
+
readonly typeParams?: Record<string, unknown>;
|
|
101
|
+
}
|
|
102
|
+
| undefined;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface PslScalarTypeDescriptor {
|
|
106
|
+
readonly codecId: string;
|
|
107
|
+
readonly nativeType: string;
|
|
108
|
+
readonly typeRef?: string;
|
|
109
|
+
readonly typeParams?: Record<string, unknown>;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface SqlControlStaticContributions {
|
|
113
|
+
readonly operationSignatures: () => ReadonlyArray<SqlOperationSignature>;
|
|
114
|
+
readonly controlMutationDefaults?: () => {
|
|
115
|
+
readonly defaultFunctionRegistry: ReadonlyMap<string, ControlMutationDefaultFunctionEntry>;
|
|
116
|
+
readonly generatorDescriptors: ReadonlyArray<ControlMutationDefaultGeneratorDescriptor>;
|
|
117
|
+
};
|
|
118
|
+
readonly pslTypeDescriptors?: () => {
|
|
119
|
+
readonly scalarTypeDescriptors: ReadonlyMap<string, PslScalarTypeDescriptor>;
|
|
120
|
+
};
|
|
121
|
+
}
|
|
36
122
|
|
|
37
|
-
/**
|
|
38
|
-
* A single database dependency declared by a framework component.
|
|
39
|
-
* Uses SqlMigrationPlanOperation so we inherit the existing precheck/execute/postcheck contract.
|
|
40
|
-
*
|
|
41
|
-
* Database dependencies allow components (extensions, adapters) to declare what database-side
|
|
42
|
-
* persistence structures they require (e.g., Postgres extensions, schemas, functions).
|
|
43
|
-
* The planner emits these as migration operations, and the verifier uses the pure verification
|
|
44
|
-
* hook to check satisfaction against the schema IR.
|
|
45
|
-
*/
|
|
46
123
|
export interface ComponentDatabaseDependency<TTargetDetails> {
|
|
47
|
-
/** Stable identifier for the dependency (e.g. 'postgres.extension.vector') */
|
|
48
124
|
readonly id: string;
|
|
49
|
-
/** Human label for output (e.g. 'Enable vector extension') */
|
|
50
125
|
readonly label: string;
|
|
51
|
-
/**
|
|
52
|
-
* Operations that install/ensure the dependency.
|
|
53
|
-
* Use SqlMigrationPlanOperation so we inherit the existing precheck/execute/postcheck contract.
|
|
54
|
-
*/
|
|
55
126
|
readonly install: readonly SqlMigrationPlanOperation<TTargetDetails>[];
|
|
56
|
-
/**
|
|
57
|
-
* Pure verification hook: checks whether this dependency is already installed
|
|
58
|
-
* based on the in-memory schema IR (no DB I/O).
|
|
59
|
-
*
|
|
60
|
-
* This must return structured issues suitable for CLI and tree output, not just a boolean.
|
|
61
|
-
*/
|
|
62
|
-
readonly verifyDatabaseDependencyInstalled: (schema: SqlSchemaIR) => readonly SchemaIssue[];
|
|
63
127
|
}
|
|
64
128
|
|
|
65
|
-
/**
|
|
66
|
-
* Database dependencies declared by a framework component.
|
|
67
|
-
*/
|
|
68
129
|
export interface ComponentDatabaseDependencies<TTargetDetails> {
|
|
69
|
-
/**
|
|
70
|
-
* Dependencies required for db init.
|
|
71
|
-
* Future: update dependencies can be added later (e.g. widening/destructive).
|
|
72
|
-
*/
|
|
73
130
|
readonly init?: readonly ComponentDatabaseDependency<TTargetDetails>[];
|
|
74
131
|
}
|
|
75
132
|
|
|
76
|
-
/**
|
|
77
|
-
* Minimal structural type implemented by any descriptor that can expose
|
|
78
|
-
* component-owned database dependencies. Targets/adapters typically omit
|
|
79
|
-
* the property, while extensions provide dependency metadata.
|
|
80
|
-
*/
|
|
81
133
|
export interface DatabaseDependencyProvider {
|
|
82
134
|
readonly databaseDependencies?: ComponentDatabaseDependencies<unknown>;
|
|
83
135
|
}
|
|
84
136
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
137
|
+
export function isDatabaseDependencyProvider(value: unknown): value is DatabaseDependencyProvider {
|
|
138
|
+
return typeof value === 'object' && value !== null && 'databaseDependencies' in value;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export function collectInitDependencies(
|
|
142
|
+
components: ReadonlyArray<unknown>,
|
|
143
|
+
): readonly ComponentDatabaseDependency<unknown>[] {
|
|
144
|
+
const result: ComponentDatabaseDependency<unknown>[] = [];
|
|
145
|
+
for (const component of components) {
|
|
146
|
+
if (!isDatabaseDependencyProvider(component)) continue;
|
|
147
|
+
const deps = component.databaseDependencies?.init;
|
|
148
|
+
if (!deps) continue;
|
|
149
|
+
result.push(...deps);
|
|
150
|
+
}
|
|
151
|
+
return result;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export interface StorageTypePlanResult<TTargetDetails> {
|
|
155
|
+
readonly operations: readonly SqlMigrationPlanOperation<TTargetDetails>[];
|
|
156
|
+
}
|
|
88
157
|
|
|
89
158
|
/**
|
|
90
|
-
*
|
|
91
|
-
|
|
159
|
+
* Input for expanding parameterized native types.
|
|
160
|
+
*/
|
|
161
|
+
export interface ExpandNativeTypeInput {
|
|
162
|
+
readonly nativeType: string;
|
|
163
|
+
readonly codecId?: string;
|
|
164
|
+
readonly typeParams?: Record<string, unknown>;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Input for resolving an identity-value SQL literal used to backfill existing rows when
|
|
169
|
+
* adding a NOT NULL column without an explicit default.
|
|
92
170
|
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
171
|
+
* "Identity value" in the algebraic (monoid) sense: the neutral element for the type
|
|
172
|
+
* (0 for numbers, '' for strings, false for booleans, etc.).
|
|
95
173
|
*/
|
|
174
|
+
export interface ResolveIdentityValueInput {
|
|
175
|
+
readonly nativeType: string;
|
|
176
|
+
readonly codecId?: string;
|
|
177
|
+
readonly typeParams?: Record<string, unknown>;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export interface CodecControlHooks<TTargetDetails = unknown> {
|
|
181
|
+
planTypeOperations?: (options: {
|
|
182
|
+
readonly typeName: string;
|
|
183
|
+
readonly typeInstance: StorageTypeInstance;
|
|
184
|
+
readonly contract: SqlContract<SqlStorage>;
|
|
185
|
+
readonly schema: SqlSchemaIR;
|
|
186
|
+
readonly schemaName?: string;
|
|
187
|
+
readonly policy: MigrationOperationPolicy;
|
|
188
|
+
}) => StorageTypePlanResult<TTargetDetails>;
|
|
189
|
+
verifyType?: (options: {
|
|
190
|
+
readonly typeName: string;
|
|
191
|
+
readonly typeInstance: StorageTypeInstance;
|
|
192
|
+
readonly schema: SqlSchemaIR;
|
|
193
|
+
readonly schemaName?: string;
|
|
194
|
+
}) => readonly SchemaIssue[];
|
|
195
|
+
introspectTypes?: (options: {
|
|
196
|
+
readonly driver: ControlDriverInstance<'sql', string>;
|
|
197
|
+
readonly schemaName?: string;
|
|
198
|
+
}) => Promise<Record<string, StorageTypeInstance>>;
|
|
199
|
+
/**
|
|
200
|
+
* Expands a parameterized native type to its full SQL representation.
|
|
201
|
+
* Used by schema verification to compare contract types against database types.
|
|
202
|
+
*
|
|
203
|
+
* For example, expands:
|
|
204
|
+
* - { nativeType: 'character varying', typeParams: { length: 255 } } -> 'character varying(255)'
|
|
205
|
+
* - { nativeType: 'numeric', typeParams: { precision: 10, scale: 2 } } -> 'numeric(10,2)'
|
|
206
|
+
*
|
|
207
|
+
* Returns the expanded type string, or the original nativeType if no expansion is needed.
|
|
208
|
+
*/
|
|
209
|
+
expandNativeType?: (input: ExpandNativeTypeInput) => string;
|
|
210
|
+
/**
|
|
211
|
+
* Resolves the identity value (monoid neutral element) as a SQL literal for safely adding
|
|
212
|
+
* a NOT NULL column without an explicit default to a non-empty table.
|
|
213
|
+
*
|
|
214
|
+
* Return semantics:
|
|
215
|
+
* - string: use this literal
|
|
216
|
+
* - null: explicitly no safe identity value is known; fall back to another strategy
|
|
217
|
+
* - undefined: no opinion; planner may use built-in fallbacks
|
|
218
|
+
*/
|
|
219
|
+
resolveIdentityValue?: (input: ResolveIdentityValueInput) => string | null | undefined;
|
|
220
|
+
}
|
|
221
|
+
|
|
96
222
|
export interface SqlControlExtensionDescriptor<TTargetId extends string>
|
|
97
|
-
extends ControlExtensionDescriptor<'sql', TTargetId
|
|
98
|
-
|
|
223
|
+
extends ControlExtensionDescriptor<'sql', TTargetId>,
|
|
224
|
+
SqlControlStaticContributions {
|
|
99
225
|
readonly databaseDependencies?: ComponentDatabaseDependencies<unknown>;
|
|
100
226
|
}
|
|
101
227
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
228
|
+
export interface SqlControlAdapterDescriptor<TTargetId extends string>
|
|
229
|
+
extends ControlAdapterDescriptor<'sql', TTargetId>,
|
|
230
|
+
SqlControlStaticContributions {}
|
|
105
231
|
|
|
106
|
-
/**
|
|
107
|
-
* A single step in a SQL migration operation (precheck, execute, or postcheck).
|
|
108
|
-
*/
|
|
109
232
|
export interface SqlMigrationPlanOperationStep {
|
|
110
233
|
readonly description: string;
|
|
111
234
|
readonly sql: string;
|
|
112
235
|
readonly meta?: AnyRecord;
|
|
113
236
|
}
|
|
114
237
|
|
|
115
|
-
/**
|
|
116
|
-
* Target details for a SQL migration operation (table, column, index, etc.).
|
|
117
|
-
*/
|
|
118
238
|
export interface SqlMigrationPlanOperationTarget<TTargetDetails> {
|
|
119
239
|
readonly id: string;
|
|
120
240
|
readonly details?: TTargetDetails;
|
|
121
241
|
}
|
|
122
242
|
|
|
123
|
-
/**
|
|
124
|
-
* A single SQL migration operation with SQL-specific fields.
|
|
125
|
-
* Extends the core MigrationPlanOperation with SQL execution details.
|
|
126
|
-
*/
|
|
127
243
|
export interface SqlMigrationPlanOperation<TTargetDetails> extends MigrationPlanOperation {
|
|
128
|
-
/** Optional detailed explanation of what this operation does and why. */
|
|
129
244
|
readonly summary?: string;
|
|
130
245
|
readonly target: SqlMigrationPlanOperationTarget<TTargetDetails>;
|
|
131
246
|
readonly precheck: readonly SqlMigrationPlanOperationStep[];
|
|
@@ -134,23 +249,15 @@ export interface SqlMigrationPlanOperation<TTargetDetails> extends MigrationPlan
|
|
|
134
249
|
readonly meta?: AnyRecord;
|
|
135
250
|
}
|
|
136
251
|
|
|
137
|
-
/**
|
|
138
|
-
* Contract identity information for SQL migrations.
|
|
139
|
-
*/
|
|
140
252
|
export interface SqlMigrationPlanContractInfo {
|
|
141
|
-
readonly
|
|
253
|
+
readonly storageHash: string;
|
|
142
254
|
readonly profileHash?: string;
|
|
143
255
|
}
|
|
144
256
|
|
|
145
|
-
/**
|
|
146
|
-
* A SQL migration plan with SQL-specific fields.
|
|
147
|
-
* Extends the core MigrationPlan with origin tracking and metadata.
|
|
148
|
-
*/
|
|
149
257
|
export interface SqlMigrationPlan<TTargetDetails> extends MigrationPlan {
|
|
150
258
|
/**
|
|
151
259
|
* Origin contract identity that the plan expects the database to currently be at.
|
|
152
|
-
* If omitted, the runner
|
|
153
|
-
* and will only proceed if no marker exists (or if the marker already matches destination).
|
|
260
|
+
* If omitted or null, the runner skips origin validation entirely.
|
|
154
261
|
*/
|
|
155
262
|
readonly origin?: SqlMigrationPlanContractInfo | null;
|
|
156
263
|
/**
|
|
@@ -161,71 +268,43 @@ export interface SqlMigrationPlan<TTargetDetails> extends MigrationPlan {
|
|
|
161
268
|
readonly meta?: AnyRecord;
|
|
162
269
|
}
|
|
163
270
|
|
|
164
|
-
// ============================================================================
|
|
165
|
-
// SQL-Specific Planner Types
|
|
166
|
-
// ============================================================================
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Specific conflict kinds for SQL migrations.
|
|
170
|
-
*/
|
|
171
271
|
export type SqlPlannerConflictKind =
|
|
172
272
|
| 'typeMismatch'
|
|
173
273
|
| 'nullabilityConflict'
|
|
174
274
|
| 'indexIncompatible'
|
|
175
275
|
| 'foreignKeyConflict'
|
|
176
276
|
| 'missingButNonAdditive'
|
|
177
|
-
| 'unsupportedExtension'
|
|
178
|
-
| 'extensionMissing'
|
|
179
277
|
| 'unsupportedOperation';
|
|
180
278
|
|
|
181
|
-
/**
|
|
182
|
-
* Location information for SQL planner conflicts.
|
|
183
|
-
*/
|
|
184
279
|
export interface SqlPlannerConflictLocation {
|
|
185
280
|
readonly table?: string;
|
|
186
281
|
readonly column?: string;
|
|
187
282
|
readonly index?: string;
|
|
188
283
|
readonly constraint?: string;
|
|
189
|
-
readonly
|
|
284
|
+
readonly type?: string;
|
|
190
285
|
}
|
|
191
286
|
|
|
192
|
-
/**
|
|
193
|
-
* A SQL-specific planner conflict with additional location information.
|
|
194
|
-
* Extends the core MigrationPlannerConflict.
|
|
195
|
-
*/
|
|
196
287
|
export interface SqlPlannerConflict extends MigrationPlannerConflict {
|
|
197
288
|
readonly kind: SqlPlannerConflictKind;
|
|
198
289
|
readonly location?: SqlPlannerConflictLocation;
|
|
199
290
|
readonly meta?: AnyRecord;
|
|
200
291
|
}
|
|
201
292
|
|
|
202
|
-
/**
|
|
203
|
-
* Successful SQL planner result with the migration plan.
|
|
204
|
-
*/
|
|
205
293
|
export interface SqlPlannerSuccessResult<TTargetDetails>
|
|
206
294
|
extends Omit<MigrationPlannerSuccessResult, 'plan'> {
|
|
207
295
|
readonly kind: 'success';
|
|
208
296
|
readonly plan: SqlMigrationPlan<TTargetDetails>;
|
|
209
297
|
}
|
|
210
298
|
|
|
211
|
-
/**
|
|
212
|
-
* Failed SQL planner result with the list of conflicts.
|
|
213
|
-
*/
|
|
214
299
|
export interface SqlPlannerFailureResult extends Omit<MigrationPlannerFailureResult, 'conflicts'> {
|
|
215
300
|
readonly kind: 'failure';
|
|
216
301
|
readonly conflicts: readonly SqlPlannerConflict[];
|
|
217
302
|
}
|
|
218
303
|
|
|
219
|
-
/**
|
|
220
|
-
* Union type for SQL planner results.
|
|
221
|
-
*/
|
|
222
304
|
export type SqlPlannerResult<TTargetDetails> =
|
|
223
305
|
| SqlPlannerSuccessResult<TTargetDetails>
|
|
224
306
|
| SqlPlannerFailureResult;
|
|
225
307
|
|
|
226
|
-
/**
|
|
227
|
-
* Options for SQL migration planner.
|
|
228
|
-
*/
|
|
229
308
|
export interface SqlMigrationPlannerPlanOptions {
|
|
230
309
|
readonly contract: SqlContract<SqlStorage>;
|
|
231
310
|
readonly schema: SqlSchemaIR;
|
|
@@ -239,29 +318,15 @@ export interface SqlMigrationPlannerPlanOptions {
|
|
|
239
318
|
readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
|
|
240
319
|
}
|
|
241
320
|
|
|
242
|
-
/**
|
|
243
|
-
* SQL migration planner interface.
|
|
244
|
-
* Extends the core MigrationPlanner with SQL-specific types.
|
|
245
|
-
*/
|
|
246
321
|
export interface SqlMigrationPlanner<TTargetDetails> {
|
|
247
322
|
plan(options: SqlMigrationPlannerPlanOptions): SqlPlannerResult<TTargetDetails>;
|
|
248
323
|
}
|
|
249
324
|
|
|
250
|
-
// ============================================================================
|
|
251
|
-
// SQL-Specific Runner Types
|
|
252
|
-
// ============================================================================
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Callbacks for SQL migration runner execution.
|
|
256
|
-
*/
|
|
257
325
|
export interface SqlMigrationRunnerExecuteCallbacks<TTargetDetails> {
|
|
258
326
|
onOperationStart?(operation: SqlMigrationPlanOperation<TTargetDetails>): void;
|
|
259
327
|
onOperationComplete?(operation: SqlMigrationPlanOperation<TTargetDetails>): void;
|
|
260
328
|
}
|
|
261
329
|
|
|
262
|
-
/**
|
|
263
|
-
* Options for SQL migration runner execution.
|
|
264
|
-
*/
|
|
265
330
|
export interface SqlMigrationRunnerExecuteOptions<TTargetDetails> {
|
|
266
331
|
readonly plan: SqlMigrationPlan<TTargetDetails>;
|
|
267
332
|
readonly driver: ControlDriverInstance<'sql', string>;
|
|
@@ -292,9 +357,6 @@ export interface SqlMigrationRunnerExecuteOptions<TTargetDetails> {
|
|
|
292
357
|
readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
|
|
293
358
|
}
|
|
294
359
|
|
|
295
|
-
/**
|
|
296
|
-
* Error codes for SQL migration runner failures.
|
|
297
|
-
*/
|
|
298
360
|
export type SqlMigrationRunnerErrorCode =
|
|
299
361
|
| 'DESTINATION_CONTRACT_MISMATCH'
|
|
300
362
|
| 'MARKER_ORIGIN_MISMATCH'
|
|
@@ -304,73 +366,36 @@ export type SqlMigrationRunnerErrorCode =
|
|
|
304
366
|
| 'SCHEMA_VERIFY_FAILED'
|
|
305
367
|
| 'EXECUTION_FAILED';
|
|
306
368
|
|
|
307
|
-
/**
|
|
308
|
-
* Detailed information about a SQL migration runner failure.
|
|
309
|
-
* Extends the core MigrationRunnerFailure with SQL-specific error codes.
|
|
310
|
-
*/
|
|
311
369
|
export interface SqlMigrationRunnerFailure extends MigrationRunnerFailure {
|
|
312
370
|
readonly code: SqlMigrationRunnerErrorCode;
|
|
313
371
|
readonly meta?: AnyRecord;
|
|
314
372
|
}
|
|
315
373
|
|
|
316
|
-
/**
|
|
317
|
-
* Success value for SQL migration runner execution.
|
|
318
|
-
* Extends core type for type branding and potential SQL-specific extensions.
|
|
319
|
-
*/
|
|
320
374
|
export interface SqlMigrationRunnerSuccessValue extends MigrationRunnerSuccessValue {}
|
|
321
375
|
|
|
322
|
-
/**
|
|
323
|
-
* Result type for SQL migration runner execution.
|
|
324
|
-
*/
|
|
325
376
|
export type SqlMigrationRunnerResult = Result<
|
|
326
377
|
SqlMigrationRunnerSuccessValue,
|
|
327
378
|
SqlMigrationRunnerFailure
|
|
328
379
|
>;
|
|
329
380
|
|
|
330
|
-
/**
|
|
331
|
-
* SQL migration runner interface.
|
|
332
|
-
* Extends the core MigrationRunner with SQL-specific types.
|
|
333
|
-
*/
|
|
334
381
|
export interface SqlMigrationRunner<TTargetDetails> {
|
|
335
382
|
execute(
|
|
336
383
|
options: SqlMigrationRunnerExecuteOptions<TTargetDetails>,
|
|
337
384
|
): Promise<SqlMigrationRunnerResult>;
|
|
338
385
|
}
|
|
339
386
|
|
|
340
|
-
// ============================================================================
|
|
341
|
-
// SQL Control Target Descriptor
|
|
342
|
-
// ============================================================================
|
|
343
|
-
|
|
344
|
-
/**
|
|
345
|
-
* SQL control target descriptor with migration support.
|
|
346
|
-
* Extends the core ControlTargetDescriptor with SQL-specific migration methods.
|
|
347
|
-
*/
|
|
348
387
|
export interface SqlControlTargetDescriptor<TTargetId extends string, TTargetDetails>
|
|
349
388
|
extends ControlTargetDescriptor<
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
* Creates a SQL migration planner for this target.
|
|
357
|
-
* Direct method for SQL-specific usage.
|
|
358
|
-
*/
|
|
389
|
+
'sql',
|
|
390
|
+
TTargetId,
|
|
391
|
+
ControlTargetInstance<'sql', TTargetId>,
|
|
392
|
+
SqlControlFamilyInstance
|
|
393
|
+
>,
|
|
394
|
+
SqlControlStaticContributions {
|
|
359
395
|
createPlanner(family: SqlControlFamilyInstance): SqlMigrationPlanner<TTargetDetails>;
|
|
360
|
-
/**
|
|
361
|
-
* Creates a SQL migration runner for this target.
|
|
362
|
-
* Direct method for SQL-specific usage.
|
|
363
|
-
*/
|
|
364
396
|
createRunner(family: SqlControlFamilyInstance): SqlMigrationRunner<TTargetDetails>;
|
|
365
397
|
}
|
|
366
398
|
|
|
367
|
-
// ============================================================================
|
|
368
|
-
// Helper Types
|
|
369
|
-
// ============================================================================
|
|
370
|
-
|
|
371
|
-
/**
|
|
372
|
-
* Options for creating a SQL migration plan.
|
|
373
|
-
*/
|
|
374
399
|
export interface CreateSqlMigrationPlanOptions<TTargetDetails> {
|
|
375
400
|
readonly targetId: string;
|
|
376
401
|
readonly origin?: SqlMigrationPlanContractInfo | null;
|
|
@@ -1,45 +1,23 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
RuntimeDriverDescriptor,
|
|
4
|
-
RuntimeExtensionDescriptor,
|
|
5
|
-
RuntimeFamilyDescriptor,
|
|
6
|
-
RuntimeTargetDescriptor,
|
|
7
|
-
} from '@prisma-next/core-execution-plane/types';
|
|
8
|
-
import {
|
|
9
|
-
createSqlRuntimeFamilyInstance,
|
|
10
|
-
type SqlRuntimeAdapterInstance,
|
|
11
|
-
type SqlRuntimeDriverInstance,
|
|
12
|
-
type SqlRuntimeFamilyInstance,
|
|
13
|
-
} from './runtime-instance';
|
|
1
|
+
import type { RuntimeFamilyDescriptor } from '@prisma-next/core-execution-plane/types';
|
|
2
|
+
import { createSqlRuntimeFamilyInstance, type SqlRuntimeFamilyInstance } from './runtime-instance';
|
|
14
3
|
|
|
15
4
|
/**
|
|
16
|
-
* SQL
|
|
17
|
-
*
|
|
5
|
+
* SQL execution-plane family descriptor.
|
|
6
|
+
*
|
|
7
|
+
* Note: this is currently named `sqlRuntimeFamilyDescriptor` because the execution plane
|
|
8
|
+
* framework types are still using the `Runtime*` naming (`RuntimeFamilyDescriptor`, etc.).
|
|
9
|
+
*
|
|
10
|
+
* This will be renamed to `sqlExecutionFamilyDescriptor` as part of `TML-1842`.
|
|
18
11
|
*/
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
12
|
+
export const sqlRuntimeFamilyDescriptor: RuntimeFamilyDescriptor<'sql', SqlRuntimeFamilyInstance> =
|
|
13
|
+
{
|
|
14
|
+
kind: 'family',
|
|
15
|
+
id: 'sql',
|
|
16
|
+
familyId: 'sql',
|
|
17
|
+
version: '0.0.1',
|
|
18
|
+
create() {
|
|
19
|
+
return createSqlRuntimeFamilyInstance();
|
|
20
|
+
},
|
|
21
|
+
};
|
|
26
22
|
|
|
27
|
-
|
|
28
|
-
readonly target: RuntimeTargetDescriptor<'sql', TTargetId>;
|
|
29
|
-
readonly adapter: RuntimeAdapterDescriptor<
|
|
30
|
-
'sql',
|
|
31
|
-
TTargetId,
|
|
32
|
-
SqlRuntimeAdapterInstance<TTargetId>
|
|
33
|
-
>;
|
|
34
|
-
readonly driver: RuntimeDriverDescriptor<'sql', TTargetId, SqlRuntimeDriverInstance<TTargetId>>;
|
|
35
|
-
readonly extensionPacks: readonly RuntimeExtensionDescriptor<'sql', TTargetId>[];
|
|
36
|
-
}): SqlRuntimeFamilyInstance {
|
|
37
|
-
return createSqlRuntimeFamilyInstance({
|
|
38
|
-
family: this,
|
|
39
|
-
target: options.target,
|
|
40
|
-
adapter: options.adapter,
|
|
41
|
-
driver: options.driver,
|
|
42
|
-
extensionPacks: options.extensionPacks,
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
}
|
|
23
|
+
Object.freeze(sqlRuntimeFamilyDescriptor);
|