1
0
mirror of https://github.com/immich-app/immich.git synced 2024-11-24 08:52:28 +02:00
immich/server
maxer137 6835d4519a
feat(server): add postgres major version check (#6213)
* 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.

* Replaced assertion with lesser than comparison
As requested by @zackpollard

* Changed the comparison to use the minPostgresVersion variable.
If we define one we might as well use it. makes changing the versioning later easier

* Added two new tests, modified two existing tests

`should return if minimum supported PostgreSQL and vectors version are installed`:
Check if init returns properly and that getPostgresVersion is called twice

`should thrown an error if PostgreSQL version is below minimum supported version`:
Checks if the init function correctly returns an error

`should suggest image with postgres ${major} if database is ${major}`:
Modified to set MockResolvedValue instead of MockResolvedValueOnce. With the new check we get the PostgreSQL version twice. So it needs to be set during the entire test.

`should not suggest image if postgres version is not in 14, 15 or 16`:
Modified the bounds to [14, 18]. Because values below 14 now will not get called.
Also Modified to call `getPostgresVersion.MockResolvedValueOnce` for twice, because it gets called twice.

* Fixed two mistakes in the jest functions from previous commit #2abcb60

`should thrown an error if PostgreSQL version is below minimum supported version`:
The regex function I wrote mistakingly used the negate function which check that the error *did not* contain the phrase "PostgreSQL". Which is the opposite

`should not suggest image if postgres version is not in 14, 15 or 16`:
confused bounds for a normal javascript array. Changed the test to only check for values above 16. As values below 14 will get thrown out by test `should return if minimum supported PostgreSQL and vectors version are installed`

I apologise for the mistakes in my previous commit.

* Format fix

---------

Co-authored-by: max <wak@vanling.net>
2024-01-06 19:24:09 -05:00
..
bin chore(server): faster shutdown (#5577) 2023-12-08 21:58:07 -05:00
openapi-generator fix(mobile): map markers not loading with int coordinates (#3957) 2023-09-05 06:08:43 +07:00
resources feat: postgres reverse geocoding (#5301) 2023-11-25 18:53:30 +00:00
src feat(server): add postgres major version check (#6213) 2024-01-06 19:24:09 -05:00
test feat(server): in upload folder, split the files into folders based on the first four of the files uuid (#6175) 2024-01-04 14:45:16 -06:00
.eslintrc.js chore(server): curly braces (#5361) 2023-11-28 15:09:20 -05:00
.gitignore feat(web): re-add open graph tags for public share links (#5635) 2023-12-11 13:37:47 -06:00
.prettierignore
.prettierrc fix(server): lint import order (#3974) 2023-09-04 21:45:59 +02:00
Dockerfile feat(server): add rw2 support (#6231) 2024-01-06 23:58:04 +00:00
immich-openapi-specs.json feat(web): onboarding (#6066) 2024-01-04 05:28:32 +00:00
nest-cli.json refactor(server)*: tsconfigs (#2689) 2023-06-08 10:01:07 -05:00
openapitools.json chore(server): update openapi (#2205) 2023-04-08 21:26:09 -05:00
package-lock.json fix(deps): update server (#6119) 2024-01-03 17:41:30 -05:00
package.json fix(deps): update dependency @nestjs/schedule to v4 (#5348) 2024-01-01 22:25:25 -05:00
start-microservices.sh fix: shebangs (#3643) 2023-08-16 22:50:01 -05:00
start-server.sh fix: shebangs (#3643) 2023-08-16 22:50:01 -05:00
start.sh fix(server): immich command (#5408) 2023-11-30 14:59:47 -06:00
tsconfig.build.json fix: exclude e2e format (#3250) 2023-07-13 21:41:16 -05:00
tsconfig.json fix(server): better fix for the OAuth Discovery errors (#4695) 2023-10-30 13:22:30 -04:00