@velvetmonkey/vault-core 2.0.152 → 2.0.153
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/migrations.js +4 -0
- package/dist/sqlite.js +11 -0
- package/package.json +1 -1
package/dist/migrations.js
CHANGED
|
@@ -47,6 +47,10 @@ export function getStateDbPath(vaultPath) {
|
|
|
47
47
|
export function initSchema(db) {
|
|
48
48
|
// Enable WAL mode for better concurrent read performance
|
|
49
49
|
db.pragma('journal_mode = WAL');
|
|
50
|
+
// Incremental auto-vacuum — reclaims freed pages without full VACUUM blocking.
|
|
51
|
+
// Only takes effect on new DBs (before first table). Existing DBs need a one-time
|
|
52
|
+
// VACUUM in openStateDb() to activate.
|
|
53
|
+
db.pragma('auto_vacuum = INCREMENTAL');
|
|
50
54
|
// Enable foreign keys
|
|
51
55
|
db.pragma('foreign_keys = ON');
|
|
52
56
|
// Performance tuning
|
package/dist/sqlite.js
CHANGED
|
@@ -50,6 +50,17 @@ export function openStateDb(vaultPath) {
|
|
|
50
50
|
try {
|
|
51
51
|
db = new Database(dbPath);
|
|
52
52
|
initSchema(db);
|
|
53
|
+
// Enable incremental auto_vacuum on existing databases (one-time cost).
|
|
54
|
+
// New DBs get it from initSchema before tables are created, but existing
|
|
55
|
+
// DBs need a VACUUM to switch the file format.
|
|
56
|
+
if (!isNewDb) {
|
|
57
|
+
const autoVacuum = db.pragma('auto_vacuum', { simple: true });
|
|
58
|
+
if (autoVacuum === 0) {
|
|
59
|
+
console.error('[vault-core] Enabling incremental auto_vacuum (one-time VACUUM)');
|
|
60
|
+
db.pragma('auto_vacuum = INCREMENTAL');
|
|
61
|
+
db.exec('VACUUM');
|
|
62
|
+
}
|
|
63
|
+
}
|
|
53
64
|
// If we just created a fresh DB but backup files exist, salvage from them
|
|
54
65
|
if (isNewDb) {
|
|
55
66
|
attemptSalvage(db, dbPath);
|
package/package.json
CHANGED