Skip to content

Commit e34ce6e

Browse files
committed
fix: Prevent re-adding existing columns during schema migration and update bplist-parser dependency.
1 parent f39d916 commit e34ce6e

File tree

3 files changed

+12
-115
lines changed

3 files changed

+12
-115
lines changed

bun.lock

Lines changed: 3 additions & 109 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/common/src/local-first/Db.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,12 @@ const startDbWorker =
229229
readonly id: Id;
230230
readonly processedAt: Millis;
231231
}> = [];
232-
const processedRequestIdTtl: Millis = 5 * 60 * 1000;
232+
const processedRequestIdTtl = 5 * 60 * 1000;
233233

234234
const { port } = run.deps;
235235

236236
port.onMessage = ({ callbackId, request, evoluPortId }) => {
237-
const now = clock.get();
237+
const now = run.deps.time.now();
238238

239239
// Evict expired callback IDs based on time-to-live.
240240
while (processedRequestIdsOrder.length > 0) {
@@ -493,9 +493,11 @@ const validateColumnValue =
493493
);
494494
};
495495

496-
const systemColumnsWithoutOwnerId = systemColumns.difference(
497-
new Set(["ownerId"]),
498-
);
496+
const systemColumnsWithoutOwnerId: ReadonlySet<string> = (() => {
497+
const columns = new Set(systemColumns);
498+
columns.delete("ownerId");
499+
return columns;
500+
})();
499501

500502
const applyColumnChange =
501503
(deps: SqliteDep) =>

packages/common/src/local-first/Schema.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,8 @@ export const ensureDbSchema =
513513
if (!currentColumns) {
514514
queries.push(createAppTable(tableName, newColumns));
515515
} else {
516-
for (const newColumn of newColumns.difference(currentColumns)) {
516+
for (const newColumn of newColumns) {
517+
if (currentColumns.has(newColumn)) continue;
517518
queries.push(sql`
518519
alter table ${sql.identifier(tableName)}
519520
add column ${sql.identifier(newColumn)} any;

0 commit comments

Comments
 (0)