feat(FN-5188): complete Step 2 — persist bootstrappedAt
Fusion-Task-Id: FN-5188 Fusion-Task-Lineage: 6d238ff1-2d69-44e7-8694-ec19e412f8ef
This commit is contained in:
committed by
gsxdsm
parent
1565b6dc52
commit
2c75ac6227
@@ -310,6 +310,21 @@ describe("Database", () => {
|
||||
expect(ts).toBeLessThanOrEqual(Date.now());
|
||||
});
|
||||
|
||||
it("seeds bootstrappedAt and preserves it across reopen", () => {
|
||||
const bootstrappedAt = db.getBootstrappedAt();
|
||||
expect(bootstrappedAt).toBeTypeOf("number");
|
||||
expect(bootstrappedAt).toBeGreaterThan(0);
|
||||
expect(bootstrappedAt).toBeLessThanOrEqual(Date.now());
|
||||
|
||||
const reopened = new Database(tempDir);
|
||||
reopened.init();
|
||||
try {
|
||||
expect(reopened.getBootstrappedAt()).toBe(bootstrappedAt);
|
||||
} finally {
|
||||
reopened.close();
|
||||
}
|
||||
});
|
||||
|
||||
it("seeds config row with all required fields", () => {
|
||||
const row = db.prepare("SELECT * FROM config WHERE id = 1").get() as any;
|
||||
expect(row).toBeDefined();
|
||||
|
||||
@@ -1520,6 +1520,9 @@ export class Database {
|
||||
this.db.exec(
|
||||
`INSERT OR IGNORE INTO __meta (key, value) VALUES ('lastModified', '${Date.now()}')`,
|
||||
);
|
||||
this.db.exec(
|
||||
`INSERT OR IGNORE INTO __meta (key, value) VALUES ('bootstrappedAt', '${Date.now()}')`,
|
||||
);
|
||||
|
||||
// Run schema migrations
|
||||
this.migrate();
|
||||
@@ -3847,6 +3850,15 @@ export class Database {
|
||||
);
|
||||
}
|
||||
|
||||
getBootstrappedAt(): number | null {
|
||||
const value = this.getMetaValue("bootstrappedAt");
|
||||
if (!value) {
|
||||
return null;
|
||||
}
|
||||
const parsed = parseInt(value, 10);
|
||||
return Number.isFinite(parsed) ? parsed : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the schema version number.
|
||||
*/
|
||||
|
||||
@@ -8805,6 +8805,10 @@ ${stepsSection}`;
|
||||
return this.db;
|
||||
}
|
||||
|
||||
getBootstrappedAt(): number | null {
|
||||
return this.db.getBootstrappedAt();
|
||||
}
|
||||
|
||||
async getSecretsStore(): Promise<SecretsStore> {
|
||||
if (this.secretsStore) {
|
||||
return this.secretsStore;
|
||||
|
||||
Reference in New Issue
Block a user