BUG(Server): Immich migration to pgvecto-rs:pg14-v0.2.0 fails when using creative sql database name #2202

Closed
opened 2026-02-05 05:38:20 +03:00 by OVERLORD · 5 comments
Owner

Originally created by @raldone01 on GitHub (Feb 21, 2024).

The bug

My psql database name is: 2Izuz2a_X)F}~8H<86*R~L_r`sx<<Yf.

The following migration failed:

Node.js v20.11.0
/usr/src/app/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:219
            throw new QueryFailedError_1.QueryFailedError(query, parameters, err);
                  ^

QueryFailedError: syntax error at or near "2"
    at PostgresQueryRunner.query (/usr/src/app/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:219:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async AddVectorsToSearchPath1707000751533.up (/usr/src/app/dist/infra/migrations/1707000751533-AddVectorsToSearchPath.js:8:9)
    at async MigrationExecutor.executePendingMigrations (/usr/src/app/node_modules/typeorm/migration/MigrationExecutor.js:225:17)
    at async DataSource.runMigrations (/usr/src/app/node_modules/typeorm/data-source/DataSource.js:265:35)
    at async DatabaseRepository.runMigrations (/usr/src/app/dist/infra/repositories/database.repository.js:177:9)
    at async /usr/src/app/dist/domain/database/database.service.js:52:13
    at async /usr/src/app/dist/infra/repositories/database.repository.js:185:23 {
  query: 'ALTER DATABASE 2Izuz2a_X)F}~8H<86*R~L_r`sx<<Yf. SET search_path TO "$user", public, vectors',
  parameters: undefined,
  driverError: error: syntax error at or near "2"
      at /usr/src/app/node_modules/pg/lib/client.js:526:17
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async PostgresQueryRunner.query (/usr/src/app/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:184:25)
      at async AddVectorsToSearchPath1707000751533.up (/usr/src/app/dist/infra/migrations/1707000751533-AddVectorsToSearchPath.js:8:9)
      at async MigrationExecutor.executePendingMigrations (/usr/src/app/node_modules/typeorm/migration/MigrationExecutor.js:225:17)
      at async DataSource.runMigrations (/usr/src/app/node_modules/typeorm/data-source/DataSource.js:265:35)
      at async DatabaseRepository.runMigrations (/usr/src/app/dist/infra/repositories/database.repository.js:177:9)
      at async /usr/src/app/dist/domain/database/database.service.js:52:13
      at async /usr/src/app/dist/infra/repositories/database.repository.js:185:23 {
    length: 90,
    severity: 'ERROR',
    code: '42601',
    detail: undefined,
    hint: undefined,
    position: '16',
    internalPosition: undefined,
    internalQuery: undefined,
    where: undefined,
    schema: undefined,
    table: undefined,
    column: undefined,
    dataType: undefined,
    constraint: undefined,
    file: 'scan.l',
    line: '1176',
    routine: 'scanner_yyerror'
  },
  length: 90,
  severity: 'ERROR',
  code: '42601',
  detail: undefined,
  hint: undefined,
  position: '16',
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'scan.l',
  line: '1176',
  routine: 'scanner_yyerror'
}

Node.js v20.11.0

I will change my db to use a more reasonable name.

The OS that Immich Server is running on

Arch docker

Version of Immich Server

ghcr.io/immich-app/immich-server:release

Version of Immich Mobile App

NaN

Platform with the issue

  • Server
  • Web
  • Mobile

Your docker-compose.yml content

The usual.

Your .env content

The usual.

Reproduction steps

1. Upgrade sql from 0.1.x to 0.2.0
2. The migration fails after the prompted db restart.

Additional information

No response

Originally created by @raldone01 on GitHub (Feb 21, 2024). ### The bug My psql database name is: ```2Izuz2a_X)F}~8H<86*R~L_r`sx<<Yf.``` The following migration failed: ``` Node.js v20.11.0 /usr/src/app/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:219 throw new QueryFailedError_1.QueryFailedError(query, parameters, err); ^ QueryFailedError: syntax error at or near "2" at PostgresQueryRunner.query (/usr/src/app/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:219:19) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async AddVectorsToSearchPath1707000751533.up (/usr/src/app/dist/infra/migrations/1707000751533-AddVectorsToSearchPath.js:8:9) at async MigrationExecutor.executePendingMigrations (/usr/src/app/node_modules/typeorm/migration/MigrationExecutor.js:225:17) at async DataSource.runMigrations (/usr/src/app/node_modules/typeorm/data-source/DataSource.js:265:35) at async DatabaseRepository.runMigrations (/usr/src/app/dist/infra/repositories/database.repository.js:177:9) at async /usr/src/app/dist/domain/database/database.service.js:52:13 at async /usr/src/app/dist/infra/repositories/database.repository.js:185:23 { query: 'ALTER DATABASE 2Izuz2a_X)F}~8H<86*R~L_r`sx<<Yf. SET search_path TO "$user", public, vectors', parameters: undefined, driverError: error: syntax error at or near "2" at /usr/src/app/node_modules/pg/lib/client.js:526:17 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async PostgresQueryRunner.query (/usr/src/app/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:184:25) at async AddVectorsToSearchPath1707000751533.up (/usr/src/app/dist/infra/migrations/1707000751533-AddVectorsToSearchPath.js:8:9) at async MigrationExecutor.executePendingMigrations (/usr/src/app/node_modules/typeorm/migration/MigrationExecutor.js:225:17) at async DataSource.runMigrations (/usr/src/app/node_modules/typeorm/data-source/DataSource.js:265:35) at async DatabaseRepository.runMigrations (/usr/src/app/dist/infra/repositories/database.repository.js:177:9) at async /usr/src/app/dist/domain/database/database.service.js:52:13 at async /usr/src/app/dist/infra/repositories/database.repository.js:185:23 { length: 90, severity: 'ERROR', code: '42601', detail: undefined, hint: undefined, position: '16', internalPosition: undefined, internalQuery: undefined, where: undefined, schema: undefined, table: undefined, column: undefined, dataType: undefined, constraint: undefined, file: 'scan.l', line: '1176', routine: 'scanner_yyerror' }, length: 90, severity: 'ERROR', code: '42601', detail: undefined, hint: undefined, position: '16', internalPosition: undefined, internalQuery: undefined, where: undefined, schema: undefined, table: undefined, column: undefined, dataType: undefined, constraint: undefined, file: 'scan.l', line: '1176', routine: 'scanner_yyerror' } Node.js v20.11.0 ``` I will change my db to use a more *reasonable* name. ### The OS that Immich Server is running on Arch docker ### Version of Immich Server ghcr.io/immich-app/immich-server:release ### Version of Immich Mobile App NaN ### Platform with the issue - [X] Server - [ ] Web - [ ] Mobile ### Your docker-compose.yml content ```YAML The usual. ``` ### Your .env content ```Shell The usual. ``` ### Reproduction steps ```bash 1. Upgrade sql from 0.1.x to 0.2.0 2. The migration fails after the prompted db restart. ``` ### Additional information _No response_
Author
Owner

@zackpollard commented on GitHub (Feb 21, 2024):

That database name makes me want to cry, however it is a fair point as even a single - would likely cause this problem. We should quote the database name in the migrations.

@zackpollard commented on GitHub (Feb 21, 2024): That database name makes me want to cry, however it is a fair point as even a single - would likely cause this problem. We should quote the database name in the migrations.
Author
Owner

@raldone01 commented on GitHub (Feb 21, 2024):

So I don't have to change the name? 🙃

Fun fact: In school I once create a database where all column names and user names, etc were only emojis.
EVEN the database NAME very fun connecting to .

@raldone01 commented on GitHub (Feb 21, 2024): So I don't have to change the name? 🙃 Fun fact: In school I once create a database where all column names and user names, etc were only emojis. EVEN the database NAME very fun connecting to ⛄.
Author
Owner

@zackpollard commented on GitHub (Feb 21, 2024):

So I don't have to change the name? 🙃

I would prefer you did, for all of our sanity...

@zackpollard commented on GitHub (Feb 21, 2024): > So I don't have to change the name? 🙃 I would prefer you did, for all of our sanity...
Author
Owner

@raldone01 commented on GitHub (Feb 21, 2024):

Take care when using including the username in queries:

❯ cat secrets/immich_db_user_name.txt 
HZ,s(x2{+fqDJ%nD{Q#Sgb`d,8-iQ`(E

Love your software by the way. Keep it up. Consider adding OCR soonish.

@raldone01 commented on GitHub (Feb 21, 2024): Take care when using including the username in queries: ``` ❯ cat secrets/immich_db_user_name.txt HZ,s(x2{+fqDJ%nD{Q#Sgb`d,8-iQ`(E ``` Love your software by the way. Keep it up. ~Consider adding OCR soonish.~
Author
Owner

@raldone01 commented on GitHub (Feb 21, 2024):

The migration succeeded and my instance is up again.
Thanks for the crazy fast fix. You are "🔥🔥🔥" (my new database name).

@raldone01 commented on GitHub (Feb 21, 2024): The migration succeeded and my instance is up again. Thanks for the crazy fast fix. You are "🔥🔥🔥" (my new database name).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#2202