mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
parent
c23c53bf6f
commit
1356468c38
5 changed files with 93 additions and 5 deletions
14
server/src/migrations/1741027685381-ResetMemories.ts
Normal file
14
server/src/migrations/1741027685381-ResetMemories.ts
Normal 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
|
||||
}
|
||||
}
|
||||
|
|
@ -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 });
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue