wayfind 2.0.37 → 2.0.38
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/bin/storage/sqlite-backend.js +20 -15
- package/package.json +1 -1
|
@@ -155,6 +155,26 @@ class SqliteBackend {
|
|
|
155
155
|
fs.mkdirSync(this.storePath, { recursive: true });
|
|
156
156
|
this.db = new Database(this.dbPath);
|
|
157
157
|
this.db.pragma('journal_mode = WAL');
|
|
158
|
+
|
|
159
|
+
// Migrate existing databases BEFORE running full schema (which creates
|
|
160
|
+
// indexes on columns that may not exist yet in pre-v2.0.29 databases).
|
|
161
|
+
const tables = this.db.prepare("SELECT name FROM sqlite_master WHERE type='table'").all().map(r => r.name);
|
|
162
|
+
if (tables.includes('decisions')) {
|
|
163
|
+
const cols = this.db.prepare('PRAGMA table_info(decisions)').all().map(c => c.name);
|
|
164
|
+
if (!cols.includes('quality_score')) {
|
|
165
|
+
this.db.exec('ALTER TABLE decisions ADD COLUMN quality_score INTEGER DEFAULT 0');
|
|
166
|
+
}
|
|
167
|
+
if (!cols.includes('distill_tier')) {
|
|
168
|
+
this.db.exec("ALTER TABLE decisions ADD COLUMN distill_tier TEXT DEFAULT 'raw'");
|
|
169
|
+
}
|
|
170
|
+
if (!cols.includes('distilled_from')) {
|
|
171
|
+
this.db.exec('ALTER TABLE decisions ADD COLUMN distilled_from TEXT DEFAULT NULL');
|
|
172
|
+
}
|
|
173
|
+
if (!cols.includes('distilled_at')) {
|
|
174
|
+
this.db.exec('ALTER TABLE decisions ADD COLUMN distilled_at INTEGER DEFAULT NULL');
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
158
178
|
this.db.exec(SCHEMA_SQL);
|
|
159
179
|
fs.chmodSync(this.dbPath, 0o600);
|
|
160
180
|
|
|
@@ -162,21 +182,6 @@ class SqliteBackend {
|
|
|
162
182
|
if (!existing) {
|
|
163
183
|
this.db.prepare('INSERT INTO metadata (key, value) VALUES (?, ?)').run('schema_version', SCHEMA_VERSION);
|
|
164
184
|
}
|
|
165
|
-
|
|
166
|
-
// Migrate existing databases: add new columns if they don't exist
|
|
167
|
-
const cols = this.db.prepare('PRAGMA table_info(decisions)').all().map(c => c.name);
|
|
168
|
-
if (!cols.includes('quality_score')) {
|
|
169
|
-
this.db.exec('ALTER TABLE decisions ADD COLUMN quality_score INTEGER DEFAULT 0');
|
|
170
|
-
}
|
|
171
|
-
if (!cols.includes('distill_tier')) {
|
|
172
|
-
this.db.exec('ALTER TABLE decisions ADD COLUMN distill_tier TEXT DEFAULT \'raw\'');
|
|
173
|
-
}
|
|
174
|
-
if (!cols.includes('distilled_from')) {
|
|
175
|
-
this.db.exec('ALTER TABLE decisions ADD COLUMN distilled_from TEXT DEFAULT NULL');
|
|
176
|
-
}
|
|
177
|
-
if (!cols.includes('distilled_at')) {
|
|
178
|
-
this.db.exec('ALTER TABLE decisions ADD COLUMN distilled_at INTEGER DEFAULT NULL');
|
|
179
|
-
}
|
|
180
185
|
}
|
|
181
186
|
|
|
182
187
|
close() {
|
package/package.json
CHANGED