Skip to content

Commit 2158112

Browse files
committed
Fix system database handling in copyDb and add system database verification test
1 parent 658055f commit 2158112

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

bin/copyDb.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ function openRocksDb(path: string, options: RocksDatabaseOptions & { dupSort?: b
289289
}
290290
let db;
291291
if (options.dupSort) {
292-
db = RocksDatabase.open(new RocksIndexStore(path, options));
292+
db = new RocksIndexStore(path, options).open();
293293
} else {
294294
db = RocksDatabase.open(path, options);
295295
db.encoder.name = options.name;
@@ -307,8 +307,10 @@ export async function migrateOnStart() {
307307
updateConfigValue(CONFIG_PARAMS.STORAGE_MIGRATEONSTART, false);
308308

309309
try {
310-
for (const databaseName in databases) {
311-
if (databaseName === 'system') continue;
310+
let databaseNames = Object.keys(databases);
311+
// system is a dontenum property, so we have to manually add it
312+
if (!databaseNames.includes('system')) databaseNames.push('system');
313+
for (const databaseName of databaseNames) {
312314
if (databaseName.endsWith('-copy')) continue;
313315
let rootStore;
314316
for (const tableName in databases[databaseName]) {

integrationTests/upgrade/4.x-upgrade.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ suite('Start 4.x server and test upgrade', (ctx: ContextWithHarper) => {
8181
CONFIRM_DOWNGRADE: 'yes',
8282
},
8383
harperBinPath: join(legacyPath, 'bin', 'harperdb.js'),
84-
}); // start on v5
84+
}); // start on 4.x again
8585
let response = await sendOperation(ctx.harper, {
8686
operation: 'search_by_conditions',
8787
table: 'test',
@@ -114,6 +114,7 @@ suite('Start 4.x server and test upgrade', (ctx: ContextWithHarper) => {
114114
conditions: [{ attribute: 'id', comparator: 'greater_than', value: 'id-4' }],
115115
});
116116
ok(response.length > 4);
117-
existsSync(join(ctx.harper.dataRootDir, 'database', 'system', 'CURRENT')); // marker for rocksdb
117+
ok(existsSync(join(ctx.harper.dataRootDir, 'database', 'data', 'CURRENT')));
118+
ok(existsSync(join(ctx.harper.dataRootDir, 'database', 'system', 'CURRENT'))); // marker for rocksdb
118119
});
119120
});

0 commit comments

Comments
 (0)