botholomew 0.8.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/db/schema.ts +11 -0
package/package.json
CHANGED
package/src/db/schema.ts
CHANGED
|
@@ -45,6 +45,7 @@ export async function migrate(db: DbConnection): Promise<void> {
|
|
|
45
45
|
const applied = new Set(rows.map((row) => row.id));
|
|
46
46
|
|
|
47
47
|
// Run pending migrations in order
|
|
48
|
+
let appliedAny = false;
|
|
48
49
|
for (const migration of loadMigrations()) {
|
|
49
50
|
if (applied.has(migration.id)) continue;
|
|
50
51
|
|
|
@@ -63,5 +64,15 @@ export async function migrate(db: DbConnection): Promise<void> {
|
|
|
63
64
|
migration.id,
|
|
64
65
|
migration.name,
|
|
65
66
|
);
|
|
67
|
+
appliedAny = true;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Flush the WAL so the next open has no schema entries to replay. DuckDB's
|
|
71
|
+
// WAL replay of ALTER TABLE re-binds all column defaults on the target
|
|
72
|
+
// table, and our CREATE TABLE defaults use `current_timestamp::VARCHAR` —
|
|
73
|
+
// which cannot be resolved during replay (no default database attached yet),
|
|
74
|
+
// crashing the process on reopen.
|
|
75
|
+
if (appliedAny) {
|
|
76
|
+
await db.exec("CHECKPOINT");
|
|
66
77
|
}
|
|
67
78
|
}
|