Skip to content

Commit

Permalink
feat: track upgrade history
Browse files Browse the repository at this point in the history
  • Loading branch information
jrasm91 committed Oct 1, 2024
1 parent d46e502 commit e9d7e2d
Show file tree
Hide file tree
Showing 23 changed files with 406 additions and 19 deletions.
2 changes: 2 additions & 0 deletions mobile/openapi/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions mobile/openapi/lib/api.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions mobile/openapi/lib/api/server_api.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions mobile/openapi/lib/api_client.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

115 changes: 115 additions & 0 deletions mobile/openapi/lib/model/server_version_history_response_dto.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions open-api/immich-openapi-specs.json
Original file line number Diff line number Diff line change
Expand Up @@ -5088,6 +5088,30 @@
]
}
},
"/server/version-history": {
"get": {
"operationId": "getVersionHistory",
"parameters": [],
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"items": {
"$ref": "#/components/schemas/ServerVersionHistoryResponseDto"
},
"type": "array"
}
}
},
"description": ""
}
},
"tags": [
"Server"
]
}
},
"/sessions": {
"delete": {
"operationId": "deleteAllSessions",
Expand Down Expand Up @@ -11042,6 +11066,26 @@
],
"type": "object"
},
"ServerVersionHistoryResponseDto": {
"properties": {
"createdAt": {
"format": "date-time",
"type": "string"
},
"id": {
"type": "string"
},
"version": {
"type": "string"
}
},
"required": [
"createdAt",
"id",
"version"
],
"type": "object"
},
"ServerVersionResponseDto": {
"properties": {
"major": {
Expand Down
13 changes: 13 additions & 0 deletions open-api/typescript-sdk/src/fetch-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,11 @@ export type ServerVersionResponseDto = {
minor: number;
patch: number;
};
export type ServerVersionHistoryResponseDto = {
createdAt: string;
id: string;
version: string;
};
export type SessionResponseDto = {
createdAt: string;
current: boolean;
Expand Down Expand Up @@ -2667,6 +2672,14 @@ export function getServerVersion(opts?: Oazapfts.RequestOpts) {
...opts
}));
}
export function getVersionHistory(opts?: Oazapfts.RequestOpts) {
return oazapfts.ok(oazapfts.fetchJson<{
status: 200;
data: ServerVersionHistoryResponseDto[];
}>("/server/version-history", {
...opts
}));
}
export function deleteAllSessions(opts?: Oazapfts.RequestOpts) {
return oazapfts.ok(oazapfts.fetchText("/sessions", {
...opts,
Expand Down
6 changes: 6 additions & 0 deletions server/src/controllers/server.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
ServerStatsResponseDto,
ServerStorageResponseDto,
ServerThemeDto,
ServerVersionHistoryResponseDto,
ServerVersionResponseDto,
} from 'src/dtos/server.dto';
import { Authenticated } from 'src/middleware/auth.guard';
Expand Down Expand Up @@ -46,6 +47,11 @@ export class ServerController {
return this.versionService.getVersion();
}

@Get('version-history')
getVersionHistory(): Promise<ServerVersionHistoryResponseDto[]> {
return this.versionService.getVersionHistory();
}

@Get('features')
getServerFeatures(): Promise<ServerFeaturesDto> {
return this.service.getFeatures();
Expand Down
6 changes: 6 additions & 0 deletions server/src/dtos/server.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ export class ServerVersionResponseDto {
}
}

export class ServerVersionHistoryResponseDto {
id!: string;
createdAt!: Date;
version!: string;
}

export class UsageByUserDto {
@ApiProperty({ type: 'string' })
userId!: string;
Expand Down
2 changes: 2 additions & 0 deletions server/src/entities/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { SystemMetadataEntity } from 'src/entities/system-metadata.entity';
import { TagEntity } from 'src/entities/tag.entity';
import { UserMetadataEntity } from 'src/entities/user-metadata.entity';
import { UserEntity } from 'src/entities/user.entity';
import { VersionHistoryEntity } from 'src/entities/version-history.entity';

export const entities = [
ActivityEntity,
Expand Down Expand Up @@ -54,4 +55,5 @@ export const entities = [
UserMetadataEntity,
SessionEntity,
LibraryEntity,
VersionHistoryEntity,
];
13 changes: 13 additions & 0 deletions server/src/entities/version-history.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Column, CreateDateColumn, Entity, PrimaryGeneratedColumn } from 'typeorm';

@Entity('version_history')
export class VersionHistoryEntity {
@PrimaryGeneratedColumn('uuid')
id!: string;

@CreateDateColumn({ type: 'timestamptz' })
createdAt!: Date;

@Column()
version!: string;
}
1 change: 1 addition & 0 deletions server/src/interfaces/database.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export enum DatabaseLock {
Migrations = 200,
SystemFileMounts = 300,
StorageTemplateMigration = 420,
VersionHistory = 500,
CLIPDimSize = 512,
LibraryWatch = 1337,
GetSystemConfig = 69,
Expand Down
9 changes: 9 additions & 0 deletions server/src/interfaces/version-history.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { VersionHistoryEntity } from 'src/entities/version-history.entity';

export const IVersionHistoryRepository = 'IVersionHistoryRepository';

export interface IVersionHistoryRepository {
create(version: Omit<VersionHistoryEntity, 'id' | 'createdAt'>): Promise<VersionHistoryEntity>;
getAll(): Promise<VersionHistoryEntity[]>;
getLatest(): Promise<VersionHistoryEntity | null>;
}
14 changes: 14 additions & 0 deletions server/src/migrations/1727797340951-AddVersionHistory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { MigrationInterface, QueryRunner } from "typeorm";

export class AddVersionHistory1727797340951 implements MigrationInterface {
name = 'AddVersionHistory1727797340951'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`CREATE TABLE "version_history" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "version" character varying NOT NULL, CONSTRAINT "PK_5db259cbb09ce82c0d13cfd1b23" PRIMARY KEY ("id"))`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP TABLE "version_history"`);
}

}
Loading

0 comments on commit e9d7e2d

Please sign in to comment.