mirror of
https://github.com/immich-app/immich
synced 2026-08-22 13:13:05 +00:00
feat(server): Throw error when PostgreSQL version is not within the supported versions
The pgvecto.rs extension, though not distributed, can be built for PostgreSQL 12 and 13. An installation of PostgreSQL 12 with the pgvecto.rs extensions installed will not be caught by immich. This causes immich to attempt to run the database migrations without having a proper environment. With assertPostgresql the server will throw an error if the PostgreSQL version is not within the supported range.
This commit is contained in:
parent
a233e176e5
commit
6f4362252b
1 changed files with 11 additions and 0 deletions
|
|
@ -7,12 +7,14 @@ import { DatabaseExtension, IDatabaseRepository } from '../repositories';
|
|||
@Injectable()
|
||||
export class DatabaseService {
|
||||
private logger = new ImmichLogger(DatabaseService.name);
|
||||
minPostgresVersion = 14;
|
||||
minVectorsVersion = new Version(0, 1, 1);
|
||||
maxVectorsVersion = new Version(0, 1, 11);
|
||||
|
||||
constructor(@Inject(IDatabaseRepository) private databaseRepository: IDatabaseRepository) {}
|
||||
|
||||
async init() {
|
||||
await this.assertPostgresql();
|
||||
await this.createVectors();
|
||||
await this.assertVectors();
|
||||
await this.databaseRepository.runMigrations();
|
||||
|
|
@ -66,4 +68,13 @@ export class DatabaseService {
|
|||
}
|
||||
return `tensorchord/pgvecto-rs:pg${major}-v${this.maxVectorsVersion}`;
|
||||
}
|
||||
|
||||
private async assertPostgresql() {
|
||||
const { major } = await this.databaseRepository.getPostgresVersion();
|
||||
if (![14, 15, 16].includes(major)) {
|
||||
throw new Error(`
|
||||
The PostgreSQL version is ${major}, which is older than the minimum supported version ${this.minPostgresVersion}.
|
||||
Please upgrade to this version or later.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue