durable-db 0.1.9 → 0.1.10
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/db/index.js +6 -1
- package/package.json +1 -1
package/dist/db/index.js
CHANGED
|
@@ -274,7 +274,7 @@ var SqliteDurableObject = class extends DurableObject {
|
|
|
274
274
|
for (const { name, chunkIndex, statements } of pending) {
|
|
275
275
|
let currentIndex = -1;
|
|
276
276
|
let currentStatement = null;
|
|
277
|
-
|
|
277
|
+
const applyChunk = () => {
|
|
278
278
|
for (let i = 0; i < statements.length; i++) {
|
|
279
279
|
const statement = statements[i];
|
|
280
280
|
if (!statement.trim()) continue;
|
|
@@ -285,6 +285,11 @@ var SqliteDurableObject = class extends DurableObject {
|
|
|
285
285
|
currentIndex = -1;
|
|
286
286
|
currentStatement = null;
|
|
287
287
|
this.sql.exec("INSERT INTO __migrations (name, chunk_index, applied_at) VALUES (?, ?, ?)", name, chunkIndex, (/* @__PURE__ */ new Date()).toISOString());
|
|
288
|
+
};
|
|
289
|
+
try {
|
|
290
|
+
const storage = this.ctx.storage;
|
|
291
|
+
if (typeof storage.transactionSync === "function") storage.transactionSync(applyChunk);
|
|
292
|
+
else applyChunk();
|
|
288
293
|
debugMigrations("Migration chunk applied: %s[%d]", name, chunkIndex);
|
|
289
294
|
} catch (error) {
|
|
290
295
|
const location = currentStatement !== null ? ` stmt ${currentIndex}: ${formatStatementForLog(currentStatement)}` : " (while recording chunk as applied)";
|