mirror of
https://github.com/immich-app/immich.git
synced 2026-03-04 09:57:33 +03:00
feat: track upgrade history (#13097)
This commit is contained in:
25
server/src/repositories/version-history.repository.ts
Normal file
25
server/src/repositories/version-history.repository.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { VersionHistoryEntity } from 'src/entities/version-history.entity';
|
||||
import { IVersionHistoryRepository } from 'src/interfaces/version-history.interface';
|
||||
import { Instrumentation } from 'src/utils/instrumentation';
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
@Instrumentation()
|
||||
@Injectable()
|
||||
export class VersionHistoryRepository implements IVersionHistoryRepository {
|
||||
constructor(@InjectRepository(VersionHistoryEntity) private repository: Repository<VersionHistoryEntity>) {}
|
||||
|
||||
async getAll(): Promise<VersionHistoryEntity[]> {
|
||||
return this.repository.find({ order: { createdAt: 'DESC' } });
|
||||
}
|
||||
|
||||
async getLatest(): Promise<VersionHistoryEntity | null> {
|
||||
const results = await this.repository.find({ order: { createdAt: 'DESC' }, take: 1 });
|
||||
return results[0] || null;
|
||||
}
|
||||
|
||||
create(version: Omit<VersionHistoryEntity, 'id' | 'createdAt'>): Promise<VersionHistoryEntity> {
|
||||
return this.repository.save(version);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user