@lunora/d1 1.0.0-alpha.21 → 1.0.0-alpha.23
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/index.mjs
CHANGED
|
@@ -2,6 +2,6 @@ export { exportGlobalRows, importGlobalRows, selectGlobalTables } from './packem
|
|
|
2
2
|
export { D1Client, D1Session } from './packem_shared/D1Client-DA3flo1o.mjs';
|
|
3
3
|
export { createD1CtxDb, readD1CdcChanges, runD1AggregateMigrations, runD1CdcMigration, runD1GlobalTableMigrations, runD1RankMigrations, runD1SearchMigrations, trimD1CdcChanges } from './packem_shared/createD1CtxDb-BMR8J0dT.mjs';
|
|
4
4
|
export { facetGlobalColumn, listGlobalTables, readGlobalTablePage } from './packem_shared/facetGlobalColumn-C6u_WMIY.mjs';
|
|
5
|
-
export { MigrationRunner } from './packem_shared/MigrationRunner-
|
|
5
|
+
export { MigrationRunner } from './packem_shared/MigrationRunner-BQx8HAGh.mjs';
|
|
6
6
|
export { default as sqliteDialect } from './packem_shared/sqliteDialect-DqYnHPuu.mjs';
|
|
7
7
|
export { createSqlCtxDb } from '@lunora/sql-store';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LunoraError } from '@lunora/errors';
|
|
1
2
|
import { sql } from 'drizzle-orm';
|
|
2
3
|
import { D1Client } from './D1Client-DA3flo1o.mjs';
|
|
3
4
|
|
|
@@ -72,7 +73,8 @@ const assertSingleStatement = (migration) => {
|
|
|
72
73
|
continue;
|
|
73
74
|
}
|
|
74
75
|
if (seenStatement && character !== void 0 && !WHITESPACE_RE.test(character)) {
|
|
75
|
-
throw new
|
|
76
|
+
throw new LunoraError(
|
|
77
|
+
"INTERNAL",
|
|
76
78
|
`Migration "${migration.name}" (v${String(migration.version)}) contains more than one SQL statement. Split it into separate migrations — batch() runs them atomically.`
|
|
77
79
|
);
|
|
78
80
|
}
|
|
@@ -119,7 +121,7 @@ class MigrationRunner {
|
|
|
119
121
|
assertSingleStatement(migration);
|
|
120
122
|
const statementText = migration.sql.replace(TRAILING_SEMICOLON_RE, "").trim();
|
|
121
123
|
if (!SHA256_HEX_RE.test(hash)) {
|
|
122
|
-
throw new
|
|
124
|
+
throw new LunoraError("INTERNAL", `migration "${migration.name}" produced a non-hex hash; refusing to inline into SQL`);
|
|
123
125
|
}
|
|
124
126
|
const trackingInsertSql = `INSERT INTO ${TRACKING_TABLE_NAME} (hash, created_at) VALUES ('${hash}', ${String(Date.now())})`;
|
|
125
127
|
const items = [this.client.drizzle.run(sql.raw(statementText)), this.client.drizzle.run(sql.raw(trackingInsertSql))];
|
|
@@ -129,7 +131,7 @@ class MigrationRunner {
|
|
|
129
131
|
const seen = /* @__PURE__ */ new Set();
|
|
130
132
|
for (const m of this.migrations) {
|
|
131
133
|
if (seen.has(m.version)) {
|
|
132
|
-
throw new
|
|
134
|
+
throw new LunoraError("INTERNAL", `Duplicate migration version ${String(m.version)}`);
|
|
133
135
|
}
|
|
134
136
|
seen.add(m.version);
|
|
135
137
|
}
|
|
@@ -139,7 +141,10 @@ class MigrationRunner {
|
|
|
139
141
|
for (const m of this.migrations) {
|
|
140
142
|
const previousVersion = seen.get(m.sql);
|
|
141
143
|
if (previousVersion !== void 0) {
|
|
142
|
-
throw new
|
|
144
|
+
throw new LunoraError(
|
|
145
|
+
"INTERNAL",
|
|
146
|
+
`Migrations ${String(previousVersion)} and ${String(m.version)} have identical SQL — bump the content, not just the version.`
|
|
147
|
+
);
|
|
143
148
|
}
|
|
144
149
|
seen.set(m.sql, m.version);
|
|
145
150
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/d1",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.23",
|
|
4
4
|
"description": "D1 adapter for Lunora .global() tables, wrapping the Sessions API for read-your-writes",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -50,8 +50,9 @@
|
|
|
50
50
|
"access": "public"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@lunora/do": "1.0.0-alpha.
|
|
54
|
-
"@lunora/
|
|
53
|
+
"@lunora/do": "1.0.0-alpha.23",
|
|
54
|
+
"@lunora/errors": "1.0.0-alpha.1",
|
|
55
|
+
"@lunora/sql-store": "1.0.0-alpha.23",
|
|
55
56
|
"drizzle-orm": "^0.45.2"
|
|
56
57
|
},
|
|
57
58
|
"engines": {
|