"Corrupted Migrations" Loop After Upgrade To Latest (v1.137.3) #6741

Closed
opened 2026-02-05 12:30:29 +03:00 by OVERLORD · 0 comments
Owner

Originally created by @mindtricksdev on GitHub (Aug 4, 2025).

I have searched the existing issues, both open and closed, to make sure this is not a duplicate report.

  • Yes

The bug

After upgrading my Immich instance, the immich-server container enters a crash loop with a "corrupted migrations" error. I tried to do some debugging and have confirmed the database is not corrupted, but its specific migration history is incompatible with the migration logic in v1.137.3 and newer versions. The issue seems to stem from a conflict between a previously run migration (...694...) and an older migration (...676...) that exists in the newer application code (best guess).

The Error Log

The immich-server container repeatedly crashes with the following error:

[Nest] 7  - 08/04/2025, 4:45:50 PM   ERROR [Microservices:DatabaseRepository] Migrations failed: Error: 
corrupted migrations: expected previously executed migration 1750694237564-AlbumAssetAuditTable to be at index 15
 but 1750676477029-AlbumAssetUpdateId was found in its place. 
New migrations must always have a name that comes alphabetically after the last executed migration.

The OS that Immich Server is running on

Windows (official docker)

Version of Immich Server

1.137.3

Version of Immich Mobile App

Platform with the issue

  • Server
  • Web
  • Mobile

Your docker-compose.yml content

#
# WARNING: To install Immich, follow our guide: https://immich.app/docs/install/docker-compose
#
# Make sure to use the docker-compose.yml of the current release:
#
# https://github.com/immich-app/immich/releases/latest/download/docker-compose.yml
#
# The compose file on main may not be compatible with the latest release.

name: immich

services:
  immich-server:
    container_name: immich_server
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    extends:
      file: hwaccel.transcoding.yml
      service: nvenc # set to one of [nvenc, quicksync, rkmpp, vaapi, vaapi-wsl] for accelerated transcoding
    volumes:
      # Do not edit the next line. If you want to change the media storage location on your system, edit the value of UPLOAD_LOCATION in the .env file
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
      - /etc/localtime:/etc/localtime:ro
    env_file:
      - .env
    ports:
      - "2283:2283"
    depends_on:
      - redis
      - database
    restart: always
    healthcheck:
      disable: false

  immich-machine-learning:
    container_name: immich_machine_learning
    # For hardware acceleration, add one of -[armnn, cuda, rocm, openvino, rknn] to the image tag.
    # Example tag: ${IMMICH_VERSION:-release}-cuda
    image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}-cuda
    extends: # uncomment this section for hardware acceleration - see https://immich.app/docs/features/ml-hardware-acceleration
      file: hwaccel.ml.yml
      service: cuda # set to one of [armnn, cuda, rocm, openvino, openvino-wsl, rknn] for accelerated inference - use the `-wsl` version for WSL2 where applicable
    volumes:
      - model-cache:/cache
    env_file:
      - .env
    restart: always
    healthcheck:
      disable: false

  redis:
    container_name: immich_redis
    image: docker.io/valkey/valkey:8-bookworm@sha256:42cba146593a5ea9a622002c1b7cba5da7be248650cbb64ecb9c6c33d29794b1
    healthcheck:
      test: redis-cli ping || exit 1
    restart: always

  database:
    container_name: immich_postgres
    image: ghcr.io/immich-app/postgres:14-vectorchord0.3.0-pgvectors0.2.0
    environment:
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_USER: ${DB_USERNAME}
      POSTGRES_DB: ${DB_DATABASE_NAME}
      POSTGRES_INITDB_ARGS: "--data-checksums"
    volumes:
      # Do not edit the next line. If you want to change the database storage location on your system, edit the value of DB_DATA_LOCATION in the .env file
      - ${DB_DATA_LOCATION}:/var/lib/postgresql/data
    restart: always

volumes:
  model-cache:

Your .env content

# You can find documentation for all the supported env variables at https://immich.app/docs/install/environment-variables

# The location where your uploaded files are stored
UPLOAD_LOCATION=E:\media\photos

# The location where your database files are stored. Network shares are not supported for the database
DB_DATA_LOCATION=./postgres

# To set a timezone, uncomment the next line and change Etc/UTC to a TZ identifier from this list: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List
TZ=Europe/Bucharest

# The Immich version to use. You can pin this to a specific version like "v1.71.0"
IMMICH_VERSION=release

# Connection secret for postgres. You should change it to a random password
# Please use only the characters `A-Za-z0-9`, without special characters or spaces
DB_PASSWORD=********
DB_USERNAME=********
DB_DATABASE_NAME=immich

Reproduction steps

  1. docker compose pull && docker compose up -d
  2. Container immich_server keeps restarting
    ...

Relevant log output

[Nest] 7  - 08/04/2025, 4:45:50 PM   ERROR [Microservices:DatabaseRepository] Migrations failed: Error: corrupted migrations: expected previously executed migration 1750694237564-AlbumAssetAuditTable to be at index 15 but 1750676477029-AlbumAssetUpdateId was found in its place. New migrations must always have a name that comes alphabetically after the last executed migration.
2025-08-04 16:45:50


Error: corrupted migrations: expected previously executed migration 1750694237564-AlbumAssetAuditTable to be at index 15 but 1750676477029-AlbumAssetUpdateId was found in its place. New migrations must always have a name that comes alphabetically after the last executed migration.
2025-08-04 16:45:50


    at #ensureMigrationsInOrder (/usr/src/app/server/node_modules/kysely/dist/cjs/migration/migrator.js:495:23)
2025-08-04 16:45:50


    at #getState (/usr/src/app/server/node_modules/kysely/dist/cjs/migration/migrator.js:441:42)
2025-08-04 16:45:50


    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
2025-08-04 16:45:50


    at async run (/usr/src/app/server/node_modules/kysely/dist/cjs/migration/migrator.js:409:31)
2025-08-04 16:45:50


    at async /usr/src/app/server/node_modules/kysely/dist/cjs/kysely.js:569:32
2025-08-04 16:45:50


    at async DefaultConnectionProvider.provideConnection (/usr/src/app/server/node_modules/kysely/dist/cjs/driver/default-connection-provider.js:12:20)
2025-08-04 16:45:50


    at async #migrate (/usr/src/app/server/node_modules/kysely/dist/cjs/migration/migrator.js:268:20)
2025-08-04 16:45:50


    at async DatabaseRepository.runMigrations (/usr/src/app/server/dist/repositories/database.repository.js:325:36)
2025-08-04 16:45:50


    at async /usr/src/app/server/dist/services/database.service.js:105:17
2025-08-04 16:45:50


    at async /usr/src/app/server/dist/repositories/database.repository.js:379:27
2025-08-04 16:45:50


microservices worker error: Error: corrupted migrations: expected previously executed migration 1750694237564-AlbumAssetAuditTable to be at index 15 but 1750676477029-AlbumAssetUpdateId was found in its place. New migrations must always have a name that comes alphabetically after the last executed migration., stack: Error: corrupted migrations: expected previously executed migration 1750694237564-AlbumAssetAuditTable to be at index 15 but 1750676477029-AlbumAssetUpdateId was found in its place. New migrations must always have a name that comes alphabetically after the last executed migration.
2025-08-04 16:45:50


    at #ensureMigrationsInOrder (/usr/src/app/server/node_modules/kysely/dist/cjs/migration/migrator.js:495:23)
2025-08-04 16:45:50


    at #getState (/usr/src/app/server/node_modules/kysely/dist/cjs/migration/migrator.js:441:42)
2025-08-04 16:45:50


    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
2025-08-04 16:45:50


    at async run (/usr/src/app/server/node_modules/kysely/dist/cjs/migration/migrator.js:409:31)
2025-08-04 16:45:50


    at async /usr/src/app/server/node_modules/kysely/dist/cjs/kysely.js:569:32
2025-08-04 16:45:50


    at async DefaultConnectionProvider.provideConnection (/usr/src/app/server/node_modules/kysely/dist/cjs/driver/default-connection-provider.js:12:20)
2025-08-04 16:45:50


    at async #migrate (/usr/src/app/server/node_modules/kysely/dist/cjs/migration/migrator.js:268:20)
2025-08-04 16:45:50


    at async DatabaseRepository.runMigrations (/usr/src/app/server/dist/repositories/database.repository.js:325:36)
2025-08-04 16:45:50


    at async /usr/src/app/server/dist/services/database.service.js:105:17
2025-08-04 16:45:50


    at async /usr/src/app/server/dist/repositories/database.repository.js:379:27

Additional information

PS D:\docker\services\immich> docker-compose exec database psql -U postgres -d immich
psql (14.18 (Debian 14.18-1.pgdg120+1))
Type "help" for help.

immich=# SELECT name FROM kysely_migrations ORDER BY name;
name

1744910873969-InitialMigration
1744991379464-AddNotificationsTable
1745244781846-AddUserAvatarColorColumn
1745902563899-AddAssetVisibilityColumn
1746636476623-DropExtraIndexes
1746768490606-AddUserPincode
1746844028242-AddLockedVisibilityEnum
1746987967923-AddPinExpiresAtColumn
1747329504572-AddNewSessionColumns
1747338664832-SessionRename
1747664684909-AddAlbumAuditTables
1749067526135-UserOnboardingDefault
1750107668827-PartnerCreateId
1750189909087-AddAlbumUserCreateFields
1750323941566-UnsetPrewarmDimParameter
1750676477029-AlbumAssetUpdateId
1750694237564-AlbumAssetAuditTable
1750780093818-AddAlbumToAssetDeleteTrigger
1751035357937-MemorySyncChanges
1751304834247-StackSyncChanges
1751924596408-AddOverrides
1752004072340-UpdateIndexOverrides
1752152941084-PeopleAuditTable
1752161055253-RenameGeodataPKConstraint
1752161055254-AddActivityAssetFk
1752169992364-AddIsPendingSyncReset
1752250924342-UserMetadataSync
1752267649968-StandardizeNames
1752759108283-ConvertToAbsolutePaths
1753104909784-AssetFaceUpdateIdAndAuditTable
1753464178233-RenameApiKeyPermissions
1753471866748-AddSharedLinkSlug
1753800911775-ProfileImageCheckpointRemoval
(33 rows)

Originally created by @mindtricksdev on GitHub (Aug 4, 2025). ### I have searched the existing issues, both open and closed, to make sure this is not a duplicate report. - [x] Yes ### The bug After upgrading my Immich instance, the `immich-server` container enters a crash loop with a "corrupted migrations" error. I tried to do some debugging and have confirmed the database is not corrupted, but its specific migration history is incompatible with the migration logic in v1.137.3 and newer versions. The issue seems to stem from a conflict between a previously run migration (...694...) and an older migration (...676...) that exists in the newer application code (best guess). # The Error Log The `immich-server` container repeatedly crashes with the following error: ```yaml [Nest] 7 - 08/04/2025, 4:45:50 PM ERROR [Microservices:DatabaseRepository] Migrations failed: Error: corrupted migrations: expected previously executed migration 1750694237564-AlbumAssetAuditTable to be at index 15 but 1750676477029-AlbumAssetUpdateId was found in its place. New migrations must always have a name that comes alphabetically after the last executed migration. ``` ### The OS that Immich Server is running on Windows (official docker) ### Version of Immich Server 1.137.3 ### Version of Immich Mobile App - ### Platform with the issue - [x] Server - [ ] Web - [ ] Mobile ### Your docker-compose.yml content ```YAML # # WARNING: To install Immich, follow our guide: https://immich.app/docs/install/docker-compose # # Make sure to use the docker-compose.yml of the current release: # # https://github.com/immich-app/immich/releases/latest/download/docker-compose.yml # # The compose file on main may not be compatible with the latest release. name: immich services: immich-server: container_name: immich_server image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release} extends: file: hwaccel.transcoding.yml service: nvenc # set to one of [nvenc, quicksync, rkmpp, vaapi, vaapi-wsl] for accelerated transcoding volumes: # Do not edit the next line. If you want to change the media storage location on your system, edit the value of UPLOAD_LOCATION in the .env file - ${UPLOAD_LOCATION}:/usr/src/app/upload - /etc/localtime:/etc/localtime:ro env_file: - .env ports: - "2283:2283" depends_on: - redis - database restart: always healthcheck: disable: false immich-machine-learning: container_name: immich_machine_learning # For hardware acceleration, add one of -[armnn, cuda, rocm, openvino, rknn] to the image tag. # Example tag: ${IMMICH_VERSION:-release}-cuda image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}-cuda extends: # uncomment this section for hardware acceleration - see https://immich.app/docs/features/ml-hardware-acceleration file: hwaccel.ml.yml service: cuda # set to one of [armnn, cuda, rocm, openvino, openvino-wsl, rknn] for accelerated inference - use the `-wsl` version for WSL2 where applicable volumes: - model-cache:/cache env_file: - .env restart: always healthcheck: disable: false redis: container_name: immich_redis image: docker.io/valkey/valkey:8-bookworm@sha256:42cba146593a5ea9a622002c1b7cba5da7be248650cbb64ecb9c6c33d29794b1 healthcheck: test: redis-cli ping || exit 1 restart: always database: container_name: immich_postgres image: ghcr.io/immich-app/postgres:14-vectorchord0.3.0-pgvectors0.2.0 environment: POSTGRES_PASSWORD: ${DB_PASSWORD} POSTGRES_USER: ${DB_USERNAME} POSTGRES_DB: ${DB_DATABASE_NAME} POSTGRES_INITDB_ARGS: "--data-checksums" volumes: # Do not edit the next line. If you want to change the database storage location on your system, edit the value of DB_DATA_LOCATION in the .env file - ${DB_DATA_LOCATION}:/var/lib/postgresql/data restart: always volumes: model-cache: ``` ### Your .env content ```Shell # You can find documentation for all the supported env variables at https://immich.app/docs/install/environment-variables # The location where your uploaded files are stored UPLOAD_LOCATION=E:\media\photos # The location where your database files are stored. Network shares are not supported for the database DB_DATA_LOCATION=./postgres # To set a timezone, uncomment the next line and change Etc/UTC to a TZ identifier from this list: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List TZ=Europe/Bucharest # The Immich version to use. You can pin this to a specific version like "v1.71.0" IMMICH_VERSION=release # Connection secret for postgres. You should change it to a random password # Please use only the characters `A-Za-z0-9`, without special characters or spaces DB_PASSWORD=******** DB_USERNAME=******** DB_DATABASE_NAME=immich ``` ### Reproduction steps 1. `docker compose pull && docker compose up -d` 2. Container `immich_server` keeps restarting ... ### Relevant log output ```shell [Nest] 7 - 08/04/2025, 4:45:50 PM ERROR [Microservices:DatabaseRepository] Migrations failed: Error: corrupted migrations: expected previously executed migration 1750694237564-AlbumAssetAuditTable to be at index 15 but 1750676477029-AlbumAssetUpdateId was found in its place. New migrations must always have a name that comes alphabetically after the last executed migration. 2025-08-04 16:45:50 Error: corrupted migrations: expected previously executed migration 1750694237564-AlbumAssetAuditTable to be at index 15 but 1750676477029-AlbumAssetUpdateId was found in its place. New migrations must always have a name that comes alphabetically after the last executed migration. 2025-08-04 16:45:50 at #ensureMigrationsInOrder (/usr/src/app/server/node_modules/kysely/dist/cjs/migration/migrator.js:495:23) 2025-08-04 16:45:50 at #getState (/usr/src/app/server/node_modules/kysely/dist/cjs/migration/migrator.js:441:42) 2025-08-04 16:45:50 at process.processTicksAndRejections (node:internal/process/task_queues:105:5) 2025-08-04 16:45:50 at async run (/usr/src/app/server/node_modules/kysely/dist/cjs/migration/migrator.js:409:31) 2025-08-04 16:45:50 at async /usr/src/app/server/node_modules/kysely/dist/cjs/kysely.js:569:32 2025-08-04 16:45:50 at async DefaultConnectionProvider.provideConnection (/usr/src/app/server/node_modules/kysely/dist/cjs/driver/default-connection-provider.js:12:20) 2025-08-04 16:45:50 at async #migrate (/usr/src/app/server/node_modules/kysely/dist/cjs/migration/migrator.js:268:20) 2025-08-04 16:45:50 at async DatabaseRepository.runMigrations (/usr/src/app/server/dist/repositories/database.repository.js:325:36) 2025-08-04 16:45:50 at async /usr/src/app/server/dist/services/database.service.js:105:17 2025-08-04 16:45:50 at async /usr/src/app/server/dist/repositories/database.repository.js:379:27 2025-08-04 16:45:50 microservices worker error: Error: corrupted migrations: expected previously executed migration 1750694237564-AlbumAssetAuditTable to be at index 15 but 1750676477029-AlbumAssetUpdateId was found in its place. New migrations must always have a name that comes alphabetically after the last executed migration., stack: Error: corrupted migrations: expected previously executed migration 1750694237564-AlbumAssetAuditTable to be at index 15 but 1750676477029-AlbumAssetUpdateId was found in its place. New migrations must always have a name that comes alphabetically after the last executed migration. 2025-08-04 16:45:50 at #ensureMigrationsInOrder (/usr/src/app/server/node_modules/kysely/dist/cjs/migration/migrator.js:495:23) 2025-08-04 16:45:50 at #getState (/usr/src/app/server/node_modules/kysely/dist/cjs/migration/migrator.js:441:42) 2025-08-04 16:45:50 at process.processTicksAndRejections (node:internal/process/task_queues:105:5) 2025-08-04 16:45:50 at async run (/usr/src/app/server/node_modules/kysely/dist/cjs/migration/migrator.js:409:31) 2025-08-04 16:45:50 at async /usr/src/app/server/node_modules/kysely/dist/cjs/kysely.js:569:32 2025-08-04 16:45:50 at async DefaultConnectionProvider.provideConnection (/usr/src/app/server/node_modules/kysely/dist/cjs/driver/default-connection-provider.js:12:20) 2025-08-04 16:45:50 at async #migrate (/usr/src/app/server/node_modules/kysely/dist/cjs/migration/migrator.js:268:20) 2025-08-04 16:45:50 at async DatabaseRepository.runMigrations (/usr/src/app/server/dist/repositories/database.repository.js:325:36) 2025-08-04 16:45:50 at async /usr/src/app/server/dist/services/database.service.js:105:17 2025-08-04 16:45:50 at async /usr/src/app/server/dist/repositories/database.repository.js:379:27 ``` ### Additional information PS D:\docker\services\immich> docker-compose exec database psql -U postgres -d immich psql (14.18 (Debian 14.18-1.pgdg120+1)) Type "help" for help. immich=# SELECT name FROM kysely_migrations ORDER BY name; name ---------------------------------------------- 1744910873969-InitialMigration 1744991379464-AddNotificationsTable 1745244781846-AddUserAvatarColorColumn 1745902563899-AddAssetVisibilityColumn 1746636476623-DropExtraIndexes 1746768490606-AddUserPincode 1746844028242-AddLockedVisibilityEnum 1746987967923-AddPinExpiresAtColumn 1747329504572-AddNewSessionColumns 1747338664832-SessionRename 1747664684909-AddAlbumAuditTables 1749067526135-UserOnboardingDefault 1750107668827-PartnerCreateId 1750189909087-AddAlbumUserCreateFields 1750323941566-UnsetPrewarmDimParameter 1750676477029-AlbumAssetUpdateId 1750694237564-AlbumAssetAuditTable 1750780093818-AddAlbumToAssetDeleteTrigger 1751035357937-MemorySyncChanges 1751304834247-StackSyncChanges 1751924596408-AddOverrides 1752004072340-UpdateIndexOverrides 1752152941084-PeopleAuditTable 1752161055253-RenameGeodataPKConstraint 1752161055254-AddActivityAssetFk 1752169992364-AddIsPendingSyncReset 1752250924342-UserMetadataSync 1752267649968-StandardizeNames 1752759108283-ConvertToAbsolutePaths 1753104909784-AssetFaceUpdateIdAndAuditTable 1753464178233-RenameApiKeyPermissions 1753471866748-AddSharedLinkSlug 1753800911775-ProfileImageCheckpointRemoval (33 rows)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#6741