mirror of
https://github.com/immich-app/immich.git
synced 2024-11-15 18:08:48 -07:00
fix(server): do not try to upgrade to an older version (#10903)
This commit is contained in:
parent
e1f25b44d2
commit
6c49a4ba34
@ -150,6 +150,7 @@ describe(DatabaseService.name, () => {
|
||||
for (const version of ['0.2.1', '0.2.0', '0.2.9']) {
|
||||
it(`should update the pgvecto.rs extension to ${version}`, async () => {
|
||||
databaseMock.getAvailableExtensionVersion.mockResolvedValue(version);
|
||||
databaseMock.getExtensionVersion.mockResolvedValueOnce(void 0);
|
||||
databaseMock.getExtensionVersion.mockResolvedValue(version);
|
||||
|
||||
await expect(sut.onBootstrapEvent()).resolves.toBeUndefined();
|
||||
@ -166,6 +167,7 @@ describe(DatabaseService.name, () => {
|
||||
it(`should update the pgvectors extension to ${version}`, async () => {
|
||||
process.env.DB_VECTOR_EXTENSION = 'pgvector';
|
||||
databaseMock.getAvailableExtensionVersion.mockResolvedValue(version);
|
||||
databaseMock.getExtensionVersion.mockResolvedValueOnce(void 0);
|
||||
databaseMock.getExtensionVersion.mockResolvedValue(version);
|
||||
|
||||
await expect(sut.onBootstrapEvent()).resolves.toBeUndefined();
|
||||
@ -190,10 +192,10 @@ describe(DatabaseService.name, () => {
|
||||
});
|
||||
}
|
||||
|
||||
for (const version of ['0.4.0', '1.0.0']) {
|
||||
for (const version of ['0.4.0', '0.7.1', '0.7.2', '1.0.0']) {
|
||||
it(`should not upgrade pgvector to ${version}`, async () => {
|
||||
process.env.DB_VECTOR_EXTENSION = 'pgvector';
|
||||
databaseMock.getExtensionVersion.mockResolvedValue('0.5.0');
|
||||
databaseMock.getExtensionVersion.mockResolvedValue('0.7.2');
|
||||
databaseMock.getAvailableExtensionVersion.mockResolvedValue(version);
|
||||
|
||||
await expect(sut.onBootstrapEvent()).resolves.toBeUndefined();
|
||||
|
@ -98,8 +98,10 @@ export class DatabaseService implements OnEvents {
|
||||
throw error;
|
||||
}
|
||||
|
||||
const initialVersion = await this.databaseRepository.getExtensionVersion(extension);
|
||||
const availableVersion = await this.databaseRepository.getAvailableExtensionVersion(extension);
|
||||
if (availableVersion && semver.satisfies(availableVersion, extensionRange)) {
|
||||
const isAvailable = availableVersion && semver.satisfies(availableVersion, extensionRange);
|
||||
if (isAvailable && (!initialVersion || semver.gt(availableVersion, initialVersion))) {
|
||||
try {
|
||||
this.logger.log(`Updating ${name} extension to ${availableVersion}`);
|
||||
const { restartRequired } = await this.databaseRepository.updateVectorExtension(extension, availableVersion);
|
||||
|
Loading…
Reference in New Issue
Block a user