fix: reset/regenerate memories (#16548)

fix: reset memories
This commit is contained in:
Jason Rasmussen 2025-03-03 23:48:05 -05:00 committed by GitHub
parent c23c53bf6f
commit 1356468c38
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 93 additions and 5 deletions

View file

@ -0,0 +1,14 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
export class ResetMemories1741027685381 implements MigrationInterface {
name = 'ResetMemories1741027685381';
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DELETE FROM "memories"`);
await queryRunner.query(`DELETE FROM "system_metadata" WHERE "key" = 'memories-state'`);
}
public async down(): Promise<void> {
// nothing to do
}
}

View file

@ -25,11 +25,24 @@ export class VersionService extends BaseService {
await this.handleVersionCheck();
await this.databaseRepository.withLock(DatabaseLock.VersionHistory, async () => {
const latest = await this.versionRepository.getLatest();
const previous = await this.versionRepository.getLatest();
const current = serverVersion.toString();
if (!latest || latest.version !== current) {
this.logger.log(`Version has changed, adding ${current} to history`);
if (!previous) {
await this.versionRepository.create({ version: current });
return;
}
if (previous.version !== current) {
const previousVersion = new SemVer(previous.version);
this.logger.log(`Adding ${current} to upgrade history`);
await this.versionRepository.create({ version: current });
const needsNewMemories = semver.lt(previousVersion, '1.129.0');
if (needsNewMemories) {
await this.jobRepository.queue({ name: JobName.MEMORIES_CREATE });
}
}
});
}