@prisma-next/target-sqlite 0.12.0-dev.13 → 0.12.0-dev.15
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-ry_1hyIa.d.mts → codec-ids-yG2RRHnw.d.mts} +1 -1
- package/dist/{codec-ids-ry_1hyIa.d.mts.map → codec-ids-yG2RRHnw.d.mts.map} +1 -1
- package/dist/codec-ids.d.mts +1 -1
- package/dist/{codec-types-DthJOcMQ.d.mts → codec-types-CM7OkQLM.d.mts} +2 -2
- package/dist/{codec-types-DthJOcMQ.d.mts.map → codec-types-CM7OkQLM.d.mts.map} +1 -1
- package/dist/codec-types.d.mts +2 -2
- package/dist/{codecs-pGBT6kq8.d.mts → codecs-t6YnHZkK.d.mts} +2 -2
- package/dist/{codecs-pGBT6kq8.d.mts.map → codecs-t6YnHZkK.d.mts.map} +1 -1
- package/dist/codecs.d.mts +1 -1
- package/dist/contract-free.d.mts +27 -0
- package/dist/contract-free.d.mts.map +1 -0
- package/dist/contract-free.mjs +80 -0
- package/dist/contract-free.mjs.map +1 -0
- package/dist/control.d.mts +1 -1
- package/dist/control.mjs +5 -5
- package/dist/control.mjs.map +1 -1
- package/dist/ddl.d.mts +2 -0
- package/dist/ddl.mjs +2 -0
- package/dist/migration.d.mts +2 -2
- package/dist/nodes-09ul6DNV.mjs +28 -0
- package/dist/nodes-09ul6DNV.mjs.map +1 -0
- package/dist/nodes-D8LGV4Yk.d.mts +27 -0
- package/dist/nodes-D8LGV4Yk.d.mts.map +1 -0
- package/dist/op-factory-call.d.mts +2 -2
- package/dist/pack.d.mts +1 -1
- package/dist/{planner-produced-sqlite-migration-Cyxk0Z8w.d.mts → planner-produced-sqlite-migration-BwFkd0br.d.mts} +3 -3
- package/dist/{planner-produced-sqlite-migration-Cyxk0Z8w.d.mts.map → planner-produced-sqlite-migration-BwFkd0br.d.mts.map} +1 -1
- package/dist/planner-produced-sqlite-migration.d.mts +1 -1
- package/dist/{planner-target-details-DkD4PzGm.d.mts → planner-target-details-RVPqF2ug.d.mts} +1 -1
- package/dist/{planner-target-details-DkD4PzGm.d.mts.map → planner-target-details-RVPqF2ug.d.mts.map} +1 -1
- package/dist/planner-target-details.d.mts +1 -1
- package/dist/planner.d.mts +2 -2
- package/dist/render-ops.d.mts +1 -1
- package/dist/{shared-WFV75TJF.d.mts → shared-Bw5G0I-c.d.mts} +2 -2
- package/dist/{shared-WFV75TJF.d.mts.map → shared-Bw5G0I-c.d.mts.map} +1 -1
- package/dist/{sqlite-migration-BmldCeJh.d.mts → sqlite-migration-D-O3Glz1.d.mts} +2 -2
- package/dist/{sqlite-migration-BmldCeJh.d.mts.map → sqlite-migration-D-O3Glz1.d.mts.map} +1 -1
- package/package.json +20 -18
- package/src/contract-free/control-bootstrap.ts +54 -0
- package/src/contract-free/ddl.ts +21 -0
- package/src/core/ddl/nodes.ts +41 -0
- package/src/core/migrations/runner.ts +8 -10
- package/src/exports/contract-free.ts +5 -0
- package/src/exports/ddl.ts +6 -0
|
@@ -10,4 +10,4 @@ declare const SQLITE_JSON_CODEC_ID: "sqlite/json@1";
|
|
|
10
10
|
declare const SQLITE_BIGINT_CODEC_ID: "sqlite/bigint@1";
|
|
11
11
|
//#endregion
|
|
12
12
|
export { SQLITE_JSON_CODEC_ID as a, SQL_CHAR_CODEC_ID as c, SQL_VARCHAR_CODEC_ID as d, SQLITE_INTEGER_CODEC_ID as i, SQL_FLOAT_CODEC_ID as l, SQLITE_BLOB_CODEC_ID as n, SQLITE_REAL_CODEC_ID as o, SQLITE_DATETIME_CODEC_ID as r, SQLITE_TEXT_CODEC_ID as s, SQLITE_BIGINT_CODEC_ID as t, SQL_INT_CODEC_ID as u };
|
|
13
|
-
//# sourceMappingURL=codec-ids-
|
|
13
|
+
//# sourceMappingURL=codec-ids-yG2RRHnw.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codec-ids-
|
|
1
|
+
{"version":3,"file":"codec-ids-yG2RRHnw.d.mts","names":[],"sources":["../src/core/codec-ids.ts"],"mappings":";;;cAMa,oBAAA;AAAA,cACA,uBAAA;AAAA,cACA,oBAAA;AAAA,cACA,oBAAA;AAAA,cACA,wBAAA;AAAA,cACA,oBAAA;AAAA,cACA,sBAAA"}
|
package/dist/codec-ids.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as SQLITE_JSON_CODEC_ID, c as SQL_CHAR_CODEC_ID, d as SQL_VARCHAR_CODEC_ID, i as SQLITE_INTEGER_CODEC_ID, l as SQL_FLOAT_CODEC_ID, n as SQLITE_BLOB_CODEC_ID, o as SQLITE_REAL_CODEC_ID, r as SQLITE_DATETIME_CODEC_ID, s as SQLITE_TEXT_CODEC_ID, t as SQLITE_BIGINT_CODEC_ID, u as SQL_INT_CODEC_ID } from "./codec-ids-
|
|
1
|
+
import { a as SQLITE_JSON_CODEC_ID, c as SQL_CHAR_CODEC_ID, d as SQL_VARCHAR_CODEC_ID, i as SQLITE_INTEGER_CODEC_ID, l as SQL_FLOAT_CODEC_ID, n as SQLITE_BLOB_CODEC_ID, o as SQLITE_REAL_CODEC_ID, r as SQLITE_DATETIME_CODEC_ID, s as SQLITE_TEXT_CODEC_ID, t as SQLITE_BIGINT_CODEC_ID, u as SQL_INT_CODEC_ID } from "./codec-ids-yG2RRHnw.mjs";
|
|
2
2
|
export { SQLITE_BIGINT_CODEC_ID, SQLITE_BLOB_CODEC_ID, SQLITE_DATETIME_CODEC_ID, SQLITE_INTEGER_CODEC_ID, SQLITE_JSON_CODEC_ID, SQLITE_REAL_CODEC_ID, SQLITE_TEXT_CODEC_ID, SQL_CHAR_CODEC_ID, SQL_FLOAT_CODEC_ID, SQL_INT_CODEC_ID, SQL_VARCHAR_CODEC_ID };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as SqliteIntegerDescriptor, c as SqliteTextDescriptor, i as SqliteDatetimeDescriptor, n as SqliteBigintDescriptor, o as SqliteJsonDescriptor, r as SqliteBlobDescriptor, s as SqliteRealDescriptor } from "./codecs-
|
|
1
|
+
import { a as SqliteIntegerDescriptor, c as SqliteTextDescriptor, i as SqliteDatetimeDescriptor, n as SqliteBigintDescriptor, o as SqliteJsonDescriptor, r as SqliteBlobDescriptor, s as SqliteRealDescriptor } from "./codecs-t6YnHZkK.mjs";
|
|
2
2
|
import * as _$_prisma_next_sql_relational_core_ast0 from "@prisma-next/sql-relational-core/ast";
|
|
3
3
|
import { ExtractCodecTypes } from "@prisma-next/sql-relational-core/ast";
|
|
4
4
|
|
|
@@ -20,4 +20,4 @@ type Resolve<T> = { readonly [K in keyof T]: { readonly [P in keyof T[K]]: T[K][
|
|
|
20
20
|
type CodecTypes = Resolve<ExtractCodecTypes<typeof codecDescriptorMap>>;
|
|
21
21
|
//#endregion
|
|
22
22
|
export { CodecTypes as t };
|
|
23
|
-
//# sourceMappingURL=codec-types-
|
|
23
|
+
//# sourceMappingURL=codec-types-CM7OkQLM.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codec-types-
|
|
1
|
+
{"version":3,"file":"codec-types-CM7OkQLM.d.mts","names":[],"sources":["../src/exports/codec-types.ts"],"mappings":";;;;;cAwBM,kBAAA;EAAA,eAYI,uCAAA,CAAA,iBAAA;EAAA;;;;;;;;;;;KAEL,OAAA,6BAAoC,CAAA,0BAA2B,CAAA,CAAE,CAAA,IAAK,CAAA,CAAE,CAAA,EAAG,CAAA;AAAA,KAEpE,UAAA,GAAa,OAAA,CAAQ,iBAAA,QAAyB,kBAAA"}
|
package/dist/codec-types.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { g as JsonValue } from "./codecs-
|
|
2
|
-
import { t as CodecTypes } from "./codec-types-
|
|
1
|
+
import { g as JsonValue } from "./codecs-t6YnHZkK.mjs";
|
|
2
|
+
import { t as CodecTypes } from "./codec-types-CM7OkQLM.mjs";
|
|
3
3
|
export { CodecTypes, JsonValue };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as SQLITE_JSON_CODEC_ID, i as SQLITE_INTEGER_CODEC_ID, n as SQLITE_BLOB_CODEC_ID, o as SQLITE_REAL_CODEC_ID, r as SQLITE_DATETIME_CODEC_ID, s as SQLITE_TEXT_CODEC_ID, t as SQLITE_BIGINT_CODEC_ID } from "./codec-ids-
|
|
1
|
+
import { a as SQLITE_JSON_CODEC_ID, i as SQLITE_INTEGER_CODEC_ID, n as SQLITE_BLOB_CODEC_ID, o as SQLITE_REAL_CODEC_ID, r as SQLITE_DATETIME_CODEC_ID, s as SQLITE_TEXT_CODEC_ID, t as SQLITE_BIGINT_CODEC_ID } from "./codec-ids-yG2RRHnw.mjs";
|
|
2
2
|
import * as _$_prisma_next_framework_components_codec0 from "@prisma-next/framework-components/codec";
|
|
3
3
|
import { CodecCallContext, CodecDescriptorImpl, CodecImpl, CodecInstanceContext } from "@prisma-next/framework-components/codec";
|
|
4
4
|
import * as _$_standard_schema_spec0 from "@standard-schema/spec";
|
|
@@ -123,4 +123,4 @@ declare const sqliteBigintColumn: () => _$_prisma_next_framework_components_code
|
|
|
123
123
|
declare const sqliteCodecRegistry: CodecDescriptorRegistry;
|
|
124
124
|
//#endregion
|
|
125
125
|
export { SqliteIntegerDescriptor as a, SqliteTextDescriptor as c, sqliteDatetimeColumn as d, sqliteIntegerColumn as f, JsonValue$1 as g, sqliteTextColumn as h, SqliteDatetimeDescriptor as i, sqliteBigintColumn as l, sqliteRealColumn as m, SqliteBigintDescriptor as n, SqliteJsonDescriptor as o, sqliteJsonColumn as p, SqliteBlobDescriptor as r, SqliteRealDescriptor as s, sqliteCodecRegistry as t, sqliteBlobColumn as u };
|
|
126
|
-
//# sourceMappingURL=codecs-
|
|
126
|
+
//# sourceMappingURL=codecs-t6YnHZkK.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codecs-
|
|
1
|
+
{"version":3,"file":"codecs-t6YnHZkK.d.mts","names":[],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AAA,cAQN,sBAAA,SAA+B,mBAAA;EAAA,SACxB,OAAA;EAAA,SACA,MAAA;EAAA,SACA,WAAA;EAAA,SACA,YAAA,EAJgB,wBAAA,CAIJ,gBAAA;EACrB,OAAA,CAAA,IAAY,GAAA,EAAK,oBAAA,KAAyB,iBAAA;AAAA;AAAA,cAOxC,kBAAA,QAAkB,0CAAA,CAAA,UAAA,CAAA,iBAAA;;;;;;;;cCrTlB,mBAAA,EAAqB,uBACc"}
|
package/dist/codecs.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as SqliteIntegerDescriptor, c as SqliteTextDescriptor, d as sqliteDatetimeColumn, f as sqliteIntegerColumn, g as JsonValue, h as sqliteTextColumn, i as SqliteDatetimeDescriptor, l as sqliteBigintColumn, m as sqliteRealColumn, n as SqliteBigintDescriptor, o as SqliteJsonDescriptor, p as sqliteJsonColumn, r as SqliteBlobDescriptor, s as SqliteRealDescriptor, t as sqliteCodecRegistry, u as sqliteBlobColumn } from "./codecs-
|
|
1
|
+
import { a as SqliteIntegerDescriptor, c as SqliteTextDescriptor, d as sqliteDatetimeColumn, f as sqliteIntegerColumn, g as JsonValue, h as sqliteTextColumn, i as SqliteDatetimeDescriptor, l as sqliteBigintColumn, m as sqliteRealColumn, n as SqliteBigintDescriptor, o as SqliteJsonDescriptor, p as sqliteJsonColumn, r as SqliteBlobDescriptor, s as SqliteRealDescriptor, t as sqliteCodecRegistry, u as sqliteBlobColumn } from "./codecs-t6YnHZkK.mjs";
|
|
2
2
|
export { JsonValue, SqliteBigintDescriptor, SqliteBlobDescriptor, SqliteDatetimeDescriptor, SqliteIntegerDescriptor, SqliteJsonDescriptor, SqliteRealDescriptor, SqliteTextDescriptor, sqliteBigintColumn, sqliteBlobColumn, sqliteCodecRegistry, sqliteDatetimeColumn, sqliteIntegerColumn, sqliteJsonColumn, sqliteRealColumn, sqliteTextColumn };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { n as SqliteCreateTable } from "./nodes-D8LGV4Yk.mjs";
|
|
2
|
+
import { DdlColumn, DdlNode } from "@prisma-next/sql-relational-core/ast";
|
|
3
|
+
|
|
4
|
+
//#region src/contract-free/control-bootstrap.d.ts
|
|
5
|
+
declare function buildSignMarkerBootstrapQueries(): readonly DdlNode[];
|
|
6
|
+
declare function buildControlTableBootstrapQueries(): readonly DdlNode[];
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/contract-free/ddl.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* Build a SQLite `CREATE TABLE` query node.
|
|
11
|
+
*
|
|
12
|
+
* Precondition: identifiers (`table`, column names/types) are emitted to SQL
|
|
13
|
+
* verbatim — they are not quoted or escaped, so callers must pass pre-trusted
|
|
14
|
+
* values (e.g. fixed control-plane identifiers). String-literal default values,
|
|
15
|
+
* by contrast, are single-quote-escaped (embedded `'` doubled) by the renderer.
|
|
16
|
+
* Identifier quoting for untrusted identifiers is added when the migration
|
|
17
|
+
* planner adopts this lowering path.
|
|
18
|
+
*/
|
|
19
|
+
declare function createTable(options: {
|
|
20
|
+
readonly table: string;
|
|
21
|
+
readonly schema?: string;
|
|
22
|
+
readonly ifNotExists?: boolean;
|
|
23
|
+
readonly columns: readonly DdlColumn[];
|
|
24
|
+
}): SqliteCreateTable;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { buildControlTableBootstrapQueries, buildSignMarkerBootstrapQueries, createTable };
|
|
27
|
+
//# sourceMappingURL=contract-free.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-free.d.mts","names":[],"sources":["../src/contract-free/control-bootstrap.ts","../src/contract-free/ddl.ts"],"mappings":";;;;iBA+CgB,+BAAA,CAAA,YAA4C,OAAO;AAAA,iBAInD,iCAAA,CAAA,YAA8C,OAAO;;;;;AAJrE;;;;AAAmE;AAInE;;;iBCtCgB,WAAA,CAAY,OAAA;EAAA,SACjB,KAAA;EAAA,SACA,MAAA;EAAA,SACA,WAAA;EAAA,SACA,OAAA,WAAkB,SAAA;AAAA,IACzB,iBAAiB"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { t as SqliteCreateTable } from "./nodes-09ul6DNV.mjs";
|
|
2
|
+
import { APP_SPACE_ID } from "@prisma-next/framework-components/control";
|
|
3
|
+
import { col, fn, lit } from "@prisma-next/sql-relational-core/contract-free";
|
|
4
|
+
//#region src/contract-free/ddl.ts
|
|
5
|
+
/**
|
|
6
|
+
* Build a SQLite `CREATE TABLE` query node.
|
|
7
|
+
*
|
|
8
|
+
* Precondition: identifiers (`table`, column names/types) are emitted to SQL
|
|
9
|
+
* verbatim — they are not quoted or escaped, so callers must pass pre-trusted
|
|
10
|
+
* values (e.g. fixed control-plane identifiers). String-literal default values,
|
|
11
|
+
* by contrast, are single-quote-escaped (embedded `'` doubled) by the renderer.
|
|
12
|
+
* Identifier quoting for untrusted identifiers is added when the migration
|
|
13
|
+
* planner adopts this lowering path.
|
|
14
|
+
*/
|
|
15
|
+
function createTable(options) {
|
|
16
|
+
return new SqliteCreateTable(options);
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/contract-free/control-bootstrap.ts
|
|
20
|
+
const markerColumns = [
|
|
21
|
+
col("space", "TEXT", {
|
|
22
|
+
notNull: true,
|
|
23
|
+
primaryKey: true,
|
|
24
|
+
default: lit(APP_SPACE_ID)
|
|
25
|
+
}),
|
|
26
|
+
col("core_hash", "TEXT", { notNull: true }),
|
|
27
|
+
col("profile_hash", "TEXT", { notNull: true }),
|
|
28
|
+
col("contract_json", "TEXT"),
|
|
29
|
+
col("canonical_version", "INTEGER"),
|
|
30
|
+
col("updated_at", "TEXT", {
|
|
31
|
+
notNull: true,
|
|
32
|
+
default: fn("datetime('now')")
|
|
33
|
+
}),
|
|
34
|
+
col("app_tag", "TEXT"),
|
|
35
|
+
col("meta", "TEXT", {
|
|
36
|
+
notNull: true,
|
|
37
|
+
default: lit("{}")
|
|
38
|
+
}),
|
|
39
|
+
col("invariants", "TEXT", {
|
|
40
|
+
notNull: true,
|
|
41
|
+
default: lit("[]")
|
|
42
|
+
})
|
|
43
|
+
];
|
|
44
|
+
const ledgerColumns = [
|
|
45
|
+
col("id", "INTEGER PRIMARY KEY AUTOINCREMENT"),
|
|
46
|
+
col("created_at", "TEXT", {
|
|
47
|
+
notNull: true,
|
|
48
|
+
default: fn("strftime('%Y-%m-%dT%H:%M:%fZ','now')")
|
|
49
|
+
}),
|
|
50
|
+
col("space", "TEXT", { notNull: true }),
|
|
51
|
+
col("migration_name", "TEXT", { notNull: true }),
|
|
52
|
+
col("migration_hash", "TEXT", { notNull: true }),
|
|
53
|
+
col("origin_core_hash", "TEXT"),
|
|
54
|
+
col("origin_profile_hash", "TEXT"),
|
|
55
|
+
col("destination_core_hash", "TEXT", { notNull: true }),
|
|
56
|
+
col("destination_profile_hash", "TEXT"),
|
|
57
|
+
col("contract_json_before", "TEXT"),
|
|
58
|
+
col("contract_json_after", "TEXT"),
|
|
59
|
+
col("operations", "TEXT", { notNull: true })
|
|
60
|
+
];
|
|
61
|
+
const markerTable = createTable({
|
|
62
|
+
table: "_prisma_marker",
|
|
63
|
+
ifNotExists: true,
|
|
64
|
+
columns: markerColumns
|
|
65
|
+
});
|
|
66
|
+
const ledgerTable = createTable({
|
|
67
|
+
table: "_prisma_ledger",
|
|
68
|
+
ifNotExists: true,
|
|
69
|
+
columns: ledgerColumns
|
|
70
|
+
});
|
|
71
|
+
function buildSignMarkerBootstrapQueries() {
|
|
72
|
+
return [markerTable];
|
|
73
|
+
}
|
|
74
|
+
function buildControlTableBootstrapQueries() {
|
|
75
|
+
return [markerTable, ledgerTable];
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
export { buildControlTableBootstrapQueries, buildSignMarkerBootstrapQueries, createTable };
|
|
79
|
+
|
|
80
|
+
//# sourceMappingURL=contract-free.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-free.mjs","names":[],"sources":["../src/contract-free/ddl.ts","../src/contract-free/control-bootstrap.ts"],"sourcesContent":["import type { DdlColumn } from '@prisma-next/sql-relational-core/ast';\nimport { SqliteCreateTable } from '../core/ddl/nodes';\n\n/**\n * Build a SQLite `CREATE TABLE` query node.\n *\n * Precondition: identifiers (`table`, column names/types) are emitted to SQL\n * verbatim — they are not quoted or escaped, so callers must pass pre-trusted\n * values (e.g. fixed control-plane identifiers). String-literal default values,\n * by contrast, are single-quote-escaped (embedded `'` doubled) by the renderer.\n * Identifier quoting for untrusted identifiers is added when the migration\n * planner adopts this lowering path.\n */\nexport function createTable(options: {\n readonly table: string;\n readonly schema?: string;\n readonly ifNotExists?: boolean;\n readonly columns: readonly DdlColumn[];\n}): SqliteCreateTable {\n return new SqliteCreateTable(options);\n}\n","import { APP_SPACE_ID } from '@prisma-next/framework-components/control';\nimport type { DdlNode } from '@prisma-next/sql-relational-core/ast';\nimport { col, fn, lit } from '@prisma-next/sql-relational-core/contract-free';\nimport { createTable } from './ddl';\n\nconst markerColumns = [\n col('space', 'TEXT', { notNull: true, primaryKey: true, default: lit(APP_SPACE_ID) }),\n col('core_hash', 'TEXT', { notNull: true }),\n col('profile_hash', 'TEXT', { notNull: true }),\n col('contract_json', 'TEXT'),\n col('canonical_version', 'INTEGER'),\n col('updated_at', 'TEXT', { notNull: true, default: fn(\"datetime('now')\") }),\n col('app_tag', 'TEXT'),\n col('meta', 'TEXT', { notNull: true, default: lit('{}') }),\n col('invariants', 'TEXT', { notNull: true, default: lit('[]') }),\n] as const;\n\nconst ledgerColumns = [\n col('id', 'INTEGER PRIMARY KEY AUTOINCREMENT'),\n col('created_at', 'TEXT', {\n notNull: true,\n default: fn(\"strftime('%Y-%m-%dT%H:%M:%fZ','now')\"),\n }),\n col('space', 'TEXT', { notNull: true }),\n col('migration_name', 'TEXT', { notNull: true }),\n col('migration_hash', 'TEXT', { notNull: true }),\n col('origin_core_hash', 'TEXT'),\n col('origin_profile_hash', 'TEXT'),\n col('destination_core_hash', 'TEXT', { notNull: true }),\n col('destination_profile_hash', 'TEXT'),\n col('contract_json_before', 'TEXT'),\n col('contract_json_after', 'TEXT'),\n col('operations', 'TEXT', { notNull: true }),\n] as const;\n\nconst markerTable = createTable({\n table: '_prisma_marker',\n ifNotExists: true,\n columns: markerColumns,\n});\n\nconst ledgerTable = createTable({\n table: '_prisma_ledger',\n ifNotExists: true,\n columns: ledgerColumns,\n});\n\nexport function buildSignMarkerBootstrapQueries(): readonly DdlNode[] {\n return [markerTable];\n}\n\nexport function buildControlTableBootstrapQueries(): readonly DdlNode[] {\n return [markerTable, ledgerTable];\n}\n"],"mappings":";;;;;;;;;;;;;;AAaA,SAAgB,YAAY,SAKN;CACpB,OAAO,IAAI,kBAAkB,OAAO;AACtC;;;ACfA,MAAM,gBAAgB;CACpB,IAAI,SAAS,QAAQ;EAAE,SAAS;EAAM,YAAY;EAAM,SAAS,IAAI,YAAY;CAAE,CAAC;CACpF,IAAI,aAAa,QAAQ,EAAE,SAAS,KAAK,CAAC;CAC1C,IAAI,gBAAgB,QAAQ,EAAE,SAAS,KAAK,CAAC;CAC7C,IAAI,iBAAiB,MAAM;CAC3B,IAAI,qBAAqB,SAAS;CAClC,IAAI,cAAc,QAAQ;EAAE,SAAS;EAAM,SAAS,GAAG,iBAAiB;CAAE,CAAC;CAC3E,IAAI,WAAW,MAAM;CACrB,IAAI,QAAQ,QAAQ;EAAE,SAAS;EAAM,SAAS,IAAI,IAAI;CAAE,CAAC;CACzD,IAAI,cAAc,QAAQ;EAAE,SAAS;EAAM,SAAS,IAAI,IAAI;CAAE,CAAC;AACjE;AAEA,MAAM,gBAAgB;CACpB,IAAI,MAAM,mCAAmC;CAC7C,IAAI,cAAc,QAAQ;EACxB,SAAS;EACT,SAAS,GAAG,sCAAsC;CACpD,CAAC;CACD,IAAI,SAAS,QAAQ,EAAE,SAAS,KAAK,CAAC;CACtC,IAAI,kBAAkB,QAAQ,EAAE,SAAS,KAAK,CAAC;CAC/C,IAAI,kBAAkB,QAAQ,EAAE,SAAS,KAAK,CAAC;CAC/C,IAAI,oBAAoB,MAAM;CAC9B,IAAI,uBAAuB,MAAM;CACjC,IAAI,yBAAyB,QAAQ,EAAE,SAAS,KAAK,CAAC;CACtD,IAAI,4BAA4B,MAAM;CACtC,IAAI,wBAAwB,MAAM;CAClC,IAAI,uBAAuB,MAAM;CACjC,IAAI,cAAc,QAAQ,EAAE,SAAS,KAAK,CAAC;AAC7C;AAEA,MAAM,cAAc,YAAY;CAC9B,OAAO;CACP,aAAa;CACb,SAAS;AACX,CAAC;AAED,MAAM,cAAc,YAAY;CAC9B,OAAO;CACP,aAAa;CACb,SAAS;AACX,CAAC;AAED,SAAgB,kCAAsD;CACpE,OAAO,CAAC,WAAW;AACrB;AAEA,SAAgB,oCAAwD;CACtE,OAAO,CAAC,aAAa,WAAW;AAClC"}
|
package/dist/control.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as SqlitePlanTargetDetails } from "./planner-target-details-
|
|
1
|
+
import { t as SqlitePlanTargetDetails } from "./planner-target-details-RVPqF2ug.mjs";
|
|
2
2
|
import { SqlControlTargetDescriptor } from "@prisma-next/family-sql/control";
|
|
3
3
|
import { StorageTable } from "@prisma-next/sql-contract/types";
|
|
4
4
|
import { NamespaceBase } from "@prisma-next/framework-components/ir";
|
package/dist/control.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { t as parseSqliteDefault } from "./default-normalizer-CWKVYSxS.mjs";
|
|
|
3
3
|
import { t as normalizeSqliteNativeType } from "./native-type-normalizer-HvkimyB8.mjs";
|
|
4
4
|
import { d as renderDefaultLiteral } from "./tables-gB0XiFu8.mjs";
|
|
5
5
|
import { n as createSqliteMigrationPlanner } from "./planner-Cygvz9Wp.mjs";
|
|
6
|
-
import { a as buildLedgerInsertStatement,
|
|
6
|
+
import { a as buildLedgerInsertStatement, i as MARKER_TABLE_NAME, l as readMarkerStatement, o as buildWriteMarkerStatements } from "./statement-builders-D1Q_i4sb.mjs";
|
|
7
7
|
import { n as SqliteUnboundDatabase, r as sqliteCreateNamespace, t as SqliteContractSerializer } from "./sqlite-contract-serializer-Hy7WQPea.mjs";
|
|
8
8
|
import { contractToSchemaIR, runnerFailure, runnerSuccess } from "@prisma-next/family-sql/control";
|
|
9
9
|
import { SqlStorage } from "@prisma-next/sql-contract/types";
|
|
@@ -36,7 +36,7 @@ var SqliteMigrationRunner = class {
|
|
|
36
36
|
if (!destinationCheck.ok) return destinationCheck;
|
|
37
37
|
const policyCheck = this.enforcePolicyCompatibility(options.policy, options.plan.operations);
|
|
38
38
|
if (!policyCheck.ok) return policyCheck;
|
|
39
|
-
const ensureResult = await this.ensureControlTables(driver);
|
|
39
|
+
const ensureResult = await this.ensureControlTables(driver, options.destinationContract);
|
|
40
40
|
if (!ensureResult.ok) return ensureResult;
|
|
41
41
|
const existingMarker = await this.readMarker(driver, space);
|
|
42
42
|
const markerCheck = this.ensureMarkerCompatibility(existingMarker, options.plan);
|
|
@@ -181,11 +181,11 @@ var SqliteMigrationRunner = class {
|
|
|
181
181
|
executedOperations
|
|
182
182
|
});
|
|
183
183
|
}
|
|
184
|
-
async ensureControlTables(driver) {
|
|
184
|
+
async ensureControlTables(driver, contract) {
|
|
185
185
|
const legacyDetection = await this.detectLegacyMarkerShape(driver);
|
|
186
186
|
if (!legacyDetection.ok) return legacyDetection;
|
|
187
|
-
|
|
188
|
-
await this.executeStatement(driver,
|
|
187
|
+
const lowererContext = { contract };
|
|
188
|
+
for (const query of this.family.bootstrapControlTableQueries()) await this.executeStatement(driver, this.family.lowerAst(query, lowererContext));
|
|
189
189
|
return okVoid();
|
|
190
190
|
}
|
|
191
191
|
async detectLegacyMarkerShape(driver) {
|
package/dist/control.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control.mjs","names":[],"sources":["../src/core/migrations/runner.ts","../src/core/sqlite-schema-verifier.ts","../src/core/control-target.ts"],"sourcesContent":["import type { ContractMarkerRecord } from '@prisma-next/contract/types';\nimport type {\n MigrationOperationPolicy,\n SqlControlFamilyInstance,\n SqlMigrationPlanContractInfo,\n SqlMigrationPlanOperation,\n SqlMigrationPlanOperationStep,\n SqlMigrationRunner,\n SqlMigrationRunnerExecuteOptions,\n SqlMigrationRunnerFailure,\n SqlMigrationRunnerResult,\n SqlMigrationRunnerSuccessValue,\n} from '@prisma-next/family-sql/control';\nimport { runnerFailure, runnerSuccess } from '@prisma-next/family-sql/control';\nimport { verifySqlSchema } from '@prisma-next/family-sql/schema-verify';\nimport { type ContractMarkerRow, parseContractMarkerRow } from '@prisma-next/family-sql/verify';\nimport type {\n ControlDriverInstance,\n MigrationRunnerResult,\n} from '@prisma-next/framework-components/control';\nimport { APP_SPACE_ID } from '@prisma-next/framework-components/control';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport type { Result } from '@prisma-next/utils/result';\nimport { notOk, ok, okVoid } from '@prisma-next/utils/result';\nimport { parseSqliteDefault } from '../default-normalizer';\nimport { normalizeSqliteNativeType } from '../native-type-normalizer';\nimport type { SqlitePlanTargetDetails } from './planner-target-details';\nimport {\n buildLedgerInsertStatement,\n buildWriteMarkerStatements,\n ensureLedgerTableStatement,\n ensureMarkerTableStatement,\n MARKER_TABLE_NAME,\n readMarkerStatement,\n type SqlStatement,\n} from './statement-builders';\n\nexport function createSqliteMigrationRunner(\n family: SqlControlFamilyInstance,\n): SqlMigrationRunner<SqlitePlanTargetDetails> {\n return new SqliteMigrationRunner(family);\n}\n\nclass SqliteMigrationRunner implements SqlMigrationRunner<SqlitePlanTargetDetails> {\n constructor(private readonly family: SqlControlFamilyInstance) {}\n\n /**\n * Apply the plan against an already-open connection without managing\n * the transaction lifecycle. The caller ({@link SqliteMigrationRunner.execute})\n * owns BEGIN/COMMIT/ROLLBACK and any connection-level setup (FK pragma\n * toggle, FK integrity check).\n */\n async executeOnConnection(\n options: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>,\n ): Promise<SqlMigrationRunnerResult> {\n const driver = options.driver;\n if (options.space !== undefined && options.space !== options.plan.spaceId) {\n throw new Error(\n `SqlMigrationRunner: options.space (${options.space}) does not match plan.spaceId (${options.plan.spaceId})`,\n );\n }\n const space = options.plan.spaceId;\n\n const destinationCheck = this.ensurePlanMatchesDestinationContract(\n options.plan.destination,\n options.destinationContract,\n );\n if (!destinationCheck.ok) return destinationCheck;\n\n const policyCheck = this.enforcePolicyCompatibility(options.policy, options.plan.operations);\n if (!policyCheck.ok) return policyCheck;\n\n const ensureResult = await this.ensureControlTables(driver);\n if (!ensureResult.ok) return ensureResult;\n const existingMarker = await this.readMarker(driver, space);\n\n const markerCheck = this.ensureMarkerCompatibility(existingMarker, options.plan);\n if (!markerCheck.ok) return markerCheck;\n\n const markerAtDestination = this.markerMatchesDestination(existingMarker, options.plan);\n const isSelfEdge = options.plan.origin?.storageHash === options.plan.destination.storageHash;\n const skipOperations = markerAtDestination && options.plan.origin != null && !isSelfEdge;\n\n let operationsExecuted: number;\n let executedOperations: readonly SqlMigrationPlanOperation<SqlitePlanTargetDetails>[];\n\n if (skipOperations) {\n operationsExecuted = 0;\n executedOperations = [];\n } else {\n const applyResult = await this.applyPlan(driver, options);\n if (!applyResult.ok) return applyResult;\n operationsExecuted = applyResult.value.operationsExecuted;\n executedOperations = applyResult.value.executedOperations;\n }\n\n if (space === APP_SPACE_ID) {\n const schemaIR = await this.family.introspect({\n driver,\n contract: options.destinationContract,\n });\n\n const schemaVerifyResult = verifySqlSchema({\n contract: options.destinationContract,\n schema: schemaIR,\n strict: options.strictVerification ?? true,\n context: options.context ?? {},\n typeMetadataRegistry: this.family.typeMetadataRegistry,\n frameworkComponents: options.frameworkComponents,\n normalizeDefault: parseSqliteDefault,\n normalizeNativeType: normalizeSqliteNativeType,\n });\n if (!schemaVerifyResult.ok) {\n return runnerFailure('SCHEMA_VERIFY_FAILED', schemaVerifyResult.summary, {\n why: 'The resulting database schema does not satisfy the destination contract.',\n meta: { issues: schemaVerifyResult.schema.issues },\n });\n }\n }\n\n // Self-edge no-op detection: see Postgres runner for the rationale\n // (kept symmetric across both targets).\n const incomingInvariants = options.plan.providedInvariants;\n const existingInvariants = new Set(existingMarker?.invariants ?? []);\n const incomingIsSubsetOfExisting = incomingInvariants.every((id) => existingInvariants.has(id));\n const isSelfEdgeNoOp = isSelfEdge && operationsExecuted === 0 && incomingIsSubsetOfExisting;\n\n if (!isSelfEdgeNoOp) {\n await this.upsertMarker(driver, options, existingMarker, space);\n await this.recordLedgerEntries(driver, options, existingMarker, executedOperations);\n }\n\n return runnerSuccess({\n operationsPlanned: options.plan.operations.length,\n operationsExecuted,\n });\n }\n\n async execute(options: {\n readonly driver: ControlDriverInstance<'sql', string>;\n readonly perSpaceOptions: ReadonlyArray<\n SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>\n >;\n }): Promise<MigrationRunnerResult> {\n const driver = options.driver;\n const perSpaceOptions = options.perSpaceOptions;\n\n if (perSpaceOptions.length === 0) {\n return ok({ perSpaceResults: [] });\n }\n\n // FK pragma toggle and the FK integrity check both span the outer\n // transaction: PRAGMA foreign_keys is a no-op inside a transaction, so the\n // toggle has to wrap BEGIN/COMMIT.\n const fkWasEnabled = await this.readForeignKeysEnabled(driver);\n if (fkWasEnabled) {\n await driver.query('PRAGMA foreign_keys = OFF');\n }\n\n try {\n await this.beginExclusiveTransaction(driver);\n let committed = false;\n try {\n const perSpaceResults: Array<{\n space: string;\n value: SqlMigrationRunnerSuccessValue;\n }> = [];\n let lastProcessedSpace: string | undefined;\n for (const spaceOptions of perSpaceOptions) {\n const space = spaceOptions.space ?? spaceOptions.plan.spaceId;\n const result = await this.executeOnConnection({ ...spaceOptions, driver, space });\n if (!result.ok) {\n return notOk({ ...result.failure, failingSpace: space });\n }\n perSpaceResults.push({ space, value: result.value });\n lastProcessedSpace = space;\n }\n\n if (fkWasEnabled) {\n const fkIntegrityCheck = await this.verifyForeignKeyIntegrity(driver);\n if (!fkIntegrityCheck.ok) {\n // Post-loop integrity violations cannot be attributed to a\n // single per-space step (the cumulative effect of all\n // applied plans was needed to reveal the broken\n // reference). Surface the last successfully-applied space\n // so operators can investigate from the most recent\n // migration first.\n return notOk({\n ...fkIntegrityCheck.failure,\n failingSpace: lastProcessedSpace ?? APP_SPACE_ID,\n });\n }\n }\n\n await this.commitTransaction(driver);\n committed = true;\n return ok({ perSpaceResults });\n } finally {\n if (!committed) {\n await this.rollbackTransaction(driver);\n }\n }\n } finally {\n if (fkWasEnabled) {\n await driver.query('PRAGMA foreign_keys = ON');\n }\n }\n }\n\n private async readForeignKeysEnabled(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<boolean> {\n const result = await driver.query<{ foreign_keys: number }>('PRAGMA foreign_keys');\n const row = result.rows[0];\n return row?.foreign_keys === 1;\n }\n\n private async verifyForeignKeyIntegrity(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<Result<void, SqlMigrationRunnerFailure>> {\n const result = await driver.query<Record<string, unknown>>('PRAGMA foreign_key_check');\n if (result.rows.length === 0) {\n return okVoid();\n }\n return runnerFailure(\n 'FOREIGN_KEY_VIOLATION',\n `Foreign key integrity check failed after migration: ${result.rows.length} violation(s).`,\n {\n why: 'PRAGMA foreign_key_check reported violations after applying recreate-table operations.',\n meta: { violations: result.rows },\n },\n );\n }\n\n private async applyPlan(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n options: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>,\n ): Promise<\n Result<\n {\n readonly operationsExecuted: number;\n readonly executedOperations: readonly SqlMigrationPlanOperation<SqlitePlanTargetDetails>[];\n },\n SqlMigrationRunnerFailure\n >\n > {\n const checks = options.executionChecks;\n const runPrechecks = checks?.prechecks !== false;\n const runPostchecks = checks?.postchecks !== false;\n const runIdempotency = checks?.idempotencyChecks !== false;\n\n let operationsExecuted = 0;\n const executedOperations: Array<SqlMigrationPlanOperation<SqlitePlanTargetDetails>> = [];\n\n for (const operation of options.plan.operations) {\n options.callbacks?.onOperationStart?.(operation);\n try {\n if (runPostchecks && runIdempotency) {\n const postcheckAlreadySatisfied = await this.expectationsAreSatisfied(\n driver,\n operation.postcheck,\n );\n if (postcheckAlreadySatisfied) {\n executedOperations.push(this.createSkipRecord(operation));\n continue;\n }\n }\n\n if (runPrechecks) {\n const precheckResult = await this.runExpectationSteps(\n driver,\n operation.precheck,\n operation,\n 'precheck',\n );\n if (!precheckResult.ok) {\n return precheckResult;\n }\n }\n\n const executeResult = await this.runExecuteSteps(driver, operation.execute, operation);\n if (!executeResult.ok) {\n return executeResult;\n }\n\n if (runPostchecks) {\n const postcheckResult = await this.runExpectationSteps(\n driver,\n operation.postcheck,\n operation,\n 'postcheck',\n );\n if (!postcheckResult.ok) {\n return postcheckResult;\n }\n }\n\n executedOperations.push(operation);\n operationsExecuted += 1;\n } finally {\n options.callbacks?.onOperationComplete?.(operation);\n }\n }\n return ok({ operationsExecuted, executedOperations });\n }\n\n private async ensureControlTables(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<Result<void, SqlMigrationRunnerFailure>> {\n // Pre-1.0 zero-range guardrail: detect a pre-cleanup single-row\n // marker table (no `space` column) and surface a structured failure\n // rather than silently rebuilding the table into the per-space\n // shape. See `specs/framework-mechanism.spec.md § 2`.\n const legacyDetection = await this.detectLegacyMarkerShape(driver);\n if (!legacyDetection.ok) {\n return legacyDetection;\n }\n await this.executeStatement(driver, ensureMarkerTableStatement);\n await this.executeStatement(driver, ensureLedgerTableStatement);\n return okVoid();\n }\n\n private async detectLegacyMarkerShape(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<Result<void, SqlMigrationRunnerFailure>> {\n const tableInfo = await driver.query<{ name: string }>(\n `PRAGMA table_info(\"${MARKER_TABLE_NAME}\")`,\n );\n if (tableInfo.rows.length === 0) {\n return okVoid();\n }\n const columns = new Set(tableInfo.rows.map((row) => row.name));\n if (columns.has('space')) {\n return okVoid();\n }\n return runnerFailure(\n 'LEGACY_MARKER_SHAPE',\n `Legacy marker-table shape detected on ${MARKER_TABLE_NAME} (no \\`space\\` column). ` +\n 'Prisma Next is in pre-1.0; the previous transitional auto-migration to the per-space-row schema has been removed. ' +\n `Drop \\`${MARKER_TABLE_NAME}\\` and re-run \\`dbInit\\` to reinitialise from a clean baseline.`,\n {\n meta: {\n table: MARKER_TABLE_NAME,\n columns: [...columns].sort(),\n },\n },\n );\n }\n\n private async readMarker(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n space: string,\n ): Promise<ContractMarkerRecord | null> {\n const stmt = readMarkerStatement(space);\n try {\n const result = await driver.query<ContractMarkerRow>(stmt.sql, stmt.params);\n const row = result.rows[0];\n if (!row) return null;\n // SQLite stores arrays as JSON-encoded TEXT (no native array type), so\n // the driver returns `invariants` as a string. Decode before delegating\n // to the shared row schema, which expects `string[]`.\n const invariants =\n typeof row.invariants === 'string'\n ? (JSON.parse(row.invariants) as unknown)\n : row.invariants;\n return parseContractMarkerRow({ ...row, invariants });\n } catch (error) {\n // Table might not exist yet\n if (error instanceof Error && error.message.includes('no such table')) {\n return null;\n }\n throw error;\n }\n }\n\n private async runExpectationSteps(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n steps: readonly SqlMigrationPlanOperationStep[],\n operation: SqlMigrationPlanOperation<SqlitePlanTargetDetails>,\n phase: 'precheck' | 'postcheck',\n ): Promise<Result<void, SqlMigrationRunnerFailure>> {\n for (const step of steps) {\n const result = await driver.query(step.sql, step.params ?? []);\n if (!this.stepResultIsTrue(result.rows)) {\n const code = phase === 'precheck' ? 'PRECHECK_FAILED' : 'POSTCHECK_FAILED';\n return runnerFailure(\n code,\n `Operation ${operation.id} failed during ${phase}: ${step.description}`,\n {\n meta: {\n operationId: operation.id,\n phase,\n stepDescription: step.description,\n },\n },\n );\n }\n }\n return okVoid();\n }\n\n private async runExecuteSteps(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n steps: readonly SqlMigrationPlanOperationStep[],\n operation: SqlMigrationPlanOperation<SqlitePlanTargetDetails>,\n ): Promise<Result<void, SqlMigrationRunnerFailure>> {\n for (const step of steps) {\n try {\n await driver.query(step.sql, step.params ?? []);\n } catch (error: unknown) {\n const message = error instanceof Error ? error.message : String(error);\n return runnerFailure(\n 'EXECUTION_FAILED',\n `Operation ${operation.id} failed during execution: ${step.description}`,\n {\n why: message,\n meta: {\n operationId: operation.id,\n stepDescription: step.description,\n sql: step.sql,\n },\n },\n );\n }\n }\n return okVoid();\n }\n\n private stepResultIsTrue(rows: readonly Record<string, unknown>[]): boolean {\n if (!rows || rows.length === 0) {\n return false;\n }\n const firstRow = rows[0];\n const firstValue = firstRow ? Object.values(firstRow)[0] : undefined;\n if (typeof firstValue === 'number') {\n return firstValue !== 0;\n }\n if (typeof firstValue === 'boolean') {\n return firstValue;\n }\n if (typeof firstValue === 'string') {\n const lower = firstValue.toLowerCase();\n if (lower === 'true' || lower === '1') return true;\n if (lower === 'false' || lower === '0') return false;\n return firstValue.length > 0;\n }\n return Boolean(firstValue);\n }\n\n private async expectationsAreSatisfied(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n steps: readonly SqlMigrationPlanOperationStep[],\n ): Promise<boolean> {\n if (steps.length === 0) {\n return false;\n }\n for (const step of steps) {\n const result = await driver.query(step.sql, step.params ?? []);\n if (!this.stepResultIsTrue(result.rows)) {\n return false;\n }\n }\n return true;\n }\n\n private createSkipRecord(\n operation: SqlMigrationPlanOperation<SqlitePlanTargetDetails>,\n ): SqlMigrationPlanOperation<SqlitePlanTargetDetails> {\n return Object.freeze({\n id: operation.id,\n label: operation.label,\n ...ifDefined('summary', operation.summary),\n operationClass: operation.operationClass,\n target: operation.target,\n precheck: Object.freeze([]),\n execute: Object.freeze([]),\n postcheck: Object.freeze([...operation.postcheck]),\n meta: Object.freeze({\n ...(operation.meta ?? {}),\n runner: Object.freeze({ skipped: true, reason: 'postcheck_pre_satisfied' }),\n }),\n });\n }\n\n private markerMatchesDestination(\n marker: ContractMarkerRecord | null,\n plan: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['plan'],\n ): boolean {\n if (!marker) return false;\n if (marker.storageHash !== plan.destination.storageHash) return false;\n if (plan.destination.profileHash && marker.profileHash !== plan.destination.profileHash) {\n return false;\n }\n return true;\n }\n\n private enforcePolicyCompatibility(\n policy: MigrationOperationPolicy,\n operations: readonly SqlMigrationPlanOperation<SqlitePlanTargetDetails>[],\n ): Result<void, SqlMigrationRunnerFailure> {\n const allowedClasses = new Set(policy.allowedOperationClasses);\n for (const operation of operations) {\n if (!allowedClasses.has(operation.operationClass)) {\n return runnerFailure(\n 'POLICY_VIOLATION',\n `Operation ${operation.id} has class \"${operation.operationClass}\" which is not allowed by policy.`,\n {\n why: `Policy only allows: ${policy.allowedOperationClasses.join(', ')}.`,\n meta: {\n operationId: operation.id,\n operationClass: operation.operationClass,\n allowedClasses: policy.allowedOperationClasses,\n },\n },\n );\n }\n }\n return okVoid();\n }\n\n private ensureMarkerCompatibility(\n marker: ContractMarkerRecord | null,\n plan: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['plan'],\n ): Result<void, SqlMigrationRunnerFailure> {\n const origin = plan.origin ?? null;\n if (!origin) {\n return okVoid();\n }\n if (!marker) {\n return runnerFailure(\n 'MARKER_ORIGIN_MISMATCH',\n `Missing contract marker: expected origin storage hash ${origin.storageHash}.`,\n { meta: { expectedOriginStorageHash: origin.storageHash } },\n );\n }\n if (marker.storageHash !== origin.storageHash) {\n return runnerFailure(\n 'MARKER_ORIGIN_MISMATCH',\n `Existing contract marker (${marker.storageHash}) does not match plan origin (${origin.storageHash}).`,\n {\n meta: {\n markerStorageHash: marker.storageHash,\n expectedOriginStorageHash: origin.storageHash,\n },\n },\n );\n }\n if (origin.profileHash && marker.profileHash !== origin.profileHash) {\n return runnerFailure(\n 'MARKER_ORIGIN_MISMATCH',\n `Existing contract marker profile hash (${marker.profileHash}) does not match plan origin profile hash (${origin.profileHash}).`,\n {\n meta: {\n markerProfileHash: marker.profileHash,\n expectedOriginProfileHash: origin.profileHash,\n },\n },\n );\n }\n return okVoid();\n }\n\n private ensurePlanMatchesDestinationContract(\n destination: SqlMigrationPlanContractInfo,\n contract: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['destinationContract'],\n ): Result<void, SqlMigrationRunnerFailure> {\n if (destination.storageHash !== contract.storage.storageHash) {\n return runnerFailure(\n 'DESTINATION_CONTRACT_MISMATCH',\n `Plan destination storage hash (${destination.storageHash}) does not match provided contract storage hash (${contract.storage.storageHash}).`,\n {\n meta: {\n planStorageHash: destination.storageHash,\n contractStorageHash: contract.storage.storageHash,\n },\n },\n );\n }\n if (\n destination.profileHash &&\n contract.profileHash &&\n destination.profileHash !== contract.profileHash\n ) {\n return runnerFailure(\n 'DESTINATION_CONTRACT_MISMATCH',\n `Plan destination profile hash (${destination.profileHash}) does not match provided contract profile hash (${contract.profileHash}).`,\n {\n meta: {\n planProfileHash: destination.profileHash,\n contractProfileHash: contract.profileHash,\n },\n },\n );\n }\n return okVoid();\n }\n\n private async upsertMarker(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n options: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>,\n existingMarker: ContractMarkerRecord | null,\n space: string,\n ): Promise<void> {\n // SQLite has no native array type, so we can't merge invariants in SQL\n // the way Postgres does. Merge client-side under the runner's\n // BEGIN EXCLUSIVE — sort + dedupe so the JSON-encoded value is stable.\n const merged = new Set<string>(existingMarker?.invariants ?? []);\n for (const inv of options.plan.providedInvariants) merged.add(inv);\n const invariants = Array.from(merged).sort();\n const writeStatements = buildWriteMarkerStatements({\n space,\n storageHash: options.plan.destination.storageHash,\n profileHash:\n options.plan.destination.profileHash ??\n options.destinationContract.profileHash ??\n options.plan.destination.storageHash,\n contractJson: options.destinationContract,\n canonicalVersion: null,\n meta: {},\n invariants,\n });\n const statement = existingMarker ? writeStatements.update : writeStatements.insert;\n await this.executeStatement(driver, statement);\n }\n\n private async recordLedgerEntries(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n options: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>,\n existingMarker: ContractMarkerRecord | null,\n executedOperations: readonly SqlMigrationPlanOperation<SqlitePlanTargetDetails>[],\n ): Promise<void> {\n const plan = options.plan;\n const space = plan.spaceId;\n const destinationProfileHash =\n plan.destination.profileHash ??\n options.destinationContract.profileHash ??\n plan.destination.storageHash;\n const edges = options.migrationEdges;\n const totalEdgeOps = edges.reduce((sum, edge) => sum + edge.operationCount, 0);\n if (totalEdgeOps !== plan.operations.length) {\n throw new Error(\n `Ledger write: plan.operations length (${plan.operations.length}) does not match sum of migrationEdges operationCount (${totalEdgeOps})`,\n );\n }\n // The ledger records the operations as executed — idempotency-skipped ops\n // are substituted with skip records (empty `execute`) by `applyPlan`, so the\n // journal reflects what actually ran rather than the raw plan.\n let offset = 0;\n const lastIndex = edges.length - 1;\n for (const [i, edge] of edges.entries()) {\n const edgeOps = executedOperations.slice(offset, offset + edge.operationCount);\n offset += edge.operationCount;\n const isFirst = i === 0;\n const isLast = i === lastIndex;\n await this.executeStatement(\n driver,\n buildLedgerInsertStatement({\n space,\n migrationName: edge.dirName,\n migrationHash: edge.migrationHash,\n originStorageHash: edge.from === '' ? null : edge.from,\n originProfileHash:\n isFirst && existingMarker?.storageHash === edge.from\n ? (existingMarker.profileHash ?? null)\n : null,\n destinationStorageHash: edge.to,\n destinationProfileHash:\n isLast && edge.to === plan.destination.storageHash ? destinationProfileHash : null,\n contractJsonBefore: isFirst ? (existingMarker?.contractJson ?? null) : null,\n contractJsonAfter: isLast ? options.destinationContract : null,\n operations: edgeOps,\n }),\n );\n }\n }\n\n private async beginExclusiveTransaction(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<void> {\n await driver.query('BEGIN EXCLUSIVE');\n }\n\n private async commitTransaction(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<void> {\n await driver.query('COMMIT');\n }\n\n private async rollbackTransaction(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<void> {\n await driver.query('ROLLBACK');\n }\n\n private async executeStatement(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n statement: SqlStatement,\n ): Promise<void> {\n if (statement.params.length > 0) {\n await driver.query(statement.sql, statement.params);\n return;\n }\n await driver.query(statement.sql);\n }\n}\n","import type { Contract } from '@prisma-next/contract/types';\nimport { SqlSchemaVerifierBase } from '@prisma-next/family-sql/ir';\nimport type { SchemaIssue, SchemaVerifyOptions } from '@prisma-next/framework-components/control';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';\n\n/**\n * SQLite target `SchemaVerifier` concretion. Mirrors the Postgres\n * shape: hooks return the empty list pending the call-site migration\n * that routes the existing verifier behaviour through the SPI.\n */\nexport class SqliteSchemaVerifier extends SqlSchemaVerifierBase<Contract<SqlStorage>, SqlSchemaIR> {\n protected verifyCommonSqlSchema(\n _options: SchemaVerifyOptions<Contract<SqlStorage>, SqlSchemaIR>,\n ): readonly SchemaIssue[] {\n return [];\n }\n\n protected verifyTargetExtensions(\n _options: SchemaVerifyOptions<Contract<SqlStorage>, SqlSchemaIR>,\n ): readonly SchemaIssue[] {\n return [];\n }\n}\n","import type { ColumnDefault, Contract } from '@prisma-next/contract/types';\nimport type {\n SqlControlFamilyInstance,\n SqlControlTargetDescriptor,\n} from '@prisma-next/family-sql/control';\nimport { contractToSchemaIR } from '@prisma-next/family-sql/control';\nimport type {\n ControlTargetInstance,\n MigrationPlanner,\n MigrationRunner,\n} from '@prisma-next/framework-components/control';\nimport { SqlStorage, type StorageColumn } from '@prisma-next/sql-contract/types';\nimport { sqliteTargetDescriptorMeta } from './descriptor-meta';\nimport { createSqliteMigrationPlanner } from './migrations/planner';\nimport { renderDefaultLiteral } from './migrations/planner-ddl-builders';\nimport type { SqlitePlanTargetDetails } from './migrations/planner-target-details';\nimport { createSqliteMigrationRunner } from './migrations/runner';\nimport { SqliteContractSerializer } from './sqlite-contract-serializer';\nimport { SqliteSchemaVerifier } from './sqlite-schema-verifier';\n\nfunction isSqlContract(contract: Contract | null): contract is Contract<SqlStorage> | null {\n return contract === null || contract.storage instanceof SqlStorage;\n}\n\nfunction sqliteRenderDefault(def: ColumnDefault, _column: StorageColumn): string {\n if (def.kind === 'function') {\n if (def.expression === 'now()') {\n return \"datetime('now')\";\n }\n return def.expression;\n }\n return renderDefaultLiteral(def.value);\n}\n\nconst sqliteControlTargetDescriptor: SqlControlTargetDescriptor<'sqlite', SqlitePlanTargetDetails> =\n {\n ...sqliteTargetDescriptorMeta,\n contractSerializer: new SqliteContractSerializer(),\n schemaVerifier: new SqliteSchemaVerifier(),\n migrations: {\n createPlanner(_family: SqlControlFamilyInstance): MigrationPlanner<'sql', 'sqlite'> {\n return createSqliteMigrationPlanner();\n },\n createRunner(family) {\n return createSqliteMigrationRunner(family) as MigrationRunner<'sql', 'sqlite'>;\n },\n contractToSchema(contract, _frameworkComponents) {\n // The framework SPI types `contract` as the generic\n // `Contract | null`. Any contract reaching the sqlite\n // target descriptor is SQL-family by construction (the\n // family contract resolver would have refused to bind a\n // sqlite target otherwise); the `isSqlContract` predicate\n // encodes that invariant at runtime + narrows the generic\n // to `Contract<SqlStorage>` without a blind cast.\n if (!isSqlContract(contract)) {\n throw new Error(\n 'sqliteControlTargetDescriptor.contractToSchema received a non-SQL contract; expected Contract<SqlStorage>',\n );\n }\n return contractToSchemaIR(contract, {\n annotationNamespace: 'sqlite',\n renderDefault: sqliteRenderDefault,\n });\n },\n },\n create(): ControlTargetInstance<'sql', 'sqlite'> {\n return {\n familyId: 'sql',\n targetId: 'sqlite',\n };\n },\n createPlanner(_family: SqlControlFamilyInstance) {\n return createSqliteMigrationPlanner();\n },\n createRunner(family) {\n return createSqliteMigrationRunner(family);\n },\n };\n\nexport default sqliteControlTargetDescriptor;\n"],"mappings":";;;;;;;;;;;;;;;;AAqCA,SAAgB,4BACd,QAC6C;CAC7C,OAAO,IAAI,sBAAsB,MAAM;AACzC;AAEA,IAAM,wBAAN,MAAmF;CACpD;CAA7B,YAAY,QAAmD;EAAlC,KAAA,SAAA;CAAmC;;;;;;;CAQhE,MAAM,oBACJ,SACmC;EACnC,MAAM,SAAS,QAAQ;EACvB,IAAI,QAAQ,UAAU,KAAA,KAAa,QAAQ,UAAU,QAAQ,KAAK,SAChE,MAAM,IAAI,MACR,sCAAsC,QAAQ,MAAM,iCAAiC,QAAQ,KAAK,QAAQ,EAC5G;EAEF,MAAM,QAAQ,QAAQ,KAAK;EAE3B,MAAM,mBAAmB,KAAK,qCAC5B,QAAQ,KAAK,aACb,QAAQ,mBACV;EACA,IAAI,CAAC,iBAAiB,IAAI,OAAO;EAEjC,MAAM,cAAc,KAAK,2BAA2B,QAAQ,QAAQ,QAAQ,KAAK,UAAU;EAC3F,IAAI,CAAC,YAAY,IAAI,OAAO;EAE5B,MAAM,eAAe,MAAM,KAAK,oBAAoB,MAAM;EAC1D,IAAI,CAAC,aAAa,IAAI,OAAO;EAC7B,MAAM,iBAAiB,MAAM,KAAK,WAAW,QAAQ,KAAK;EAE1D,MAAM,cAAc,KAAK,0BAA0B,gBAAgB,QAAQ,IAAI;EAC/E,IAAI,CAAC,YAAY,IAAI,OAAO;EAE5B,MAAM,sBAAsB,KAAK,yBAAyB,gBAAgB,QAAQ,IAAI;EACtF,MAAM,aAAa,QAAQ,KAAK,QAAQ,gBAAgB,QAAQ,KAAK,YAAY;EACjF,MAAM,iBAAiB,uBAAuB,QAAQ,KAAK,UAAU,QAAQ,CAAC;EAE9E,I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AC;CACV;CAEA,uBACE,UACwB;EACxB,OAAO,CAAC;CACV;AACF;;;ACHA,SAAS,cAAc,UAAoE;CACzF,OAAO,aAAa,QAAQ,SAAS,mBAAmB;AAC1D;AAEA,SAAS,oBAAoB,KAAoB,SAAgC;CAC/E,IAAI,IAAI,SAAS,YAAY;EAC3B,IAAI,IAAI,eAAe,SACrB,OAAO;EAET,OAAO,IAAI;CACb;CACA,OAAO,qBAAqB,IAAI,KAAK;AACvC;AAEA,MAAM,gCACJ;CACE,GAAG;CACH,oBAAoB,IAAI,yBAAyB;CACjD,gBAAgB,IAAI,qBAAqB;CACzC,YAAY;EACV,cAAc,SAAsE;GAClF,OAAO,6BAA6B;EACtC;EACA,aAAa,QAAQ;GACnB,OAAO,4BAA4B,MAAM;EAC3C;EACA,iBAAiB,UAAU,sBAAsB;GAQ/C,IAAI,CAAC,cAAc,QAAQ,GACzB,MAAM,IAAI,MACR,2GACF;GAEF,OAAO,mBAAmB,UAAU;IAClC,qBAAqB;IACrB,eAAe;GACjB,CAAC;EACH;CACF;CACA,SAAiD;EAC/C,OAAO;GACL,UAAU;GACV,UAAU;EACZ;CACF;CACA,cAAc,SAAmC;EAC/C,OAAO,6BAA6B;CACtC;CACA,aAAa,QAAQ;EACnB,OAAO,4BAA4B,MAAM;CAC3C;AACF"}
|
|
1
|
+
{"version":3,"file":"control.mjs","names":[],"sources":["../src/core/migrations/runner.ts","../src/core/sqlite-schema-verifier.ts","../src/core/control-target.ts"],"sourcesContent":["import type { Contract, ContractMarkerRecord } from '@prisma-next/contract/types';\nimport type {\n MigrationOperationPolicy,\n SqlControlFamilyInstance,\n SqlMigrationPlanContractInfo,\n SqlMigrationPlanOperation,\n SqlMigrationPlanOperationStep,\n SqlMigrationRunner,\n SqlMigrationRunnerExecuteOptions,\n SqlMigrationRunnerFailure,\n SqlMigrationRunnerResult,\n SqlMigrationRunnerSuccessValue,\n} from '@prisma-next/family-sql/control';\nimport { runnerFailure, runnerSuccess } from '@prisma-next/family-sql/control';\nimport { verifySqlSchema } from '@prisma-next/family-sql/schema-verify';\nimport { type ContractMarkerRow, parseContractMarkerRow } from '@prisma-next/family-sql/verify';\nimport type {\n ControlDriverInstance,\n MigrationRunnerResult,\n} from '@prisma-next/framework-components/control';\nimport { APP_SPACE_ID } from '@prisma-next/framework-components/control';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport type { Result } from '@prisma-next/utils/result';\nimport { notOk, ok, okVoid } from '@prisma-next/utils/result';\nimport { parseSqliteDefault } from '../default-normalizer';\nimport { normalizeSqliteNativeType } from '../native-type-normalizer';\nimport type { SqlitePlanTargetDetails } from './planner-target-details';\nimport {\n buildLedgerInsertStatement,\n buildWriteMarkerStatements,\n MARKER_TABLE_NAME,\n readMarkerStatement,\n type SqlStatement,\n} from './statement-builders';\n\nexport function createSqliteMigrationRunner(\n family: SqlControlFamilyInstance,\n): SqlMigrationRunner<SqlitePlanTargetDetails> {\n return new SqliteMigrationRunner(family);\n}\n\nclass SqliteMigrationRunner implements SqlMigrationRunner<SqlitePlanTargetDetails> {\n constructor(private readonly family: SqlControlFamilyInstance) {}\n\n /**\n * Apply the plan against an already-open connection without managing\n * the transaction lifecycle. The caller ({@link SqliteMigrationRunner.execute})\n * owns BEGIN/COMMIT/ROLLBACK and any connection-level setup (FK pragma\n * toggle, FK integrity check).\n */\n async executeOnConnection(\n options: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>,\n ): Promise<SqlMigrationRunnerResult> {\n const driver = options.driver;\n if (options.space !== undefined && options.space !== options.plan.spaceId) {\n throw new Error(\n `SqlMigrationRunner: options.space (${options.space}) does not match plan.spaceId (${options.plan.spaceId})`,\n );\n }\n const space = options.plan.spaceId;\n\n const destinationCheck = this.ensurePlanMatchesDestinationContract(\n options.plan.destination,\n options.destinationContract,\n );\n if (!destinationCheck.ok) return destinationCheck;\n\n const policyCheck = this.enforcePolicyCompatibility(options.policy, options.plan.operations);\n if (!policyCheck.ok) return policyCheck;\n\n const ensureResult = await this.ensureControlTables(driver, options.destinationContract);\n if (!ensureResult.ok) return ensureResult;\n const existingMarker = await this.readMarker(driver, space);\n\n const markerCheck = this.ensureMarkerCompatibility(existingMarker, options.plan);\n if (!markerCheck.ok) return markerCheck;\n\n const markerAtDestination = this.markerMatchesDestination(existingMarker, options.plan);\n const isSelfEdge = options.plan.origin?.storageHash === options.plan.destination.storageHash;\n const skipOperations = markerAtDestination && options.plan.origin != null && !isSelfEdge;\n\n let operationsExecuted: number;\n let executedOperations: readonly SqlMigrationPlanOperation<SqlitePlanTargetDetails>[];\n\n if (skipOperations) {\n operationsExecuted = 0;\n executedOperations = [];\n } else {\n const applyResult = await this.applyPlan(driver, options);\n if (!applyResult.ok) return applyResult;\n operationsExecuted = applyResult.value.operationsExecuted;\n executedOperations = applyResult.value.executedOperations;\n }\n\n if (space === APP_SPACE_ID) {\n const schemaIR = await this.family.introspect({\n driver,\n contract: options.destinationContract,\n });\n\n const schemaVerifyResult = verifySqlSchema({\n contract: options.destinationContract,\n schema: schemaIR,\n strict: options.strictVerification ?? true,\n context: options.context ?? {},\n typeMetadataRegistry: this.family.typeMetadataRegistry,\n frameworkComponents: options.frameworkComponents,\n normalizeDefault: parseSqliteDefault,\n normalizeNativeType: normalizeSqliteNativeType,\n });\n if (!schemaVerifyResult.ok) {\n return runnerFailure('SCHEMA_VERIFY_FAILED', schemaVerifyResult.summary, {\n why: 'The resulting database schema does not satisfy the destination contract.',\n meta: { issues: schemaVerifyResult.schema.issues },\n });\n }\n }\n\n // Self-edge no-op detection: see Postgres runner for the rationale\n // (kept symmetric across both targets).\n const incomingInvariants = options.plan.providedInvariants;\n const existingInvariants = new Set(existingMarker?.invariants ?? []);\n const incomingIsSubsetOfExisting = incomingInvariants.every((id) => existingInvariants.has(id));\n const isSelfEdgeNoOp = isSelfEdge && operationsExecuted === 0 && incomingIsSubsetOfExisting;\n\n if (!isSelfEdgeNoOp) {\n await this.upsertMarker(driver, options, existingMarker, space);\n await this.recordLedgerEntries(driver, options, existingMarker, executedOperations);\n }\n\n return runnerSuccess({\n operationsPlanned: options.plan.operations.length,\n operationsExecuted,\n });\n }\n\n async execute(options: {\n readonly driver: ControlDriverInstance<'sql', string>;\n readonly perSpaceOptions: ReadonlyArray<\n SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>\n >;\n }): Promise<MigrationRunnerResult> {\n const driver = options.driver;\n const perSpaceOptions = options.perSpaceOptions;\n\n if (perSpaceOptions.length === 0) {\n return ok({ perSpaceResults: [] });\n }\n\n // FK pragma toggle and the FK integrity check both span the outer\n // transaction: PRAGMA foreign_keys is a no-op inside a transaction, so the\n // toggle has to wrap BEGIN/COMMIT.\n const fkWasEnabled = await this.readForeignKeysEnabled(driver);\n if (fkWasEnabled) {\n await driver.query('PRAGMA foreign_keys = OFF');\n }\n\n try {\n await this.beginExclusiveTransaction(driver);\n let committed = false;\n try {\n const perSpaceResults: Array<{\n space: string;\n value: SqlMigrationRunnerSuccessValue;\n }> = [];\n let lastProcessedSpace: string | undefined;\n for (const spaceOptions of perSpaceOptions) {\n const space = spaceOptions.space ?? spaceOptions.plan.spaceId;\n const result = await this.executeOnConnection({ ...spaceOptions, driver, space });\n if (!result.ok) {\n return notOk({ ...result.failure, failingSpace: space });\n }\n perSpaceResults.push({ space, value: result.value });\n lastProcessedSpace = space;\n }\n\n if (fkWasEnabled) {\n const fkIntegrityCheck = await this.verifyForeignKeyIntegrity(driver);\n if (!fkIntegrityCheck.ok) {\n // Post-loop integrity violations cannot be attributed to a\n // single per-space step (the cumulative effect of all\n // applied plans was needed to reveal the broken\n // reference). Surface the last successfully-applied space\n // so operators can investigate from the most recent\n // migration first.\n return notOk({\n ...fkIntegrityCheck.failure,\n failingSpace: lastProcessedSpace ?? APP_SPACE_ID,\n });\n }\n }\n\n await this.commitTransaction(driver);\n committed = true;\n return ok({ perSpaceResults });\n } finally {\n if (!committed) {\n await this.rollbackTransaction(driver);\n }\n }\n } finally {\n if (fkWasEnabled) {\n await driver.query('PRAGMA foreign_keys = ON');\n }\n }\n }\n\n private async readForeignKeysEnabled(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<boolean> {\n const result = await driver.query<{ foreign_keys: number }>('PRAGMA foreign_keys');\n const row = result.rows[0];\n return row?.foreign_keys === 1;\n }\n\n private async verifyForeignKeyIntegrity(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<Result<void, SqlMigrationRunnerFailure>> {\n const result = await driver.query<Record<string, unknown>>('PRAGMA foreign_key_check');\n if (result.rows.length === 0) {\n return okVoid();\n }\n return runnerFailure(\n 'FOREIGN_KEY_VIOLATION',\n `Foreign key integrity check failed after migration: ${result.rows.length} violation(s).`,\n {\n why: 'PRAGMA foreign_key_check reported violations after applying recreate-table operations.',\n meta: { violations: result.rows },\n },\n );\n }\n\n private async applyPlan(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n options: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>,\n ): Promise<\n Result<\n {\n readonly operationsExecuted: number;\n readonly executedOperations: readonly SqlMigrationPlanOperation<SqlitePlanTargetDetails>[];\n },\n SqlMigrationRunnerFailure\n >\n > {\n const checks = options.executionChecks;\n const runPrechecks = checks?.prechecks !== false;\n const runPostchecks = checks?.postchecks !== false;\n const runIdempotency = checks?.idempotencyChecks !== false;\n\n let operationsExecuted = 0;\n const executedOperations: Array<SqlMigrationPlanOperation<SqlitePlanTargetDetails>> = [];\n\n for (const operation of options.plan.operations) {\n options.callbacks?.onOperationStart?.(operation);\n try {\n if (runPostchecks && runIdempotency) {\n const postcheckAlreadySatisfied = await this.expectationsAreSatisfied(\n driver,\n operation.postcheck,\n );\n if (postcheckAlreadySatisfied) {\n executedOperations.push(this.createSkipRecord(operation));\n continue;\n }\n }\n\n if (runPrechecks) {\n const precheckResult = await this.runExpectationSteps(\n driver,\n operation.precheck,\n operation,\n 'precheck',\n );\n if (!precheckResult.ok) {\n return precheckResult;\n }\n }\n\n const executeResult = await this.runExecuteSteps(driver, operation.execute, operation);\n if (!executeResult.ok) {\n return executeResult;\n }\n\n if (runPostchecks) {\n const postcheckResult = await this.runExpectationSteps(\n driver,\n operation.postcheck,\n operation,\n 'postcheck',\n );\n if (!postcheckResult.ok) {\n return postcheckResult;\n }\n }\n\n executedOperations.push(operation);\n operationsExecuted += 1;\n } finally {\n options.callbacks?.onOperationComplete?.(operation);\n }\n }\n return ok({ operationsExecuted, executedOperations });\n }\n\n private async ensureControlTables(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n contract: Contract<SqlStorage>,\n ): Promise<Result<void, SqlMigrationRunnerFailure>> {\n const legacyDetection = await this.detectLegacyMarkerShape(driver);\n if (!legacyDetection.ok) {\n return legacyDetection;\n }\n const lowererContext = { contract };\n for (const query of this.family.bootstrapControlTableQueries()) {\n await this.executeStatement(driver, this.family.lowerAst(query, lowererContext));\n }\n return okVoid();\n }\n\n private async detectLegacyMarkerShape(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<Result<void, SqlMigrationRunnerFailure>> {\n const tableInfo = await driver.query<{ name: string }>(\n `PRAGMA table_info(\"${MARKER_TABLE_NAME}\")`,\n );\n if (tableInfo.rows.length === 0) {\n return okVoid();\n }\n const columns = new Set(tableInfo.rows.map((row) => row.name));\n if (columns.has('space')) {\n return okVoid();\n }\n return runnerFailure(\n 'LEGACY_MARKER_SHAPE',\n `Legacy marker-table shape detected on ${MARKER_TABLE_NAME} (no \\`space\\` column). ` +\n 'Prisma Next is in pre-1.0; the previous transitional auto-migration to the per-space-row schema has been removed. ' +\n `Drop \\`${MARKER_TABLE_NAME}\\` and re-run \\`dbInit\\` to reinitialise from a clean baseline.`,\n {\n meta: {\n table: MARKER_TABLE_NAME,\n columns: [...columns].sort(),\n },\n },\n );\n }\n\n private async readMarker(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n space: string,\n ): Promise<ContractMarkerRecord | null> {\n const stmt = readMarkerStatement(space);\n try {\n const result = await driver.query<ContractMarkerRow>(stmt.sql, stmt.params);\n const row = result.rows[0];\n if (!row) return null;\n // SQLite stores arrays as JSON-encoded TEXT (no native array type), so\n // the driver returns `invariants` as a string. Decode before delegating\n // to the shared row schema, which expects `string[]`.\n const invariants =\n typeof row.invariants === 'string'\n ? (JSON.parse(row.invariants) as unknown)\n : row.invariants;\n return parseContractMarkerRow({ ...row, invariants });\n } catch (error) {\n // Table might not exist yet\n if (error instanceof Error && error.message.includes('no such table')) {\n return null;\n }\n throw error;\n }\n }\n\n private async runExpectationSteps(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n steps: readonly SqlMigrationPlanOperationStep[],\n operation: SqlMigrationPlanOperation<SqlitePlanTargetDetails>,\n phase: 'precheck' | 'postcheck',\n ): Promise<Result<void, SqlMigrationRunnerFailure>> {\n for (const step of steps) {\n const result = await driver.query(step.sql, step.params ?? []);\n if (!this.stepResultIsTrue(result.rows)) {\n const code = phase === 'precheck' ? 'PRECHECK_FAILED' : 'POSTCHECK_FAILED';\n return runnerFailure(\n code,\n `Operation ${operation.id} failed during ${phase}: ${step.description}`,\n {\n meta: {\n operationId: operation.id,\n phase,\n stepDescription: step.description,\n },\n },\n );\n }\n }\n return okVoid();\n }\n\n private async runExecuteSteps(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n steps: readonly SqlMigrationPlanOperationStep[],\n operation: SqlMigrationPlanOperation<SqlitePlanTargetDetails>,\n ): Promise<Result<void, SqlMigrationRunnerFailure>> {\n for (const step of steps) {\n try {\n await driver.query(step.sql, step.params ?? []);\n } catch (error: unknown) {\n const message = error instanceof Error ? error.message : String(error);\n return runnerFailure(\n 'EXECUTION_FAILED',\n `Operation ${operation.id} failed during execution: ${step.description}`,\n {\n why: message,\n meta: {\n operationId: operation.id,\n stepDescription: step.description,\n sql: step.sql,\n },\n },\n );\n }\n }\n return okVoid();\n }\n\n private stepResultIsTrue(rows: readonly Record<string, unknown>[]): boolean {\n if (!rows || rows.length === 0) {\n return false;\n }\n const firstRow = rows[0];\n const firstValue = firstRow ? Object.values(firstRow)[0] : undefined;\n if (typeof firstValue === 'number') {\n return firstValue !== 0;\n }\n if (typeof firstValue === 'boolean') {\n return firstValue;\n }\n if (typeof firstValue === 'string') {\n const lower = firstValue.toLowerCase();\n if (lower === 'true' || lower === '1') return true;\n if (lower === 'false' || lower === '0') return false;\n return firstValue.length > 0;\n }\n return Boolean(firstValue);\n }\n\n private async expectationsAreSatisfied(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n steps: readonly SqlMigrationPlanOperationStep[],\n ): Promise<boolean> {\n if (steps.length === 0) {\n return false;\n }\n for (const step of steps) {\n const result = await driver.query(step.sql, step.params ?? []);\n if (!this.stepResultIsTrue(result.rows)) {\n return false;\n }\n }\n return true;\n }\n\n private createSkipRecord(\n operation: SqlMigrationPlanOperation<SqlitePlanTargetDetails>,\n ): SqlMigrationPlanOperation<SqlitePlanTargetDetails> {\n return Object.freeze({\n id: operation.id,\n label: operation.label,\n ...ifDefined('summary', operation.summary),\n operationClass: operation.operationClass,\n target: operation.target,\n precheck: Object.freeze([]),\n execute: Object.freeze([]),\n postcheck: Object.freeze([...operation.postcheck]),\n meta: Object.freeze({\n ...(operation.meta ?? {}),\n runner: Object.freeze({ skipped: true, reason: 'postcheck_pre_satisfied' }),\n }),\n });\n }\n\n private markerMatchesDestination(\n marker: ContractMarkerRecord | null,\n plan: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['plan'],\n ): boolean {\n if (!marker) return false;\n if (marker.storageHash !== plan.destination.storageHash) return false;\n if (plan.destination.profileHash && marker.profileHash !== plan.destination.profileHash) {\n return false;\n }\n return true;\n }\n\n private enforcePolicyCompatibility(\n policy: MigrationOperationPolicy,\n operations: readonly SqlMigrationPlanOperation<SqlitePlanTargetDetails>[],\n ): Result<void, SqlMigrationRunnerFailure> {\n const allowedClasses = new Set(policy.allowedOperationClasses);\n for (const operation of operations) {\n if (!allowedClasses.has(operation.operationClass)) {\n return runnerFailure(\n 'POLICY_VIOLATION',\n `Operation ${operation.id} has class \"${operation.operationClass}\" which is not allowed by policy.`,\n {\n why: `Policy only allows: ${policy.allowedOperationClasses.join(', ')}.`,\n meta: {\n operationId: operation.id,\n operationClass: operation.operationClass,\n allowedClasses: policy.allowedOperationClasses,\n },\n },\n );\n }\n }\n return okVoid();\n }\n\n private ensureMarkerCompatibility(\n marker: ContractMarkerRecord | null,\n plan: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['plan'],\n ): Result<void, SqlMigrationRunnerFailure> {\n const origin = plan.origin ?? null;\n if (!origin) {\n return okVoid();\n }\n if (!marker) {\n return runnerFailure(\n 'MARKER_ORIGIN_MISMATCH',\n `Missing contract marker: expected origin storage hash ${origin.storageHash}.`,\n { meta: { expectedOriginStorageHash: origin.storageHash } },\n );\n }\n if (marker.storageHash !== origin.storageHash) {\n return runnerFailure(\n 'MARKER_ORIGIN_MISMATCH',\n `Existing contract marker (${marker.storageHash}) does not match plan origin (${origin.storageHash}).`,\n {\n meta: {\n markerStorageHash: marker.storageHash,\n expectedOriginStorageHash: origin.storageHash,\n },\n },\n );\n }\n if (origin.profileHash && marker.profileHash !== origin.profileHash) {\n return runnerFailure(\n 'MARKER_ORIGIN_MISMATCH',\n `Existing contract marker profile hash (${marker.profileHash}) does not match plan origin profile hash (${origin.profileHash}).`,\n {\n meta: {\n markerProfileHash: marker.profileHash,\n expectedOriginProfileHash: origin.profileHash,\n },\n },\n );\n }\n return okVoid();\n }\n\n private ensurePlanMatchesDestinationContract(\n destination: SqlMigrationPlanContractInfo,\n contract: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['destinationContract'],\n ): Result<void, SqlMigrationRunnerFailure> {\n if (destination.storageHash !== contract.storage.storageHash) {\n return runnerFailure(\n 'DESTINATION_CONTRACT_MISMATCH',\n `Plan destination storage hash (${destination.storageHash}) does not match provided contract storage hash (${contract.storage.storageHash}).`,\n {\n meta: {\n planStorageHash: destination.storageHash,\n contractStorageHash: contract.storage.storageHash,\n },\n },\n );\n }\n if (\n destination.profileHash &&\n contract.profileHash &&\n destination.profileHash !== contract.profileHash\n ) {\n return runnerFailure(\n 'DESTINATION_CONTRACT_MISMATCH',\n `Plan destination profile hash (${destination.profileHash}) does not match provided contract profile hash (${contract.profileHash}).`,\n {\n meta: {\n planProfileHash: destination.profileHash,\n contractProfileHash: contract.profileHash,\n },\n },\n );\n }\n return okVoid();\n }\n\n private async upsertMarker(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n options: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>,\n existingMarker: ContractMarkerRecord | null,\n space: string,\n ): Promise<void> {\n // SQLite has no native array type, so we can't merge invariants in SQL\n // the way Postgres does. Merge client-side under the runner's\n // BEGIN EXCLUSIVE — sort + dedupe so the JSON-encoded value is stable.\n const merged = new Set<string>(existingMarker?.invariants ?? []);\n for (const inv of options.plan.providedInvariants) merged.add(inv);\n const invariants = Array.from(merged).sort();\n const writeStatements = buildWriteMarkerStatements({\n space,\n storageHash: options.plan.destination.storageHash,\n profileHash:\n options.plan.destination.profileHash ??\n options.destinationContract.profileHash ??\n options.plan.destination.storageHash,\n contractJson: options.destinationContract,\n canonicalVersion: null,\n meta: {},\n invariants,\n });\n const statement = existingMarker ? writeStatements.update : writeStatements.insert;\n await this.executeStatement(driver, statement);\n }\n\n private async recordLedgerEntries(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n options: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>,\n existingMarker: ContractMarkerRecord | null,\n executedOperations: readonly SqlMigrationPlanOperation<SqlitePlanTargetDetails>[],\n ): Promise<void> {\n const plan = options.plan;\n const space = plan.spaceId;\n const destinationProfileHash =\n plan.destination.profileHash ??\n options.destinationContract.profileHash ??\n plan.destination.storageHash;\n const edges = options.migrationEdges;\n const totalEdgeOps = edges.reduce((sum, edge) => sum + edge.operationCount, 0);\n if (totalEdgeOps !== plan.operations.length) {\n throw new Error(\n `Ledger write: plan.operations length (${plan.operations.length}) does not match sum of migrationEdges operationCount (${totalEdgeOps})`,\n );\n }\n // The ledger records the operations as executed — idempotency-skipped ops\n // are substituted with skip records (empty `execute`) by `applyPlan`, so the\n // journal reflects what actually ran rather than the raw plan.\n let offset = 0;\n const lastIndex = edges.length - 1;\n for (const [i, edge] of edges.entries()) {\n const edgeOps = executedOperations.slice(offset, offset + edge.operationCount);\n offset += edge.operationCount;\n const isFirst = i === 0;\n const isLast = i === lastIndex;\n await this.executeStatement(\n driver,\n buildLedgerInsertStatement({\n space,\n migrationName: edge.dirName,\n migrationHash: edge.migrationHash,\n originStorageHash: edge.from === '' ? null : edge.from,\n originProfileHash:\n isFirst && existingMarker?.storageHash === edge.from\n ? (existingMarker.profileHash ?? null)\n : null,\n destinationStorageHash: edge.to,\n destinationProfileHash:\n isLast && edge.to === plan.destination.storageHash ? destinationProfileHash : null,\n contractJsonBefore: isFirst ? (existingMarker?.contractJson ?? null) : null,\n contractJsonAfter: isLast ? options.destinationContract : null,\n operations: edgeOps,\n }),\n );\n }\n }\n\n private async beginExclusiveTransaction(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<void> {\n await driver.query('BEGIN EXCLUSIVE');\n }\n\n private async commitTransaction(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<void> {\n await driver.query('COMMIT');\n }\n\n private async rollbackTransaction(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n ): Promise<void> {\n await driver.query('ROLLBACK');\n }\n\n private async executeStatement(\n driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],\n statement: SqlStatement,\n ): Promise<void> {\n if (statement.params.length > 0) {\n await driver.query(statement.sql, statement.params);\n return;\n }\n await driver.query(statement.sql);\n }\n}\n","import type { Contract } from '@prisma-next/contract/types';\nimport { SqlSchemaVerifierBase } from '@prisma-next/family-sql/ir';\nimport type { SchemaIssue, SchemaVerifyOptions } from '@prisma-next/framework-components/control';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';\n\n/**\n * SQLite target `SchemaVerifier` concretion. Mirrors the Postgres\n * shape: hooks return the empty list pending the call-site migration\n * that routes the existing verifier behaviour through the SPI.\n */\nexport class SqliteSchemaVerifier extends SqlSchemaVerifierBase<Contract<SqlStorage>, SqlSchemaIR> {\n protected verifyCommonSqlSchema(\n _options: SchemaVerifyOptions<Contract<SqlStorage>, SqlSchemaIR>,\n ): readonly SchemaIssue[] {\n return [];\n }\n\n protected verifyTargetExtensions(\n _options: SchemaVerifyOptions<Contract<SqlStorage>, SqlSchemaIR>,\n ): readonly SchemaIssue[] {\n return [];\n }\n}\n","import type { ColumnDefault, Contract } from '@prisma-next/contract/types';\nimport type {\n SqlControlFamilyInstance,\n SqlControlTargetDescriptor,\n} from '@prisma-next/family-sql/control';\nimport { contractToSchemaIR } from '@prisma-next/family-sql/control';\nimport type {\n ControlTargetInstance,\n MigrationPlanner,\n MigrationRunner,\n} from '@prisma-next/framework-components/control';\nimport { SqlStorage, type StorageColumn } from '@prisma-next/sql-contract/types';\nimport { sqliteTargetDescriptorMeta } from './descriptor-meta';\nimport { createSqliteMigrationPlanner } from './migrations/planner';\nimport { renderDefaultLiteral } from './migrations/planner-ddl-builders';\nimport type { SqlitePlanTargetDetails } from './migrations/planner-target-details';\nimport { createSqliteMigrationRunner } from './migrations/runner';\nimport { SqliteContractSerializer } from './sqlite-contract-serializer';\nimport { SqliteSchemaVerifier } from './sqlite-schema-verifier';\n\nfunction isSqlContract(contract: Contract | null): contract is Contract<SqlStorage> | null {\n return contract === null || contract.storage instanceof SqlStorage;\n}\n\nfunction sqliteRenderDefault(def: ColumnDefault, _column: StorageColumn): string {\n if (def.kind === 'function') {\n if (def.expression === 'now()') {\n return \"datetime('now')\";\n }\n return def.expression;\n }\n return renderDefaultLiteral(def.value);\n}\n\nconst sqliteControlTargetDescriptor: SqlControlTargetDescriptor<'sqlite', SqlitePlanTargetDetails> =\n {\n ...sqliteTargetDescriptorMeta,\n contractSerializer: new SqliteContractSerializer(),\n schemaVerifier: new SqliteSchemaVerifier(),\n migrations: {\n createPlanner(_family: SqlControlFamilyInstance): MigrationPlanner<'sql', 'sqlite'> {\n return createSqliteMigrationPlanner();\n },\n createRunner(family) {\n return createSqliteMigrationRunner(family) as MigrationRunner<'sql', 'sqlite'>;\n },\n contractToSchema(contract, _frameworkComponents) {\n // The framework SPI types `contract` as the generic\n // `Contract | null`. Any contract reaching the sqlite\n // target descriptor is SQL-family by construction (the\n // family contract resolver would have refused to bind a\n // sqlite target otherwise); the `isSqlContract` predicate\n // encodes that invariant at runtime + narrows the generic\n // to `Contract<SqlStorage>` without a blind cast.\n if (!isSqlContract(contract)) {\n throw new Error(\n 'sqliteControlTargetDescriptor.contractToSchema received a non-SQL contract; expected Contract<SqlStorage>',\n );\n }\n return contractToSchemaIR(contract, {\n annotationNamespace: 'sqlite',\n renderDefault: sqliteRenderDefault,\n });\n },\n },\n create(): ControlTargetInstance<'sql', 'sqlite'> {\n return {\n familyId: 'sql',\n targetId: 'sqlite',\n };\n },\n createPlanner(_family: SqlControlFamilyInstance) {\n return createSqliteMigrationPlanner();\n },\n createRunner(family) {\n return createSqliteMigrationRunner(family);\n },\n };\n\nexport default sqliteControlTargetDescriptor;\n"],"mappings":";;;;;;;;;;;;;;;;AAoCA,SAAgB,4BACd,QAC6C;CAC7C,OAAO,IAAI,sBAAsB,MAAM;AACzC;AAEA,IAAM,wBAAN,MAAmF;CACpD;CAA7B,YAAY,QAAmD;EAAlC,KAAA,S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B,IAAI,KAAK;AACvC;AAEA,MAAM,gCACJ;CACE,GAAG;CACH,oBAAoB,IAAI,yBAAyB;CACjD,gBAAgB,IAAI,qBAAqB;CACzC,YAAY;EACV,cAAc,SAAsE;GAClF,OAAO,6BAA6B;EACtC;EACA,aAAa,QAAQ;GACnB,OAAO,4BAA4B,MAAM;EAC3C;EACA,iBAAiB,UAAU,sBAAsB;GAQ/C,IAAI,CAAC,cAAc,QAAQ,GACzB,MAAM,IAAI,MACR,2GACF;GAEF,OAAO,mBAAmB,UAAU;IAClC,qBAAqB;IACrB,eAAe;GACjB,CAAC;EACH;CACF;CACA,SAAiD;EAC/C,OAAO;GACL,UAAU;GACV,UAAU;EACZ;CACF;CACA,cAAc,SAAmC;EAC/C,OAAO,6BAA6B;CACtC;CACA,aAAa,QAAQ;EACnB,OAAO,4BAA4B,MAAM;CAC3C;AACF"}
|
package/dist/ddl.d.mts
ADDED
package/dist/ddl.mjs
ADDED
package/dist/migration.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as SqliteTableSpec, n as SqliteColumnSpec, r as SqliteIndexSpec, t as Op } from "./shared-
|
|
2
|
-
import { t as SqliteMigration } from "./sqlite-migration-
|
|
1
|
+
import { i as SqliteTableSpec, n as SqliteColumnSpec, r as SqliteIndexSpec, t as Op } from "./shared-Bw5G0I-c.mjs";
|
|
2
|
+
import { t as SqliteMigration } from "./sqlite-migration-D-O3Glz1.mjs";
|
|
3
3
|
import { MigrationOperationClass } from "@prisma-next/family-sql/control";
|
|
4
4
|
import { placeholder } from "@prisma-next/errors/migration";
|
|
5
5
|
import { MigrationCLI } from "@prisma-next/cli/migration-cli";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { DdlNode } from "@prisma-next/sql-relational-core/ast";
|
|
2
|
+
//#region src/core/ddl/nodes.ts
|
|
3
|
+
var SqliteDdlNode = class extends DdlNode {};
|
|
4
|
+
function freezeDdlColumns(columns) {
|
|
5
|
+
return Object.freeze([...columns]);
|
|
6
|
+
}
|
|
7
|
+
var SqliteCreateTable = class extends SqliteDdlNode {
|
|
8
|
+
kind = "create-table";
|
|
9
|
+
table;
|
|
10
|
+
schema;
|
|
11
|
+
ifNotExists;
|
|
12
|
+
columns;
|
|
13
|
+
constructor(options) {
|
|
14
|
+
super();
|
|
15
|
+
this.table = options.table;
|
|
16
|
+
this.schema = options.schema;
|
|
17
|
+
this.ifNotExists = options.ifNotExists;
|
|
18
|
+
this.columns = freezeDdlColumns(options.columns);
|
|
19
|
+
this.freeze();
|
|
20
|
+
}
|
|
21
|
+
accept(visitor) {
|
|
22
|
+
return visitor.createTable(this);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
export { SqliteDdlNode as n, SqliteCreateTable as t };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=nodes-09ul6DNV.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodes-09ul6DNV.mjs","names":[],"sources":["../src/core/ddl/nodes.ts"],"sourcesContent":["import { type DdlColumn, DdlNode } from '@prisma-next/sql-relational-core/ast';\n\nexport interface SqliteDdlVisitor<R> {\n createTable(node: SqliteCreateTable): R;\n}\n\nexport abstract class SqliteDdlNode extends DdlNode {\n abstract accept<R>(visitor: SqliteDdlVisitor<R>): R;\n}\n\nfunction freezeDdlColumns(columns: readonly DdlColumn[]): ReadonlyArray<DdlColumn> {\n return Object.freeze([...columns]);\n}\n\nexport class SqliteCreateTable extends SqliteDdlNode {\n readonly kind = 'create-table' as const;\n readonly table: string;\n readonly schema: string | undefined;\n readonly ifNotExists: boolean | undefined;\n readonly columns: ReadonlyArray<DdlColumn>;\n\n constructor(options: {\n readonly table: string;\n readonly schema?: string;\n readonly ifNotExists?: boolean;\n readonly columns: readonly DdlColumn[];\n }) {\n super();\n this.table = options.table;\n this.schema = options.schema;\n this.ifNotExists = options.ifNotExists;\n this.columns = freezeDdlColumns(options.columns);\n this.freeze();\n }\n\n override accept<R>(visitor: SqliteDdlVisitor<R>): R {\n return visitor.createTable(this);\n }\n}\n\nexport type AnySqliteDdlNode = SqliteCreateTable;\n"],"mappings":";;AAMA,IAAsB,gBAAtB,cAA4C,QAAQ,CAEpD;AAEA,SAAS,iBAAiB,SAAyD;CACjF,OAAO,OAAO,OAAO,CAAC,GAAG,OAAO,CAAC;AACnC;AAEA,IAAa,oBAAb,cAAuC,cAAc;CACnD,OAAgB;CAChB;CACA;CACA;CACA;CAEA,YAAY,SAKT;EACD,MAAM;EACN,KAAK,QAAQ,QAAQ;EACrB,KAAK,SAAS,QAAQ;EACtB,KAAK,cAAc,QAAQ;EAC3B,KAAK,UAAU,iBAAiB,QAAQ,OAAO;EAC/C,KAAK,OAAO;CACd;CAEA,OAAmB,SAAiC;EAClD,OAAO,QAAQ,YAAY,IAAI;CACjC;AACF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DdlColumn, DdlNode } from "@prisma-next/sql-relational-core/ast";
|
|
2
|
+
|
|
3
|
+
//#region src/core/ddl/nodes.d.ts
|
|
4
|
+
interface SqliteDdlVisitor<R> {
|
|
5
|
+
createTable(node: SqliteCreateTable): R;
|
|
6
|
+
}
|
|
7
|
+
declare abstract class SqliteDdlNode extends DdlNode {
|
|
8
|
+
abstract accept<R>(visitor: SqliteDdlVisitor<R>): R;
|
|
9
|
+
}
|
|
10
|
+
declare class SqliteCreateTable extends SqliteDdlNode {
|
|
11
|
+
readonly kind: "create-table";
|
|
12
|
+
readonly table: string;
|
|
13
|
+
readonly schema: string | undefined;
|
|
14
|
+
readonly ifNotExists: boolean | undefined;
|
|
15
|
+
readonly columns: ReadonlyArray<DdlColumn>;
|
|
16
|
+
constructor(options: {
|
|
17
|
+
readonly table: string;
|
|
18
|
+
readonly schema?: string;
|
|
19
|
+
readonly ifNotExists?: boolean;
|
|
20
|
+
readonly columns: readonly DdlColumn[];
|
|
21
|
+
});
|
|
22
|
+
accept<R>(visitor: SqliteDdlVisitor<R>): R;
|
|
23
|
+
}
|
|
24
|
+
type AnySqliteDdlNode = SqliteCreateTable;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { SqliteDdlVisitor as i, SqliteCreateTable as n, SqliteDdlNode as r, AnySqliteDdlNode as t };
|
|
27
|
+
//# sourceMappingURL=nodes-D8LGV4Yk.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodes-D8LGV4Yk.d.mts","names":[],"sources":["../src/core/ddl/nodes.ts"],"mappings":";;;UAEiB,gBAAA;EACf,WAAA,CAAY,IAAA,EAAM,iBAAA,GAAoB,CAAC;AAAA;AAAA,uBAGnB,aAAA,SAAsB,OAAA;EAAA,SACjC,MAAA,GAAA,CAAU,OAAA,EAAS,gBAAA,CAAiB,CAAA,IAAK,CAAA;AAAA;AAAA,cAOvC,iBAAA,SAA0B,aAAA;EAAA,SAC5B,IAAA;EAAA,SACA,KAAA;EAAA,SACA,MAAA;EAAA,SACA,WAAA;EAAA,SACA,OAAA,EAAS,aAAA,CAAc,SAAA;cAEpB,OAAA;IAAA,SACD,KAAA;IAAA,SACA,MAAA;IAAA,SACA,WAAA;IAAA,SACA,OAAA,WAAkB,SAAA;EAAA;EAUpB,MAAA,GAAA,CAAU,OAAA,EAAS,gBAAA,CAAiB,CAAA,IAAK,CAAA;AAAA;AAAA,KAKxC,gBAAA,GAAmB,iBAAiB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as SqlitePlanTargetDetails } from "./planner-target-details-
|
|
2
|
-
import { i as SqliteTableSpec, n as SqliteColumnSpec, r as SqliteIndexSpec } from "./shared-
|
|
1
|
+
import { t as SqlitePlanTargetDetails } from "./planner-target-details-RVPqF2ug.mjs";
|
|
2
|
+
import { i as SqliteTableSpec, n as SqliteColumnSpec, r as SqliteIndexSpec } from "./shared-Bw5G0I-c.mjs";
|
|
3
3
|
import { MigrationOperationClass, SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
|
|
4
4
|
import { ImportRequirement, TsExpression } from "@prisma-next/ts-render";
|
|
5
5
|
import { OpFactoryCall } from "@prisma-next/framework-components/control";
|
package/dist/pack.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as SqlitePlanTargetDetails } from "./planner-target-details-
|
|
2
|
-
import { t as SqliteMigration } from "./sqlite-migration-
|
|
1
|
+
import { t as SqlitePlanTargetDetails } from "./planner-target-details-RVPqF2ug.mjs";
|
|
2
|
+
import { t as SqliteMigration } from "./sqlite-migration-D-O3Glz1.mjs";
|
|
3
3
|
import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
|
|
4
4
|
import { MigrationPlanWithAuthoringSurface, OpFactoryCall } from "@prisma-next/framework-components/control";
|
|
5
5
|
import { MigrationMeta } from "@prisma-next/migration-tools/migration";
|
|
@@ -26,4 +26,4 @@ declare class TypeScriptRenderableSqliteMigration extends SqliteMigration implem
|
|
|
26
26
|
}
|
|
27
27
|
//#endregion
|
|
28
28
|
export { TypeScriptRenderableSqliteMigration as n, SqliteMigrationDestinationInfo as t };
|
|
29
|
-
//# sourceMappingURL=planner-produced-sqlite-migration-
|
|
29
|
+
//# sourceMappingURL=planner-produced-sqlite-migration-BwFkd0br.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner-produced-sqlite-migration-
|
|
1
|
+
{"version":3,"file":"planner-produced-sqlite-migration-BwFkd0br.d.mts","names":[],"sources":["../src/core/migrations/planner-produced-sqlite-migration.ts"],"mappings":";;;;;;;KAWK,EAAA,GAAK,yBAAyB,CAAC,uBAAA;AAAA,UAEnB,8BAAA;EAAA,SACN,WAAA;EAAA,SACA,WAAW;AAAA;AAAA,cAGT,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,2 +1,2 @@
|
|
|
1
|
-
import { n as TypeScriptRenderableSqliteMigration, t as SqliteMigrationDestinationInfo } from "./planner-produced-sqlite-migration-
|
|
1
|
+
import { n as TypeScriptRenderableSqliteMigration, t as SqliteMigrationDestinationInfo } from "./planner-produced-sqlite-migration-BwFkd0br.mjs";
|
|
2
2
|
export { type SqliteMigrationDestinationInfo, TypeScriptRenderableSqliteMigration };
|
package/dist/{planner-target-details-DkD4PzGm.d.mts → planner-target-details-RVPqF2ug.d.mts}
RENAMED
|
@@ -9,4 +9,4 @@ interface SqlitePlanTargetDetails {
|
|
|
9
9
|
declare function buildTargetDetails(objectType: OperationClass, name: string, table?: string): SqlitePlanTargetDetails;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { buildTargetDetails as n, SqlitePlanTargetDetails as t };
|
|
12
|
-
//# sourceMappingURL=planner-target-details-
|
|
12
|
+
//# sourceMappingURL=planner-target-details-RVPqF2ug.d.mts.map
|
package/dist/{planner-target-details-DkD4PzGm.d.mts.map → planner-target-details-RVPqF2ug.d.mts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner-target-details-
|
|
1
|
+
{"version":3,"file":"planner-target-details-RVPqF2ug.d.mts","names":[],"sources":["../src/core/migrations/planner-target-details.ts"],"mappings":";KAEY,cAAA;AAAA,UAMK,uBAAA;EAAA,SACN,MAAA;EAAA,SACA,UAAA,EAAY,cAAc;EAAA,SAC1B,IAAA;EAAA,SACA,KAAA;AAAA;AAAA,iBASK,kBAAA,CACd,UAAA,EAAY,cAAA,EACZ,IAAA,UACA,KAAA,YACC,uBAAuB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as buildTargetDetails, t as SqlitePlanTargetDetails } from "./planner-target-details-
|
|
1
|
+
import { n as buildTargetDetails, t as SqlitePlanTargetDetails } from "./planner-target-details-RVPqF2ug.mjs";
|
|
2
2
|
export { type SqlitePlanTargetDetails, buildTargetDetails };
|
package/dist/planner.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as SqlitePlanTargetDetails } from "./planner-target-details-
|
|
2
|
-
import { n as TypeScriptRenderableSqliteMigration } from "./planner-produced-sqlite-migration-
|
|
1
|
+
import { t as SqlitePlanTargetDetails } from "./planner-target-details-RVPqF2ug.mjs";
|
|
2
|
+
import { n as TypeScriptRenderableSqliteMigration } from "./planner-produced-sqlite-migration-BwFkd0br.mjs";
|
|
3
3
|
import { MigrationOperationPolicy, SqlMigrationPlanner, SqlPlannerFailureResult } from "@prisma-next/family-sql/control";
|
|
4
4
|
import { MigrationPlanner, MigrationScaffoldContext } from "@prisma-next/framework-components/control";
|
|
5
5
|
import { Contract } from "@prisma-next/contract/types";
|
package/dist/render-ops.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as SqlitePlanTargetDetails } from "./planner-target-details-
|
|
1
|
+
import { t as SqlitePlanTargetDetails } from "./planner-target-details-RVPqF2ug.mjs";
|
|
2
2
|
import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
|
|
3
3
|
import { OpFactoryCall } from "@prisma-next/framework-components/control";
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as SqlitePlanTargetDetails } from "./planner-target-details-
|
|
1
|
+
import { t as SqlitePlanTargetDetails } from "./planner-target-details-RVPqF2ug.mjs";
|
|
2
2
|
import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
|
|
3
3
|
import { ReferentialAction } from "@prisma-next/sql-contract/types";
|
|
4
4
|
|
|
@@ -66,4 +66,4 @@ interface SqliteIndexSpec {
|
|
|
66
66
|
}
|
|
67
67
|
//#endregion
|
|
68
68
|
export { SqliteTableSpec as i, SqliteColumnSpec as n, SqliteIndexSpec as r, Op as t };
|
|
69
|
-
//# sourceMappingURL=shared-
|
|
69
|
+
//# sourceMappingURL=shared-Bw5G0I-c.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-
|
|
1
|
+
{"version":3,"file":"shared-Bw5G0I-c.d.mts","names":[],"sources":["../src/core/migrations/operations/shared.ts"],"mappings":";;;;;KAKY,EAAA,GAAK,yBAAyB,CAAC,uBAAA;;AAAuB;AAsBlE;;;;;;;;;;AAKwC;AAGxC;;;UARiB,gBAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;EAAA,SACA,UAAA;EAAA,SACA,QAAA;EAAA,SACA,6BAAA;AAAA;AAAA,UAGM,oBAAA;EAAA,SACN,OAAO;AAAA;AAAA,UAGD,gBAAA;EAAA,SACN,OAAA;EAAA,SACA,IAAI;AAAA;AAAA,UAGE,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,iBAAiB;EAAA,SAC5B,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,OAAO;AAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as SqlitePlanTargetDetails } from "./planner-target-details-
|
|
1
|
+
import { t as SqlitePlanTargetDetails } from "./planner-target-details-RVPqF2ug.mjs";
|
|
2
2
|
import { Migration } from "@prisma-next/family-sql/migration";
|
|
3
3
|
|
|
4
4
|
//#region src/core/migrations/sqlite-migration.d.ts
|
|
@@ -14,4 +14,4 @@ declare abstract class SqliteMigration extends Migration<SqlitePlanTargetDetails
|
|
|
14
14
|
}
|
|
15
15
|
//#endregion
|
|
16
16
|
export { SqliteMigration as t };
|
|
17
|
-
//# sourceMappingURL=sqlite-migration-
|
|
17
|
+
//# sourceMappingURL=sqlite-migration-D-O3Glz1.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sqlite-migration-
|
|
1
|
+
{"version":3,"file":"sqlite-migration-D-O3Glz1.d.mts","names":[],"sources":["../src/core/migrations/sqlite-migration.ts"],"mappings":";;;;;;AAUA;;;;;uBAAsB,eAAA,SAAwB,SAAY,CAAC,uBAAA;EAAA,SAChD,QAAA;AAAA"}
|
package/package.json
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/target-sqlite",
|
|
3
|
-
"version": "0.12.0-dev.
|
|
3
|
+
"version": "0.12.0-dev.15",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@prisma-next/cli": "0.12.0-dev.
|
|
9
|
-
"@prisma-next/contract": "0.12.0-dev.
|
|
10
|
-
"@prisma-next/errors": "0.12.0-dev.
|
|
11
|
-
"@prisma-next/family-sql": "0.12.0-dev.
|
|
12
|
-
"@prisma-next/framework-components": "0.12.0-dev.
|
|
13
|
-
"@prisma-next/migration-tools": "0.12.0-dev.
|
|
14
|
-
"@prisma-next/sql-contract": "0.12.0-dev.
|
|
15
|
-
"@prisma-next/sql-errors": "0.12.0-dev.
|
|
16
|
-
"@prisma-next/sql-relational-core": "0.12.0-dev.
|
|
17
|
-
"@prisma-next/sql-runtime": "0.12.0-dev.
|
|
18
|
-
"@prisma-next/sql-schema-ir": "0.12.0-dev.
|
|
19
|
-
"@prisma-next/ts-render": "0.12.0-dev.
|
|
20
|
-
"@prisma-next/utils": "0.12.0-dev.
|
|
8
|
+
"@prisma-next/cli": "0.12.0-dev.15",
|
|
9
|
+
"@prisma-next/contract": "0.12.0-dev.15",
|
|
10
|
+
"@prisma-next/errors": "0.12.0-dev.15",
|
|
11
|
+
"@prisma-next/family-sql": "0.12.0-dev.15",
|
|
12
|
+
"@prisma-next/framework-components": "0.12.0-dev.15",
|
|
13
|
+
"@prisma-next/migration-tools": "0.12.0-dev.15",
|
|
14
|
+
"@prisma-next/sql-contract": "0.12.0-dev.15",
|
|
15
|
+
"@prisma-next/sql-errors": "0.12.0-dev.15",
|
|
16
|
+
"@prisma-next/sql-relational-core": "0.12.0-dev.15",
|
|
17
|
+
"@prisma-next/sql-runtime": "0.12.0-dev.15",
|
|
18
|
+
"@prisma-next/sql-schema-ir": "0.12.0-dev.15",
|
|
19
|
+
"@prisma-next/ts-render": "0.12.0-dev.15",
|
|
20
|
+
"@prisma-next/utils": "0.12.0-dev.15",
|
|
21
21
|
"@standard-schema/spec": "1.1.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@prisma-next/driver-sqlite": "0.12.0-dev.
|
|
25
|
-
"@prisma-next/test-utils": "0.12.0-dev.
|
|
26
|
-
"@prisma-next/tsconfig": "0.12.0-dev.
|
|
27
|
-
"@prisma-next/tsdown": "0.12.0-dev.
|
|
24
|
+
"@prisma-next/driver-sqlite": "0.12.0-dev.15",
|
|
25
|
+
"@prisma-next/test-utils": "0.12.0-dev.15",
|
|
26
|
+
"@prisma-next/tsconfig": "0.12.0-dev.15",
|
|
27
|
+
"@prisma-next/tsdown": "0.12.0-dev.15",
|
|
28
28
|
"tsdown": "0.22.0",
|
|
29
29
|
"typescript": "5.9.3",
|
|
30
30
|
"vitest": "4.1.6"
|
|
@@ -45,7 +45,9 @@
|
|
|
45
45
|
"./codec-ids": "./dist/codec-ids.mjs",
|
|
46
46
|
"./codec-types": "./dist/codec-types.mjs",
|
|
47
47
|
"./codecs": "./dist/codecs.mjs",
|
|
48
|
+
"./contract-free": "./dist/contract-free.mjs",
|
|
48
49
|
"./control": "./dist/control.mjs",
|
|
50
|
+
"./ddl": "./dist/ddl.mjs",
|
|
49
51
|
"./default-normalizer": "./dist/default-normalizer.mjs",
|
|
50
52
|
"./migration": "./dist/migration.mjs",
|
|
51
53
|
"./native-type-normalizer": "./dist/native-type-normalizer.mjs",
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { APP_SPACE_ID } from '@prisma-next/framework-components/control';
|
|
2
|
+
import type { DdlNode } from '@prisma-next/sql-relational-core/ast';
|
|
3
|
+
import { col, fn, lit } from '@prisma-next/sql-relational-core/contract-free';
|
|
4
|
+
import { createTable } from './ddl';
|
|
5
|
+
|
|
6
|
+
const markerColumns = [
|
|
7
|
+
col('space', 'TEXT', { notNull: true, primaryKey: true, default: lit(APP_SPACE_ID) }),
|
|
8
|
+
col('core_hash', 'TEXT', { notNull: true }),
|
|
9
|
+
col('profile_hash', 'TEXT', { notNull: true }),
|
|
10
|
+
col('contract_json', 'TEXT'),
|
|
11
|
+
col('canonical_version', 'INTEGER'),
|
|
12
|
+
col('updated_at', 'TEXT', { notNull: true, default: fn("datetime('now')") }),
|
|
13
|
+
col('app_tag', 'TEXT'),
|
|
14
|
+
col('meta', 'TEXT', { notNull: true, default: lit('{}') }),
|
|
15
|
+
col('invariants', 'TEXT', { notNull: true, default: lit('[]') }),
|
|
16
|
+
] as const;
|
|
17
|
+
|
|
18
|
+
const ledgerColumns = [
|
|
19
|
+
col('id', 'INTEGER PRIMARY KEY AUTOINCREMENT'),
|
|
20
|
+
col('created_at', 'TEXT', {
|
|
21
|
+
notNull: true,
|
|
22
|
+
default: fn("strftime('%Y-%m-%dT%H:%M:%fZ','now')"),
|
|
23
|
+
}),
|
|
24
|
+
col('space', 'TEXT', { notNull: true }),
|
|
25
|
+
col('migration_name', 'TEXT', { notNull: true }),
|
|
26
|
+
col('migration_hash', 'TEXT', { notNull: true }),
|
|
27
|
+
col('origin_core_hash', 'TEXT'),
|
|
28
|
+
col('origin_profile_hash', 'TEXT'),
|
|
29
|
+
col('destination_core_hash', 'TEXT', { notNull: true }),
|
|
30
|
+
col('destination_profile_hash', 'TEXT'),
|
|
31
|
+
col('contract_json_before', 'TEXT'),
|
|
32
|
+
col('contract_json_after', 'TEXT'),
|
|
33
|
+
col('operations', 'TEXT', { notNull: true }),
|
|
34
|
+
] as const;
|
|
35
|
+
|
|
36
|
+
const markerTable = createTable({
|
|
37
|
+
table: '_prisma_marker',
|
|
38
|
+
ifNotExists: true,
|
|
39
|
+
columns: markerColumns,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const ledgerTable = createTable({
|
|
43
|
+
table: '_prisma_ledger',
|
|
44
|
+
ifNotExists: true,
|
|
45
|
+
columns: ledgerColumns,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
export function buildSignMarkerBootstrapQueries(): readonly DdlNode[] {
|
|
49
|
+
return [markerTable];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function buildControlTableBootstrapQueries(): readonly DdlNode[] {
|
|
53
|
+
return [markerTable, ledgerTable];
|
|
54
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { DdlColumn } from '@prisma-next/sql-relational-core/ast';
|
|
2
|
+
import { SqliteCreateTable } from '../core/ddl/nodes';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Build a SQLite `CREATE TABLE` query node.
|
|
6
|
+
*
|
|
7
|
+
* Precondition: identifiers (`table`, column names/types) are emitted to SQL
|
|
8
|
+
* verbatim — they are not quoted or escaped, so callers must pass pre-trusted
|
|
9
|
+
* values (e.g. fixed control-plane identifiers). String-literal default values,
|
|
10
|
+
* by contrast, are single-quote-escaped (embedded `'` doubled) by the renderer.
|
|
11
|
+
* Identifier quoting for untrusted identifiers is added when the migration
|
|
12
|
+
* planner adopts this lowering path.
|
|
13
|
+
*/
|
|
14
|
+
export function createTable(options: {
|
|
15
|
+
readonly table: string;
|
|
16
|
+
readonly schema?: string;
|
|
17
|
+
readonly ifNotExists?: boolean;
|
|
18
|
+
readonly columns: readonly DdlColumn[];
|
|
19
|
+
}): SqliteCreateTable {
|
|
20
|
+
return new SqliteCreateTable(options);
|
|
21
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type DdlColumn, DdlNode } from '@prisma-next/sql-relational-core/ast';
|
|
2
|
+
|
|
3
|
+
export interface SqliteDdlVisitor<R> {
|
|
4
|
+
createTable(node: SqliteCreateTable): R;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export abstract class SqliteDdlNode extends DdlNode {
|
|
8
|
+
abstract accept<R>(visitor: SqliteDdlVisitor<R>): R;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function freezeDdlColumns(columns: readonly DdlColumn[]): ReadonlyArray<DdlColumn> {
|
|
12
|
+
return Object.freeze([...columns]);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class SqliteCreateTable extends SqliteDdlNode {
|
|
16
|
+
readonly kind = 'create-table' as const;
|
|
17
|
+
readonly table: string;
|
|
18
|
+
readonly schema: string | undefined;
|
|
19
|
+
readonly ifNotExists: boolean | undefined;
|
|
20
|
+
readonly columns: ReadonlyArray<DdlColumn>;
|
|
21
|
+
|
|
22
|
+
constructor(options: {
|
|
23
|
+
readonly table: string;
|
|
24
|
+
readonly schema?: string;
|
|
25
|
+
readonly ifNotExists?: boolean;
|
|
26
|
+
readonly columns: readonly DdlColumn[];
|
|
27
|
+
}) {
|
|
28
|
+
super();
|
|
29
|
+
this.table = options.table;
|
|
30
|
+
this.schema = options.schema;
|
|
31
|
+
this.ifNotExists = options.ifNotExists;
|
|
32
|
+
this.columns = freezeDdlColumns(options.columns);
|
|
33
|
+
this.freeze();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
override accept<R>(visitor: SqliteDdlVisitor<R>): R {
|
|
37
|
+
return visitor.createTable(this);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type AnySqliteDdlNode = SqliteCreateTable;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ContractMarkerRecord } from '@prisma-next/contract/types';
|
|
1
|
+
import type { Contract, ContractMarkerRecord } from '@prisma-next/contract/types';
|
|
2
2
|
import type {
|
|
3
3
|
MigrationOperationPolicy,
|
|
4
4
|
SqlControlFamilyInstance,
|
|
@@ -19,6 +19,7 @@ import type {
|
|
|
19
19
|
MigrationRunnerResult,
|
|
20
20
|
} from '@prisma-next/framework-components/control';
|
|
21
21
|
import { APP_SPACE_ID } from '@prisma-next/framework-components/control';
|
|
22
|
+
import type { SqlStorage } from '@prisma-next/sql-contract/types';
|
|
22
23
|
import { ifDefined } from '@prisma-next/utils/defined';
|
|
23
24
|
import type { Result } from '@prisma-next/utils/result';
|
|
24
25
|
import { notOk, ok, okVoid } from '@prisma-next/utils/result';
|
|
@@ -28,8 +29,6 @@ import type { SqlitePlanTargetDetails } from './planner-target-details';
|
|
|
28
29
|
import {
|
|
29
30
|
buildLedgerInsertStatement,
|
|
30
31
|
buildWriteMarkerStatements,
|
|
31
|
-
ensureLedgerTableStatement,
|
|
32
|
-
ensureMarkerTableStatement,
|
|
33
32
|
MARKER_TABLE_NAME,
|
|
34
33
|
readMarkerStatement,
|
|
35
34
|
type SqlStatement,
|
|
@@ -70,7 +69,7 @@ class SqliteMigrationRunner implements SqlMigrationRunner<SqlitePlanTargetDetail
|
|
|
70
69
|
const policyCheck = this.enforcePolicyCompatibility(options.policy, options.plan.operations);
|
|
71
70
|
if (!policyCheck.ok) return policyCheck;
|
|
72
71
|
|
|
73
|
-
const ensureResult = await this.ensureControlTables(driver);
|
|
72
|
+
const ensureResult = await this.ensureControlTables(driver, options.destinationContract);
|
|
74
73
|
if (!ensureResult.ok) return ensureResult;
|
|
75
74
|
const existingMarker = await this.readMarker(driver, space);
|
|
76
75
|
|
|
@@ -306,17 +305,16 @@ class SqliteMigrationRunner implements SqlMigrationRunner<SqlitePlanTargetDetail
|
|
|
306
305
|
|
|
307
306
|
private async ensureControlTables(
|
|
308
307
|
driver: SqlMigrationRunnerExecuteOptions<SqlitePlanTargetDetails>['driver'],
|
|
308
|
+
contract: Contract<SqlStorage>,
|
|
309
309
|
): Promise<Result<void, SqlMigrationRunnerFailure>> {
|
|
310
|
-
// Pre-1.0 zero-range guardrail: detect a pre-cleanup single-row
|
|
311
|
-
// marker table (no `space` column) and surface a structured failure
|
|
312
|
-
// rather than silently rebuilding the table into the per-space
|
|
313
|
-
// shape. See `specs/framework-mechanism.spec.md § 2`.
|
|
314
310
|
const legacyDetection = await this.detectLegacyMarkerShape(driver);
|
|
315
311
|
if (!legacyDetection.ok) {
|
|
316
312
|
return legacyDetection;
|
|
317
313
|
}
|
|
318
|
-
|
|
319
|
-
|
|
314
|
+
const lowererContext = { contract };
|
|
315
|
+
for (const query of this.family.bootstrapControlTableQueries()) {
|
|
316
|
+
await this.executeStatement(driver, this.family.lowerAst(query, lowererContext));
|
|
317
|
+
}
|
|
320
318
|
return okVoid();
|
|
321
319
|
}
|
|
322
320
|
|