immich-app / immich

High performance self-hosted photo and video management solution.
https://immich.app
GNU Affero General Public License v3.0
45.2k stars 2.19k forks source link

Migrations fail for upgrade to 1.94.1 #6862

Closed agross closed 7 months ago

agross commented 7 months ago

The bug

After upgrading from (I believe 1.92.2) to 1.94.1 this was logged by the "server" container when then exited.

Migration "AddAutoStackId1703035138085" failed, error: column "autoStackId" of relation "exif" already exists
/usr/src/app/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:219
            throw new QueryFailedError_1.QueryFailedError(query, parameters, err);
                  ^

QueryFailedError: column "autoStackId" of relation "exif" already exists
    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 AddAutoStackId1703035138085.up (/usr/src/app/dist/infra/migrations/1703035138085-AddAutoStackId.js:9: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:263:35)
    at async DatabaseRepository.runMigrations (/usr/src/app/dist/infra/repositories/database.repository.js:42:9)
    at async DatabaseService.init (/usr/src/app/dist/domain/database/database.service.js:33:9)
    at async AppService.init (/usr/src/app/dist/immich/app.service.js:56:9)
    at async AppModule.onModuleInit (/usr/src/app/dist/immich/app.module.js:32:9)
    at async callModuleInitHook (/usr/src/app/node_modules/@nestjs/core/hooks/on-module-init.hook.js:51:9) {
  query: 'ALTER TABLE "exif" ADD "autoStackId" character varying',
  parameters: undefined,
  driverError: error: column "autoStackId" of relation "exif" already exists
      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 AddAutoStackId1703035138085.up (/usr/src/app/dist/infra/migrations/1703035138085-AddAutoStackId.js:9: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:263:35)
      at async DatabaseRepository.runMigrations (/usr/src/app/dist/infra/repositories/database.repository.js:42:9)
      at async DatabaseService.init (/usr/src/app/dist/domain/database/database.service.js:33:9)
      at async AppService.init (/usr/src/app/dist/immich/app.service.js:56:9)
      at async AppModule.onModuleInit (/usr/src/app/dist/immich/app.module.js:32:9) {
    length: 134,
    severity: 'ERROR',
    code: '42701',
    detail: undefined,
    hint: undefined,
    position: undefined,
    internalPosition: undefined,
    internalQuery: undefined,
    where: undefined,
    schema: undefined,
    table: undefined,
    column: undefined,
    dataType: undefined,
    constraint: undefined,
    file: 'tablecmds.c',
    line: '7242',
    routine: 'check_for_column_name_collision'
  },
  length: 134,
  severity: 'ERROR',
  code: '42701',
  detail: undefined,
  hint: undefined,
  position: undefined,
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'tablecmds.c',
  line: '7242',
  routine: 'check_for_column_name_collision'
}

After restarting the container without other changes made the error disappeared.

I now wonder:

The OS that Immich Server is running on

docker

Version of Immich Server

1.94.1

Version of Immich Mobile App

unrelated

Platform with the issue

Your docker-compose.yml content

unrelated

Your .env content

unrelated

Reproduction steps

1. Upgrade to 1.94.1

Additional information

No response

bo0tzz commented 7 months ago

This is the same scenario as #6759. Nothing to worry about :)