u
This commit is contained in:
@@ -108,5 +108,26 @@ test('schema migrations & posterminal version 2', async (t) => {
|
||||
assert.ok(cols.includes('enabled'), 'enabled column should be restored');
|
||||
assert.ok(cols.includes('clientversion'), 'clientversion column should be restored');
|
||||
});
|
||||
|
||||
await t.test('refuses to initialize if db schema version is higher than highest upgrade version', async () => {
|
||||
// Manually set database meta version to a future version (e.g. 99)
|
||||
provider.db.prepare(`UPDATE meta SET value = '99' WHERE "key" = 'version'`).run();
|
||||
const futureVersion = await provider.getSchemaVersion();
|
||||
assert.equal(futureVersion, 99);
|
||||
|
||||
await assert.rejects(
|
||||
async () => {
|
||||
await provider.initialize();
|
||||
},
|
||||
(err) => {
|
||||
assert.match(err.message, /Refusing to start: database schema version \(99\) is higher than the highest version in the upgrade folder \(2\)/);
|
||||
return true;
|
||||
},
|
||||
'Should throw and refuse to initialize'
|
||||
);
|
||||
|
||||
// Restore to version 2 so cleanup/subsequent steps stay consistent
|
||||
provider.db.prepare(`UPDATE meta SET value = '2' WHERE "key" = 'version'`).run();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user