@prisma-next/target-sqlite 0.11.0 → 0.12.0-dev.1
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-CYwMu3-4.d.mts → codec-ids-C4UfWqAE.d.mts} +1 -1
- package/dist/{codec-ids-CYwMu3-4.d.mts.map → codec-ids-C4UfWqAE.d.mts.map} +1 -1
- package/dist/codec-ids.d.mts +1 -1
- package/dist/{codec-types-DNauB5UT.d.mts → codec-types-B2ci-b_W.d.mts} +2 -2
- package/dist/{codec-types-DNauB5UT.d.mts.map → codec-types-B2ci-b_W.d.mts.map} +1 -1
- package/dist/codec-types.d.mts +2 -2
- package/dist/codecs-DVnHtVWW.mjs.map +1 -1
- package/dist/{codecs-BAlEiSeP.d.mts → codecs-DqDWNIKq.d.mts} +2 -2
- package/dist/{codecs-BAlEiSeP.d.mts.map → codecs-DqDWNIKq.d.mts.map} +1 -1
- package/dist/codecs.d.mts +1 -1
- package/dist/codecs.mjs.map +1 -1
- package/dist/control.d.mts +1 -1
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +10 -39
- package/dist/control.mjs.map +1 -1
- package/dist/{default-normalizer-3Fccw7yw.mjs → default-normalizer-CWKVYSxS.mjs} +1 -1
- package/dist/{default-normalizer-3Fccw7yw.mjs.map → default-normalizer-CWKVYSxS.mjs.map} +1 -1
- package/dist/default-normalizer.d.mts.map +1 -1
- package/dist/default-normalizer.mjs +1 -1
- package/dist/descriptor-meta-DIbCXU65.mjs +15 -0
- package/dist/descriptor-meta-DIbCXU65.mjs.map +1 -0
- package/dist/descriptor-meta-runtime-DOcnLfOX.mjs +12 -0
- package/dist/descriptor-meta-runtime-DOcnLfOX.mjs.map +1 -0
- package/dist/migration.d.mts +2 -2
- package/dist/migration.d.mts.map +1 -1
- package/dist/migration.mjs +3 -3
- package/dist/migration.mjs.map +1 -1
- package/dist/{native-type-normalizer-BlN5XfD-.mjs → native-type-normalizer-HvkimyB8.mjs} +1 -1
- package/dist/{native-type-normalizer-BlN5XfD-.mjs.map → native-type-normalizer-HvkimyB8.mjs.map} +1 -1
- package/dist/native-type-normalizer.d.mts.map +1 -1
- package/dist/native-type-normalizer.mjs +1 -1
- package/dist/{op-factory-call-BnPhI25-.mjs → op-factory-call-VBm-wu5R.mjs} +2 -2
- package/dist/{op-factory-call-BnPhI25-.mjs.map → op-factory-call-VBm-wu5R.mjs.map} +1 -1
- package/dist/op-factory-call.d.mts +2 -2
- package/dist/op-factory-call.d.mts.map +1 -1
- package/dist/op-factory-call.mjs +1 -1
- package/dist/pack.d.mts +8 -7
- package/dist/pack.d.mts.map +1 -1
- package/dist/pack.mjs +1 -1
- package/dist/{planner-B9-16QqD.mjs → planner-BBvwGy0f.mjs} +7 -7
- package/dist/{planner-B9-16QqD.mjs.map → planner-BBvwGy0f.mjs.map} +1 -1
- package/dist/{planner-produced-sqlite-migration-CI9LdXPr.d.mts → planner-produced-sqlite-migration-D4FSvPE4.d.mts} +3 -3
- package/dist/planner-produced-sqlite-migration-D4FSvPE4.d.mts.map +1 -0
- package/dist/{planner-produced-sqlite-migration-BqzfeOFu.mjs → planner-produced-sqlite-migration-DF8pnKfG.mjs} +5 -8
- package/dist/planner-produced-sqlite-migration-DF8pnKfG.mjs.map +1 -0
- package/dist/planner-produced-sqlite-migration.d.mts +1 -1
- package/dist/planner-produced-sqlite-migration.mjs +1 -1
- package/dist/{planner-target-details-vhvZDWK1.d.mts → planner-target-details-B-VJkUsu.d.mts} +1 -1
- package/dist/planner-target-details-B-VJkUsu.d.mts.map +1 -0
- package/dist/{planner-target-details-Bm71XPKb.mjs → planner-target-details-BRS591Zt.mjs} +1 -1
- package/dist/{planner-target-details-Bm71XPKb.mjs.map → planner-target-details-BRS591Zt.mjs.map} +1 -1
- package/dist/planner-target-details.d.mts +1 -1
- package/dist/planner-target-details.mjs +1 -1
- package/dist/planner.d.mts +2 -2
- package/dist/planner.d.mts.map +1 -1
- package/dist/planner.mjs +1 -1
- package/dist/{render-ops-CSRDT4YL.mjs → render-ops-ByOBLKVj.mjs} +1 -1
- package/dist/{render-ops-CSRDT4YL.mjs.map → render-ops-ByOBLKVj.mjs.map} +1 -1
- package/dist/render-ops.d.mts +1 -1
- package/dist/render-ops.d.mts.map +1 -1
- package/dist/render-ops.mjs +1 -1
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +2 -2
- package/dist/runtime.mjs.map +1 -1
- package/dist/{shared-qLsgTOZs.d.mts → shared-DDOJntxk.d.mts} +2 -2
- package/dist/shared-DDOJntxk.d.mts.map +1 -0
- package/dist/{sql-utils-DhevMgef.mjs → sql-utils-D0gQAMLB.mjs} +1 -1
- package/dist/{sql-utils-DhevMgef.mjs.map → sql-utils-D0gQAMLB.mjs.map} +1 -1
- package/dist/sql-utils.d.mts.map +1 -1
- package/dist/sql-utils.mjs +1 -1
- package/dist/{sqlite-migration-DAb2NEX6.d.mts → sqlite-migration-Feio34n3.d.mts} +2 -2
- package/dist/sqlite-migration-Feio34n3.d.mts.map +1 -0
- package/dist/{sqlite-migration-BBJktVVw.mjs → sqlite-migration-Lvmtu9IE.mjs} +1 -1
- package/dist/{sqlite-migration-BBJktVVw.mjs.map → sqlite-migration-Lvmtu9IE.mjs.map} +1 -1
- package/dist/{statement-builders-Dne-LkAV.mjs → statement-builders-BiRmeyJM.mjs} +1 -1
- package/dist/statement-builders-BiRmeyJM.mjs.map +1 -0
- package/dist/statement-builders.d.mts +1 -1
- package/dist/statement-builders.d.mts.map +1 -1
- package/dist/statement-builders.mjs +1 -1
- package/dist/{tables-DGRRJasz.mjs → tables-gB0XiFu8.mjs} +4 -4
- package/dist/{tables-DGRRJasz.mjs.map → tables-gB0XiFu8.mjs.map} +1 -1
- package/package.json +29 -18
- package/src/core/authoring.ts +1 -1
- package/src/core/descriptor-meta-runtime.ts +28 -0
- package/src/core/descriptor-meta.ts +2 -6
- package/src/core/migrations/planner-produced-sqlite-migration.ts +0 -2
- package/src/core/migrations/render-typescript.ts +1 -5
- package/src/core/migrations/runner.ts +11 -60
- package/src/core/migrations/statement-builders.ts +1 -1
- package/src/core/runtime-target.ts +2 -2
- package/dist/descriptor-meta-CE2Kbn9b.mjs +0 -17
- package/dist/descriptor-meta-CE2Kbn9b.mjs.map +0 -1
- package/dist/planner-produced-sqlite-migration-BqzfeOFu.mjs.map +0 -1
- package/dist/planner-produced-sqlite-migration-CI9LdXPr.d.mts.map +0 -1
- package/dist/planner-target-details-vhvZDWK1.d.mts.map +0 -1
- package/dist/shared-qLsgTOZs.d.mts.map +0 -1
- package/dist/sqlite-migration-DAb2NEX6.d.mts.map +0 -1
- package/dist/statement-builders-Dne-LkAV.mjs.map +0 -1
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import type { CodecTypes } from '../exports/codec-types';
|
|
2
2
|
import { sqliteAuthoringFieldPresets } from './authoring';
|
|
3
|
+
import { sqliteTargetDescriptorMetaRuntime } from './descriptor-meta-runtime';
|
|
3
4
|
|
|
4
5
|
const sqliteTargetDescriptorMetaBase = {
|
|
5
|
-
|
|
6
|
-
familyId: 'sql',
|
|
7
|
-
targetId: 'sqlite',
|
|
8
|
-
id: 'sqlite',
|
|
9
|
-
version: '0.0.1',
|
|
10
|
-
capabilities: {},
|
|
6
|
+
...sqliteTargetDescriptorMetaRuntime,
|
|
11
7
|
authoring: {
|
|
12
8
|
field: sqliteAuthoringFieldPresets,
|
|
13
9
|
},
|
|
@@ -4,7 +4,6 @@ import type {
|
|
|
4
4
|
OpFactoryCall,
|
|
5
5
|
} from '@prisma-next/framework-components/control';
|
|
6
6
|
import type { MigrationMeta } from '@prisma-next/migration-tools/migration';
|
|
7
|
-
import { ifDefined } from '@prisma-next/utils/defined';
|
|
8
7
|
import type { SqlitePlanTargetDetails } from './planner-target-details';
|
|
9
8
|
import { renderOps } from './render-ops';
|
|
10
9
|
import { renderCallsToTypeScript } from './render-typescript';
|
|
@@ -64,7 +63,6 @@ export class TypeScriptRenderableSqliteMigration
|
|
|
64
63
|
return renderCallsToTypeScript(this.#calls, {
|
|
65
64
|
from: this.#meta.from,
|
|
66
65
|
to: this.#meta.to,
|
|
67
|
-
...ifDefined('labels', this.#meta.labels),
|
|
68
66
|
});
|
|
69
67
|
}
|
|
70
68
|
}
|
|
@@ -6,12 +6,11 @@
|
|
|
6
6
|
|
|
7
7
|
import type { OpFactoryCall } from '@prisma-next/framework-components/control';
|
|
8
8
|
import { detectScaffoldRuntime, shebangLineFor } from '@prisma-next/migration-tools/migration-ts';
|
|
9
|
-
import { type ImportRequirement,
|
|
9
|
+
import { type ImportRequirement, renderImports } from '@prisma-next/ts-render';
|
|
10
10
|
|
|
11
11
|
export interface RenderMigrationMeta {
|
|
12
12
|
readonly from: string | null;
|
|
13
13
|
readonly to: string;
|
|
14
|
-
readonly labels?: readonly string[];
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
/**
|
|
@@ -73,9 +72,6 @@ function buildDescribeMethod(meta: RenderMigrationMeta): string {
|
|
|
73
72
|
lines.push(' return {');
|
|
74
73
|
lines.push(` from: ${JSON.stringify(meta.from)},`);
|
|
75
74
|
lines.push(` to: ${JSON.stringify(meta.to)},`);
|
|
76
|
-
if (meta.labels && meta.labels.length > 0) {
|
|
77
|
-
lines.push(` labels: ${jsonToTsSource(meta.labels)},`);
|
|
78
|
-
}
|
|
79
75
|
lines.push(' };');
|
|
80
76
|
lines.push(' }');
|
|
81
77
|
lines.push('');
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { ContractMarkerRecord } from '@prisma-next/contract/types';
|
|
2
2
|
import type {
|
|
3
3
|
MigrationOperationPolicy,
|
|
4
|
-
MultiSpaceRunnerResult,
|
|
5
4
|
SqlControlFamilyInstance,
|
|
6
5
|
SqlMigrationPlanContractInfo,
|
|
7
6
|
SqlMigrationPlanOperation,
|
|
@@ -15,7 +14,10 @@ import type {
|
|
|
15
14
|
import { runnerFailure, runnerSuccess } from '@prisma-next/family-sql/control';
|
|
16
15
|
import { verifySqlSchema } from '@prisma-next/family-sql/schema-verify';
|
|
17
16
|
import { type ContractMarkerRow, parseContractMarkerRow } from '@prisma-next/family-sql/verify';
|
|
18
|
-
import type {
|
|
17
|
+
import type {
|
|
18
|
+
ControlDriverInstance,
|
|
19
|
+
MigrationRunnerResult,
|
|
20
|
+
} from '@prisma-next/framework-components/control';
|
|
19
21
|
import { APP_SPACE_ID } from '@prisma-next/framework-components/control';
|
|
20
22
|
import { ifDefined } from '@prisma-next/utils/defined';
|
|
21
23
|
import type { Result } from '@prisma-next/utils/result';
|
|
@@ -42,63 +44,11 @@ export function createSqliteMigrationRunner(
|
|
|
42
44
|
class SqliteMigrationRunner implements SqlMigrationRunner<SqlitePlanTargetDetails> {
|
|
43
45
|
constructor(private readonly family: SqlControlFamilyInstance) {}
|
|
44
46
|
|
|
45
|
-
async execute(
|
|
46
|
-
options: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>,
|
|
47
|
-
): Promise<SqlMigrationRunnerResult> {
|
|
48
|
-
const driver = options.driver;
|
|
49
|
-
|
|
50
|
-
const destinationCheck = this.ensurePlanMatchesDestinationContract(
|
|
51
|
-
options.plan.destination,
|
|
52
|
-
options.destinationContract,
|
|
53
|
-
);
|
|
54
|
-
if (!destinationCheck.ok) return destinationCheck;
|
|
55
|
-
|
|
56
|
-
const policyCheck = this.enforcePolicyCompatibility(options.policy, options.plan.operations);
|
|
57
|
-
if (!policyCheck.ok) return policyCheck;
|
|
58
|
-
|
|
59
|
-
// SQLite recreate-table drops and rebuilds the table. If foreign_keys is ON,
|
|
60
|
-
// dropping a referenced parent cascade-deletes child rows; we must disable FK
|
|
61
|
-
// enforcement for the duration of the migration and validate integrity before
|
|
62
|
-
// committing. PRAGMA foreign_keys is a no-op inside a transaction, so toggle
|
|
63
|
-
// around BEGIN/COMMIT.
|
|
64
|
-
const fkWasEnabled = await this.readForeignKeysEnabled(driver);
|
|
65
|
-
if (fkWasEnabled) {
|
|
66
|
-
await driver.query('PRAGMA foreign_keys = OFF');
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
try {
|
|
70
|
-
await this.beginExclusiveTransaction(driver);
|
|
71
|
-
let committed = false;
|
|
72
|
-
try {
|
|
73
|
-
const result = await this.executeOnConnection(options);
|
|
74
|
-
if (!result.ok) return result;
|
|
75
|
-
|
|
76
|
-
if (fkWasEnabled) {
|
|
77
|
-
const fkIntegrityCheck = await this.verifyForeignKeyIntegrity(driver);
|
|
78
|
-
if (!fkIntegrityCheck.ok) return fkIntegrityCheck;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
await this.commitTransaction(driver);
|
|
82
|
-
committed = true;
|
|
83
|
-
return result;
|
|
84
|
-
} finally {
|
|
85
|
-
if (!committed) {
|
|
86
|
-
await this.rollbackTransaction(driver);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
} finally {
|
|
90
|
-
if (fkWasEnabled) {
|
|
91
|
-
await driver.query('PRAGMA foreign_keys = ON');
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
47
|
/**
|
|
97
48
|
* Apply the plan against an already-open connection without managing
|
|
98
|
-
* the transaction lifecycle. The caller
|
|
99
|
-
* and any connection-level setup (FK pragma
|
|
100
|
-
* check).
|
|
101
|
-
* across contract spaces inside one outer transaction.
|
|
49
|
+
* the transaction lifecycle. The caller ({@link SqliteMigrationRunner.execute})
|
|
50
|
+
* owns BEGIN/COMMIT/ROLLBACK and any connection-level setup (FK pragma
|
|
51
|
+
* toggle, FK integrity check).
|
|
102
52
|
*/
|
|
103
53
|
async executeOnConnection(
|
|
104
54
|
options: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>,
|
|
@@ -186,12 +136,12 @@ class SqliteMigrationRunner implements SqlMigrationRunner<SqlitePlanTargetDetail
|
|
|
186
136
|
});
|
|
187
137
|
}
|
|
188
138
|
|
|
189
|
-
async
|
|
139
|
+
async execute(options: {
|
|
190
140
|
readonly driver: ControlDriverInstance<'sql', string>;
|
|
191
141
|
readonly perSpaceOptions: ReadonlyArray<
|
|
192
142
|
SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>
|
|
193
143
|
>;
|
|
194
|
-
}): Promise<
|
|
144
|
+
}): Promise<MigrationRunnerResult> {
|
|
195
145
|
const driver = options.driver;
|
|
196
146
|
const perSpaceOptions = options.perSpaceOptions;
|
|
197
147
|
|
|
@@ -200,7 +150,8 @@ class SqliteMigrationRunner implements SqlMigrationRunner<SqlitePlanTargetDetail
|
|
|
200
150
|
}
|
|
201
151
|
|
|
202
152
|
// FK pragma toggle and the FK integrity check both span the outer
|
|
203
|
-
// transaction
|
|
153
|
+
// transaction: PRAGMA foreign_keys is a no-op inside a transaction, so the
|
|
154
|
+
// toggle has to wrap BEGIN/COMMIT.
|
|
204
155
|
const fkWasEnabled = await this.readForeignKeysEnabled(driver);
|
|
205
156
|
if (fkWasEnabled) {
|
|
206
157
|
await driver.query('PRAGMA foreign_keys = OFF');
|
|
@@ -80,7 +80,7 @@ export interface WriteMarkerInput {
|
|
|
80
80
|
* Logical space identifier for this marker row. Required at every
|
|
81
81
|
* call site so the type system surfaces every place that needs to
|
|
82
82
|
* thread the value (rather than letting an `?? APP_SPACE_ID`
|
|
83
|
-
* fall-through silently collapse
|
|
83
|
+
* fall-through silently collapse per-space markers onto the
|
|
84
84
|
* `'app'` row). App-plan callers pass {@link APP_SPACE_ID}
|
|
85
85
|
* (`'app'`); per-extension callers pass the extension's space id.
|
|
86
86
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RuntimeTargetInstance } from '@prisma-next/framework-components/execution';
|
|
2
2
|
import type { SqlRuntimeTargetDescriptor } from '@prisma-next/sql-runtime';
|
|
3
|
-
import {
|
|
3
|
+
import { sqliteTargetDescriptorMetaRuntime } from './descriptor-meta-runtime';
|
|
4
4
|
|
|
5
5
|
export interface SqliteRuntimeTargetInstance extends RuntimeTargetInstance<'sql', 'sqlite'> {}
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@ const sqliteRuntimeTargetDescriptor: SqlRuntimeTargetDescriptor<
|
|
|
8
8
|
'sqlite',
|
|
9
9
|
SqliteRuntimeTargetInstance
|
|
10
10
|
> = {
|
|
11
|
-
...
|
|
11
|
+
...sqliteTargetDescriptorMetaRuntime,
|
|
12
12
|
codecs: () => [],
|
|
13
13
|
create(): SqliteRuntimeTargetInstance {
|
|
14
14
|
return {
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { temporalAuthoringPresets } from "@prisma-next/family-sql/control";
|
|
2
|
-
const sqliteTargetDescriptorMeta = {
|
|
3
|
-
kind: "target",
|
|
4
|
-
familyId: "sql",
|
|
5
|
-
targetId: "sqlite",
|
|
6
|
-
id: "sqlite",
|
|
7
|
-
version: "0.0.1",
|
|
8
|
-
capabilities: {},
|
|
9
|
-
authoring: { field: { temporal: temporalAuthoringPresets({
|
|
10
|
-
codecId: "sqlite/datetime@1",
|
|
11
|
-
nativeType: "text"
|
|
12
|
-
}) } }
|
|
13
|
-
};
|
|
14
|
-
//#endregion
|
|
15
|
-
export { sqliteTargetDescriptorMeta as t };
|
|
16
|
-
|
|
17
|
-
//# sourceMappingURL=descriptor-meta-CE2Kbn9b.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"descriptor-meta-CE2Kbn9b.mjs","names":[],"sources":["../src/core/authoring.ts","../src/core/descriptor-meta.ts"],"sourcesContent":["import { temporalAuthoringPresets } from '@prisma-next/family-sql/control';\nimport type { AuthoringFieldNamespace } from '@prisma-next/framework-components/authoring';\n\nexport const sqliteAuthoringFieldPresets = {\n temporal: temporalAuthoringPresets({\n codecId: 'sqlite/datetime@1',\n nativeType: 'text',\n }),\n} as const satisfies AuthoringFieldNamespace;\n","import type { CodecTypes } from '../exports/codec-types';\nimport { sqliteAuthoringFieldPresets } from './authoring';\n\nconst sqliteTargetDescriptorMetaBase = {\n kind: 'target',\n familyId: 'sql',\n targetId: 'sqlite',\n id: 'sqlite',\n version: '0.0.1',\n capabilities: {},\n authoring: {\n field: sqliteAuthoringFieldPresets,\n },\n} as const;\n\nexport const sqliteTargetDescriptorMeta: typeof sqliteTargetDescriptorMetaBase & {\n readonly __codecTypes?: CodecTypes;\n} = sqliteTargetDescriptorMetaBase;\n"],"mappings":";ACeA,MAAa,6BAET;CAbF,MAAM;CACN,UAAU;CACV,UAAU;CACV,IAAI;CACJ,SAAS;CACT,cAAc,EAAE;CAChB,WAAW,EACT,OAAO,EDPT,UAAU,yBAAyB;EACjC,SAAS;EACT,YAAY;EACb,CAAC,ECIO,EACR;CAKC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"planner-produced-sqlite-migration-BqzfeOFu.mjs","names":["#calls","#meta","#destination","#spaceId"],"sources":["../src/core/migrations/render-typescript.ts","../src/core/migrations/planner-produced-sqlite-migration.ts"],"sourcesContent":["/**\n * Polymorphic TypeScript emitter for the SQLite migration IR. Mirrors the\n * Postgres `render-typescript.ts` — different base-class + factory module\n * specifier, same overall shape.\n */\n\nimport type { OpFactoryCall } from '@prisma-next/framework-components/control';\nimport { detectScaffoldRuntime, shebangLineFor } from '@prisma-next/migration-tools/migration-ts';\nimport { type ImportRequirement, jsonToTsSource, renderImports } from '@prisma-next/ts-render';\n\nexport interface RenderMigrationMeta {\n readonly from: string | null;\n readonly to: string;\n readonly labels?: readonly string[];\n}\n\n/**\n * Always-present base imports for the rendered scaffold. Both come from\n * `@prisma-next/sqlite/migration` so an authored SQLite\n * `migration.ts` only needs a single dependency for its base class and\n * its CLI entrypoint. Mirrors Postgres's `BASE_IMPORTS`.\n *\n * - `Migration` — the facade re-export fixes the `SqlMigration`\n * generic to `SqlitePlanTargetDetails` and the abstract `targetId` to\n * `'sqlite'`.\n * - `MigrationCLI` — the migration-file CLI entrypoint, re-exported from\n * `@prisma-next/cli/migration-cli`. Loads `prisma-next.config.ts`,\n * assembles a `ControlStack`, and instantiates the migration class.\n */\nconst BASE_IMPORTS: readonly ImportRequirement[] = [\n { moduleSpecifier: '@prisma-next/sqlite/migration', symbol: 'Migration' },\n { moduleSpecifier: '@prisma-next/sqlite/migration', symbol: 'MigrationCLI' },\n];\n\nexport function renderCallsToTypeScript(\n calls: ReadonlyArray<OpFactoryCall>,\n meta: RenderMigrationMeta,\n): string {\n const imports = buildImports(calls);\n const operationsBody = calls.map((c) => c.renderTypeScript()).join(',\\n');\n\n return [\n shebangLineFor(detectScaffoldRuntime()),\n imports,\n '',\n 'export default class M extends Migration {',\n buildDescribeMethod(meta),\n ' override get operations() {',\n ' return [',\n indent(operationsBody, 6),\n ' ];',\n ' }',\n '}',\n '',\n 'MigrationCLI.run(import.meta.url, M);',\n '',\n ].join('\\n');\n}\n\nfunction buildImports(calls: ReadonlyArray<OpFactoryCall>): string {\n const requirements: ImportRequirement[] = [...BASE_IMPORTS];\n for (const call of calls) {\n for (const req of call.importRequirements()) {\n requirements.push(req);\n }\n }\n return renderImports(requirements);\n}\n\nfunction buildDescribeMethod(meta: RenderMigrationMeta): string {\n const lines: string[] = [];\n lines.push(' override describe() {');\n lines.push(' return {');\n lines.push(` from: ${JSON.stringify(meta.from)},`);\n lines.push(` to: ${JSON.stringify(meta.to)},`);\n if (meta.labels && meta.labels.length > 0) {\n lines.push(` labels: ${jsonToTsSource(meta.labels)},`);\n }\n lines.push(' };');\n lines.push(' }');\n lines.push('');\n return lines.join('\\n');\n}\n\nfunction indent(text: string, spaces: number): string {\n const pad = ' '.repeat(spaces);\n return text\n .split('\\n')\n .map((line) => (line.trim() ? `${pad}${line}` : line))\n .join('\\n');\n}\n","import type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type {\n MigrationPlanWithAuthoringSurface,\n OpFactoryCall,\n} from '@prisma-next/framework-components/control';\nimport type { MigrationMeta } from '@prisma-next/migration-tools/migration';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport type { SqlitePlanTargetDetails } from './planner-target-details';\nimport { renderOps } from './render-ops';\nimport { renderCallsToTypeScript } from './render-typescript';\nimport { SqliteMigration } from './sqlite-migration';\n\ntype Op = SqlMigrationPlanOperation<SqlitePlanTargetDetails>;\n\nexport interface SqliteMigrationDestinationInfo {\n readonly storageHash: string;\n readonly profileHash?: string;\n}\n\nexport class TypeScriptRenderableSqliteMigration\n extends SqliteMigration\n implements MigrationPlanWithAuthoringSurface\n{\n readonly #calls: readonly OpFactoryCall[];\n readonly #meta: MigrationMeta;\n readonly #destination: SqliteMigrationDestinationInfo;\n readonly #spaceId: string;\n\n constructor(\n calls: readonly OpFactoryCall[],\n meta: MigrationMeta,\n spaceId: string,\n destination?: SqliteMigrationDestinationInfo,\n ) {\n super();\n this.#calls = calls;\n this.#meta = meta;\n this.#spaceId = spaceId;\n this.#destination = destination ?? { storageHash: meta.to };\n }\n\n override get operations(): readonly Op[] {\n return renderOps(this.#calls);\n }\n\n override describe(): MigrationMeta {\n return this.#meta;\n }\n\n override get destination(): SqliteMigrationDestinationInfo {\n return this.#destination;\n }\n\n /**\n * Contract space this planner-produced plan applies to. Threaded\n * from {@link SqlMigrationPlannerPlanOptions.spaceId} so the runner\n * keys the marker row by the right space when executing the plan.\n */\n get spaceId(): string {\n return this.#spaceId;\n }\n\n renderTypeScript(): string {\n return renderCallsToTypeScript(this.#calls, {\n from: this.#meta.from,\n to: this.#meta.to,\n ...ifDefined('labels', this.#meta.labels),\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA6BA,MAAM,eAA6C,CACjD;CAAE,iBAAiB;CAAiC,QAAQ;CAAa,EACzE;CAAE,iBAAiB;CAAiC,QAAQ;CAAgB,CAC7E;AAED,SAAgB,wBACd,OACA,MACQ;CACR,MAAM,UAAU,aAAa,MAAM;CACnC,MAAM,iBAAiB,MAAM,KAAK,MAAM,EAAE,kBAAkB,CAAC,CAAC,KAAK,MAAM;CAEzE,OAAO;EACL,eAAe,uBAAuB,CAAC;EACvC;EACA;EACA;EACA,oBAAoB,KAAK;EACzB;EACA;EACA,OAAO,gBAAgB,EAAE;EACzB;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,KAAK,KAAK;;AAGd,SAAS,aAAa,OAA6C;CACjE,MAAM,eAAoC,CAAC,GAAG,aAAa;CAC3D,KAAK,MAAM,QAAQ,OACjB,KAAK,MAAM,OAAO,KAAK,oBAAoB,EACzC,aAAa,KAAK,IAAI;CAG1B,OAAO,cAAc,aAAa;;AAGpC,SAAS,oBAAoB,MAAmC;CAC9D,MAAM,QAAkB,EAAE;CAC1B,MAAM,KAAK,0BAA0B;CACrC,MAAM,KAAK,eAAe;CAC1B,MAAM,KAAK,eAAe,KAAK,UAAU,KAAK,KAAK,CAAC,GAAG;CACvD,MAAM,KAAK,aAAa,KAAK,UAAU,KAAK,GAAG,CAAC,GAAG;CACnD,IAAI,KAAK,UAAU,KAAK,OAAO,SAAS,GACtC,MAAM,KAAK,iBAAiB,eAAe,KAAK,OAAO,CAAC,GAAG;CAE7D,MAAM,KAAK,SAAS;CACpB,MAAM,KAAK,MAAM;CACjB,MAAM,KAAK,GAAG;CACd,OAAO,MAAM,KAAK,KAAK;;AAGzB,SAAS,OAAO,MAAc,QAAwB;CACpD,MAAM,MAAM,IAAI,OAAO,OAAO;CAC9B,OAAO,KACJ,MAAM,KAAK,CACX,KAAK,SAAU,KAAK,MAAM,GAAG,GAAG,MAAM,SAAS,KAAM,CACrD,KAAK,KAAK;;;;ACtEf,IAAa,sCAAb,cACU,gBAEV;CACE;CACA;CACA;CACA;CAEA,YACE,OACA,MACA,SACA,aACA;EACA,OAAO;EACP,KAAKA,SAAS;EACd,KAAKC,QAAQ;EACb,KAAKE,WAAW;EAChB,KAAKD,eAAe,eAAe,EAAE,aAAa,KAAK,IAAI;;CAG7D,IAAa,aAA4B;EACvC,OAAO,UAAU,KAAKF,OAAO;;CAG/B,WAAmC;EACjC,OAAO,KAAKC;;CAGd,IAAa,cAA8C;EACzD,OAAO,KAAKC;;;;;;;CAQd,IAAI,UAAkB;EACpB,OAAO,KAAKC;;CAGd,mBAA2B;EACzB,OAAO,wBAAwB,KAAKH,QAAQ;GAC1C,MAAM,KAAKC,MAAM;GACjB,IAAI,KAAKA,MAAM;GACf,GAAG,UAAU,UAAU,KAAKA,MAAM,OAAO;GAC1C,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"planner-produced-sqlite-migration-CI9LdXPr.d.mts","names":[],"sources":["../src/core/migrations/planner-produced-sqlite-migration.ts"],"mappings":";;;;;;;KAYK,EAAA,GAAK,yBAAA,CAA0B,uBAAA;AAAA,UAEnB,8BAAA;EAAA,SACN,WAAA;EAAA,SACA,WAAA;AAAA;AAAA,cAGE,mCAAA,SACH,eAAA,YACG,iCAAA;EAAA;cAQT,KAAA,WAAgB,aAAA,IAChB,IAAA,EAAM,aAAA,EACN,OAAA,UACA,WAAA,GAAc,8BAAA;EAAA,IASH,UAAA,CAAA,YAAuB,EAAA;EAI3B,QAAA,CAAA,GAAY,aAAA;EAAA,IAIR,WAAA,CAAA,GAAe,8BAAA;EAjCR;AAGtB;;;;EAHsB,IA0ChB,OAAA,CAAA;EAIJ,gBAAA,CAAA;AAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"planner-target-details-vhvZDWK1.d.mts","names":[],"sources":["../src/core/migrations/planner-target-details.ts"],"mappings":";KAEY,cAAA;AAAA,UAMK,uBAAA;EAAA,SACN,MAAA;EAAA,SACA,UAAA,EAAY,cAAA;EAAA,SACZ,IAAA;EAAA,SACA,KAAA;AAAA;AAAA,iBASK,kBAAA,CACd,UAAA,EAAY,cAAA,EACZ,IAAA,UACA,KAAA,YACC,uBAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shared-qLsgTOZs.d.mts","names":[],"sources":["../src/core/migrations/operations/shared.ts"],"mappings":";;;;;KAKY,EAAA,GAAK,yBAAA,CAA0B,uBAAA;;;AAsB3C;;;;;;;;;;;AAQA;;;UARiB,gBAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;EAAA,SACA,UAAA;EAAA,SACA,QAAA;EAAA,SACA,6BAAA;AAAA;AAAA,UAGM,oBAAA;EAAA,SACN,OAAA;AAAA;AAAA,UAGM,gBAAA;EAAA,SACN,OAAA;EAAA,SACA,IAAA;AAAA;AAAA,UAGM,oBAAA;EAAA,SACN,OAAA;EAAA,SACA,UAAA;IAAA,SACE,KAAA;IAAA,SACA,OAAA;EAAA;EAAA,SAEF,IAAA;EAAA,SACA,QAAA,GAAW,iBAAA;EAAA,SACX,QAAA,GAAW,iBAAA;EAAA,SACX,UAAA;AAAA;;;;;UAOM,eAAA;EAAA,SACN,OAAA,WAAkB,gBAAA;EAAA,SAClB,UAAA,GAAa,oBAAA;EAAA,SACb,OAAA,YAAmB,gBAAA;EAAA,SACnB,WAAA,YAAuB,oBAAA;AAAA;;;;;;UAQjB,eAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;AAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sqlite-migration-DAb2NEX6.d.mts","names":[],"sources":["../src/core/migrations/sqlite-migration.ts"],"mappings":";;;;;;AAUA;;;;;uBAAsB,eAAA,SAAwB,SAAA,CAAa,uBAAA;EAAA,SAChD,QAAA;AAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"statement-builders-Dne-LkAV.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 MARKER_TABLE_NAME = '_prisma_marker';\nexport const LEDGER_TABLE_NAME = '_prisma_ledger';\n\n/**\n * Control tables the runner creates/manages. The planner must not drop these\n * when reconciling \"extra\" tables against the contract.\n */\nexport const CONTROL_TABLE_NAMES: ReadonlySet<string> = new Set([\n MARKER_TABLE_NAME,\n LEDGER_TABLE_NAME,\n]);\n\n/**\n * Schema for `_prisma_marker`. The `space TEXT PRIMARY KEY` shape\n * supports one row per loaded contract space (`'app'`,\n * `'<extension-id>'`, …); brand-new databases create this shape\n * directly. The migration runner detects pre-1.0 single-row markers\n * (no `space` column) at boot and fails with a structured\n * `LEGACY_MARKER_SHAPE` error rather than auto-rebuilding the table —\n * see `specs/framework-mechanism.spec.md § 2`.\n */\nexport const ensureMarkerTableStatement: SqlStatement = {\n sql: `CREATE TABLE IF NOT EXISTS _prisma_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 TEXT,\n canonical_version INTEGER,\n updated_at TEXT NOT NULL DEFAULT (datetime('now')),\n app_tag TEXT,\n meta TEXT 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_ledger (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n created_at TEXT NOT NULL DEFAULT (datetime('now')),\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 TEXT,\n contract_json_after TEXT,\n operations TEXT NOT NULL\n )`,\n params: [],\n};\n\nexport function readMarkerStatement(space: string): SqlStatement {\n return {\n sql: `SELECT\n core_hash,\n profile_hash,\n contract_json,\n canonical_version,\n updated_at,\n app_tag,\n meta,\n invariants\n FROM _prisma_marker\n WHERE space = ?`,\n params: [space],\n };\n}\n\nexport interface WriteMarkerInput {\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 multi-space markers onto the\n * `'app'` row). App-plan callers pass {@link APP_SPACE_ID}\n * (`'app'`); per-extension callers 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 write into `marker.invariants`. Stored as a JSON-encoded\n * TEXT array — SQLite has no native array type. The runner is responsible\n * for merging with the existing column (no SQL-side merge here, unlike\n * Postgres) before passing them in: BEGIN EXCLUSIVE on the migration\n * transaction makes the read-then-merge-then-write sequence safe.\n */\n readonly invariants: readonly string[];\n}\n\nexport function buildWriteMarkerStatements(input: WriteMarkerInput): {\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 jsonParam(input.invariants),\n ];\n\n return {\n insert: {\n sql: `INSERT INTO _prisma_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 ?,\n ?,\n ?,\n ?,\n ?,\n datetime('now'),\n ?,\n ?,\n ?\n )`,\n params,\n },\n update: {\n sql: `UPDATE _prisma_marker SET\n core_hash = ?,\n profile_hash = ?,\n contract_json = ?,\n canonical_version = ?,\n updated_at = datetime('now'),\n app_tag = ?,\n meta = ?,\n invariants = ?\n WHERE space = ?`,\n params: [\n input.storageHash,\n input.profileHash,\n jsonParam(input.contractJson),\n input.canonicalVersion ?? null,\n input.appTag ?? null,\n jsonParam(input.meta ?? {}),\n jsonParam(input.invariants),\n input.space,\n ],\n },\n };\n}\n\nexport interface LedgerInsertInput {\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_ledger (\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 ?,\n ?,\n ?,\n ?,\n ?,\n ?,\n ?\n )`,\n params: [\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,oBAAoB;AACjC,MAAa,oBAAoB;;;;;AAMjC,MAAa,sBAA2C,IAAI,IAAI,CAC9D,mBACA,kBACD,CAAC;;;;;;;;;;AAWF,MAAa,6BAA2C;CACtD,KAAK;+CACwCA,eAAa;;;;;;;;;;CAU1D,QAAQ,EAAE;CACX;AAED,MAAa,6BAA2C;CACtD,KAAK;;;;;;;;;;;CAWL,QAAQ,EAAE;CACX;AAED,SAAgB,oBAAoB,OAA6B;CAC/D,OAAO;EACL,KAAK;;;;;;;;;;;EAWL,QAAQ,CAAC,MAAM;EAChB;;AA6BH,SAAgB,2BAA2B,OAGzC;CAYA,OAAO;EACL,QAAQ;GACN,KAAK;;;;;;;;;;;;;;;;;;;;;GAqBL,QAAA;IAjCF,MAAM;IACN,MAAM;IACN,MAAM;IACN,UAAU,MAAM,aAAa;IAC7B,MAAM,oBAAoB;IAC1B,MAAM,UAAU;IAChB,UAAU,MAAM,QAAQ,EAAE,CAAC;IAC3B,UAAU,MAAM,WAAW;IA0BnB;GACP;EACD,QAAQ;GACN,KAAK;;;;;;;;;;GAUL,QAAQ;IACN,MAAM;IACN,MAAM;IACN,UAAU,MAAM,aAAa;IAC7B,MAAM,oBAAoB;IAC1B,MAAM,UAAU;IAChB,UAAU,MAAM,QAAQ,EAAE,CAAC;IAC3B,UAAU,MAAM,WAAW;IAC3B,MAAM;IACP;GACF;EACF;;AAaH,SAAgB,2BAA2B,OAAwC;CACjF,OAAO;EACL,KAAK;;;;;;;;;;;;;;;;;EAiBL,QAAQ;GACN,MAAM,qBAAqB;GAC3B,MAAM,qBAAqB;GAC3B,MAAM;GACN,MAAM,0BAA0B;GAChC,UAAU,MAAM,mBAAmB;GACnC,UAAU,MAAM,kBAAkB;GAClC,UAAU,MAAM,WAAW;GAC5B;EACF;;AAGH,SAAS,UAAU,OAAwB;CACzC,OAAO,KAAK,UAAU,SAAS,KAAK"}
|