[iOS] SqliteException(2067): UNIQUE constraint failed in remote_asset_entity during sync #7385

Open
opened 2026-02-05 12:59:38 +03:00 by OVERLORD · 48 comments
Owner

Originally created by @abhishekgupta0511 on GitHub (Oct 1, 2025).

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

  • Yes

The bug

Description

When using Immich iOS client (iPhone 13 Pro, iOS 17/18), the app crashes with a SQLite UNIQUE constraint error during sync.

Steps to Reproduce

  1. Upgrade server to v1.144.1.
  2. Open Immich iOS mobile app.
  3. Let sync run with existing assets.
  4. Error appears in logs:

SqliteException(2067): while executing statement, UNIQUE constraint failed: remote_asset_entity.owner_id, remote_asset_entity.checksum

Causing statement: INSERT INTO "remote_asset_entity" ...

  1. Resetting the mobile DB (deleting & reinstalling app) DOES NOT work.

Expected Behavior

  • Client should detect duplicate remote assets gracefully, not crash.
    -- Actual Behavior - Sync fails with UNIQUE constraint violation, blocking further asset sync.
  • Resetting the mobile DB (deleting & reinstalling app) SHOULD HAVE worked.
    • It doesn't work

Environment

  • Device: iPhone 13 Pro
  • iOS version: 17.x / 18.x (latest)
  • Immich Mobile app version: 1.144.1 client build
  • Immich Server version: 1.144.1
  • Database: Postgres (vector extension)

Additional Info

Resetting the mobile DB (deleting & reinstalling app) DOES NOT work.

The OS that Immich Server is running on

ios mobile app immich 1.144.1

Version of Immich Server

v1.144.1

Version of Immich Mobile App

v1.44.1

Platform with the issue

  • Server
  • Web
  • Mobile

Device make and model

iPhone 13 pro

Your docker-compose.yml content

name: immich

services:
  immich-server:
    container_name: immich_server
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    volumes:
      - ${UPLOAD_LOCATION}:/data
      - /etc/localtime:/etc/localtime:ro
    env_file:
      - .env
    ports:
      - '8081:2283'
    depends_on:
      - redis
      - database
    environment:
      IMMICH_FFMPEG_PATH: "/usr/local/bin/ffmpeg"
      IMMICH_FFPROBE_PATH: "/usr/local/bin/ffprobe"
      IMMICH_HWACCEL_TRANSCODE: "cpu"
      IMMICH_HWACCEL_INFERENCE: "cpu"
    restart: always
    healthcheck:
      disable: false

  immich-machine-learning:
    container_name: immich_machine_learning
    image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}
    volumes:
      - model-cache:/cache
    env_file:
      - .env
    restart: always
    healthcheck:
      disable: false
    environment:
      IMMICH_HWACCEL_INFERENCE: "cpu"

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

  database:
    container_name: immich_postgres
    image: ghcr.io/immich-app/postgres:14-vectorchord0.4.3-pgvectors0.2.0@sha256:8d292bdb796aa58bbbaa47fe971c8516f6f57d6a47e7172e62754feb6ed4e7b0
    environment:
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_USER: ${DB_USERNAME}
      POSTGRES_DB: ${DB_DATABASE_NAME}
      POSTGRES_INITDB_ARGS: '--data-checksums'
    volumes:
      - ${DB_DATA_LOCATION}:/var/lib/postgresql/data
    shm_size: 128mb
    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=/Volumes/PrimarySSD/immich-upload/library

# The location where your database files are stored. Network shares are not supported for the database
DB_DATA_LOCATION=/Volumes/PrimarySSD/immich-db/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=Etc/UTC
TZ=Asia/Kolkata

# 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=postgres

# The values below this line do not need to be changed
###################################################################################
DB_USERNAME=postgres
DB_DATABASE_NAME=immich


# MEDIA_HW_ACCELERATION=true
MEDIA_HW_ACCELERATION=false
MEDIA_CONCURRENCY=8
MEDIA_TRANSCODE_THREADS=4


# IMMICH_LOG_LEVEL=warn

# Use these environment variables if your Immich version supports them
IMMICH_FFMPEG_FLAGS="-y -v error -strict -2"
IMMICH_FFPROBE_FLAGS="-v error"

FFMPEG_ARGS=-vf tonemap=tonemap=bt.2390:desat=0:peak=1000

Reproduction steps

  1. Upgrade server to v1.144.1.
  2. Open Immich iOS mobile app.
  3. Let sync run with existing assets.
  4. Error appears in client app logs:
    SqliteException(2067): while executing statement, UNIQUE constraint failed: remote_asset_entity.owner_id, remote_asset_entity.checksum

Causing statement: INSERT INTO "remote_asset_entity" ...

Error in client

SqliteException(2067): while executing statement, UNIQUE constraint failed: remote_asset_entity.owner_id, remote_asset_entity.checksum, constraint failed (code 2067)
Causing statement: INSERT INTO "remote_asset_entity" ("name", "type", "created_at", "updated_at", "duration_in_seconds", "id", "checksum", "is_favorite", "owner_id", "local_date_time", "thumb_hash", "deleted_at", "live_photo_video_id", "visibility", "stack_id", "library_id") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT("id") DO UPDATE SET "name" = ?, "type" = ?, "created_at" = ?, "updated_at" = ?, "duration_in_seconds" = ?, "checksum" = ?, "is_favorite" = ?, "owner_id" = ?, "local_date_time" = ?, "thumb_hash" = ?, "deleted_at" = ?, "live_photo_video_id" = ?, "visibility" = ?, "stack_id" = ?, "library_id" = ?, parameters: IMG_5801.MOV, 2, 2025-08-23T05:06:07.000Z, 2025-08-24T12:31:31.000Z, 2, b47509b2-87b9-4e03-b058-1337201093dc, 0UIDkK+sfB4wXWEFQLv4MYQCzZI=, 0, f918d4e0-14f2-48a7-9611-38656bcb7fbc, 2025-08-23T10:36:07.000Z, null, null, null, 1, null, null, IMG_5801.MOV, 2, 2025-08-23T05:06:07.000Z, 2025-08-24T12:31:31.000Z, 2, 0UIDkK+sfB4wXWEFQLv4MYQCzZI=, 0, f918d4e0-14f2-48a7-9611-38656bcb7fbc, 2025-08-23T10:36:07.000Z, null, null, null, 1, null, null

package:sqlite3/src/implementation/exception.dart 87 throwException
package:sqlite3/src/implementation/statement.dart 109 StatementImplementation._execute
package:sqlite3/src/implementation/statement.dart 289 StatementImplementation.executeWith
package:sqlite3/src/statement.dart 81 CommonPreparedStatement.execute
package:drift/src/sqlite3/database.dart 131 Sqlite3Delegate.runBatchSync
package:drift/native.dart 373 _NativeDelegate.runBatched.
dart:async/future.dart 315 new Future.sync
package:drift/native.dart 373 _NativeDelegate.runBatched
package:drift/src/runtime/executor/helpers/engines.dart 128 _BaseExecutor.runBatched.
package:drift/src/runtime/executor/helpers/engines.dart 62 _BaseExecutor._synchronized
package:drift/src/runtime/executor/helpers/engines.dart 122 _BaseExecutor.runBatched
package:drift/src/remote/server_impl.dart 170 ServerImplementation._runBatched
package:drift/src/remote/communication.dart 165 DriftCommunication.setRequestHandler.
===== asynchronous gap ===========================
package:drift/src/remote/communication.dart 113 DriftCommunication.request
package:drift/src/remote/client_impl.dart 84 _BaseExecutor.runBatched
package:drift/src/runtime/api/batch.dart 215 Batch._runWith
package:drift/src/runtime/api/batch.dart 199 Batch._commit
package:immich_mobile/infrastructure/repositories/sync_stream.repository.dart 178 SyncStreamRepository.updateAssetsV1
package:immich_mobile/domain/services/sync_stream.service.dart 67 SyncStreamService._processBatch
package:immich_mobile/domain/services/sync_stream.service.dart 58 SyncStreamService._handleEvents
package:immich_mobile/infrastructure/repositories/sync_api.repository.dart 105 SyncApiRepository.streamChanges
package:immich_mobile/domain/services/sync_stream.service.dart 30 SyncStreamService.sync
package:immich_mobile/utils/isolate.dart 57 runInIsolateGentle..
package:immich_mobile/utils/isolate.dart 36 runInIsolateGentle.
package:worker_manager/src/worker/worker_io.dart 106 WorkerImpl._anotherIsolate.

Relevant log output

Error in client

SqliteException(2067): while executing statement, UNIQUE constraint failed: remote_asset_entity.owner_id, remote_asset_entity.checksum, constraint failed (code 2067)
  Causing statement: INSERT INTO "remote_asset_entity" ("name", "type", "created_at", "updated_at", "duration_in_seconds", "id", "checksum", "is_favorite", "owner_id", "local_date_time", "thumb_hash", "deleted_at", "live_photo_video_id", "visibility", "stack_id", "library_id") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT("id") DO UPDATE SET "name" = ?, "type" = ?, "created_at" = ?, "updated_at" = ?, "duration_in_seconds" = ?, "checksum" = ?, "is_favorite" = ?, "owner_id" = ?, "local_date_time" = ?, "thumb_hash" = ?, "deleted_at" = ?, "live_photo_video_id" = ?, "visibility" = ?, "stack_id" = ?, "library_id" = ?, parameters: IMG_5801.MOV, 2, 2025-08-23T05:06:07.000Z, 2025-08-24T12:31:31.000Z, 2, b47509b2-87b9-4e03-b058-1337201093dc, 0UIDkK+sfB4wXWEFQLv4MYQCzZI=, 0, f918d4e0-14f2-48a7-9611-38656bcb7fbc, 2025-08-23T10:36:07.000Z, null, null, null, 1, null, null, IMG_5801.MOV, 2, 2025-08-23T05:06:07.000Z, 2025-08-24T12:31:31.000Z, 2, 0UIDkK+sfB4wXWEFQLv4MYQCzZI=, 0, f918d4e0-14f2-48a7-9611-38656bcb7fbc, 2025-08-23T10:36:07.000Z, null, null, null, 1, null, null



package:sqlite3/src/implementation/exception.dart 87                               throwException
package:sqlite3/src/implementation/statement.dart 109                              StatementImplementation._execute
package:sqlite3/src/implementation/statement.dart 289                              StatementImplementation.executeWith
package:sqlite3/src/statement.dart 81                                              CommonPreparedStatement.execute
package:drift/src/sqlite3/database.dart 131                                        Sqlite3Delegate.runBatchSync
package:drift/native.dart 373                                                      _NativeDelegate.runBatched.<fn>
dart:async/future.dart 315                                                         new Future.sync
package:drift/native.dart 373                                                      _NativeDelegate.runBatched
package:drift/src/runtime/executor/helpers/engines.dart 128                        _BaseExecutor.runBatched.<fn>
package:drift/src/runtime/executor/helpers/engines.dart 62                         _BaseExecutor._synchronized
package:drift/src/runtime/executor/helpers/engines.dart 122                        _BaseExecutor.runBatched
package:drift/src/remote/server_impl.dart 170                                      ServerImplementation._runBatched
package:drift/src/remote/communication.dart 165                                    DriftCommunication.setRequestHandler.<fn>
===== asynchronous gap ===========================
package:drift/src/remote/communication.dart 113                                    DriftCommunication.request
package:drift/src/remote/client_impl.dart 84                                       _BaseExecutor.runBatched
package:drift/src/runtime/api/batch.dart 215                                       Batch._runWith
package:drift/src/runtime/api/batch.dart 199                                       Batch._commit
package:immich_mobile/infrastructure/repositories/sync_stream.repository.dart 178  SyncStreamRepository.updateAssetsV1
package:immich_mobile/domain/services/sync_stream.service.dart 67                  SyncStreamService._processBatch
package:immich_mobile/domain/services/sync_stream.service.dart 58                  SyncStreamService._handleEvents
package:immich_mobile/infrastructure/repositories/sync_api.repository.dart 105     SyncApiRepository.streamChanges
package:immich_mobile/domain/services/sync_stream.service.dart 30                  SyncStreamService.sync
package:immich_mobile/utils/isolate.dart 57                                        runInIsolateGentle.<fn>.<fn>
package:immich_mobile/utils/isolate.dart 36                                        runInIsolateGentle.<fn>
package:worker_manager/src/worker/worker_io.dart 106                               WorkerImpl._anotherIsolate.<fn>

Additional information

Resetting the mobile DB (deleting & reinstalling app) DOES NOT work. It ideally should have fixed the issue but it didn't.

Originally created by @abhishekgupta0511 on GitHub (Oct 1, 2025). ### I have searched the existing issues, both open and closed, to make sure this is not a duplicate report. - [x] Yes ### The bug **Description** When using Immich iOS client (iPhone 13 Pro, iOS 17/18), the app crashes with a SQLite UNIQUE constraint error during sync. **Steps to Reproduce** 1. Upgrade server to v1.144.1. 2. Open Immich iOS mobile app. 3. Let sync run with existing assets. 4. Error appears in logs: SqliteException(2067): while executing statement, UNIQUE constraint failed: remote_asset_entity.owner_id, remote_asset_entity.checksum Causing statement: INSERT INTO "remote_asset_entity" ... 5. Resetting the mobile DB (deleting & reinstalling app) DOES NOT work. **Expected Behavior** - Client should detect duplicate remote assets gracefully, not crash. -- Actual Behavior - Sync fails with UNIQUE constraint violation, blocking further asset sync. - Resetting the mobile DB (deleting & reinstalling app) SHOULD HAVE worked. - - It doesn't work **Environment** - Device: iPhone 13 Pro - iOS version: 17.x / 18.x (latest) - Immich Mobile app version: 1.144.1 client build - Immich Server version: 1.144.1 - Database: Postgres (vector extension) **Additional Info** Resetting the mobile DB (deleting & reinstalling app) DOES NOT work. ### The OS that Immich Server is running on ios mobile app immich 1.144.1 ### Version of Immich Server v1.144.1 ### Version of Immich Mobile App v1.44.1 ### Platform with the issue - [ ] Server - [ ] Web - [x] Mobile ### Device make and model iPhone 13 pro ### Your docker-compose.yml content ```YAML name: immich services: immich-server: container_name: immich_server image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release} volumes: - ${UPLOAD_LOCATION}:/data - /etc/localtime:/etc/localtime:ro env_file: - .env ports: - '8081:2283' depends_on: - redis - database environment: IMMICH_FFMPEG_PATH: "/usr/local/bin/ffmpeg" IMMICH_FFPROBE_PATH: "/usr/local/bin/ffprobe" IMMICH_HWACCEL_TRANSCODE: "cpu" IMMICH_HWACCEL_INFERENCE: "cpu" restart: always healthcheck: disable: false immich-machine-learning: container_name: immich_machine_learning image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release} volumes: - model-cache:/cache env_file: - .env restart: always healthcheck: disable: false environment: IMMICH_HWACCEL_INFERENCE: "cpu" redis: container_name: immich_redis image: docker.io/valkey/valkey:8-bookworm@sha256:fea8b3e67b15729d4bb70589eb03367bab9ad1ee89c876f54327fc7c6e618571 healthcheck: test: redis-cli ping || exit 1 restart: always database: container_name: immich_postgres image: ghcr.io/immich-app/postgres:14-vectorchord0.4.3-pgvectors0.2.0@sha256:8d292bdb796aa58bbbaa47fe971c8516f6f57d6a47e7172e62754feb6ed4e7b0 environment: POSTGRES_PASSWORD: ${DB_PASSWORD} POSTGRES_USER: ${DB_USERNAME} POSTGRES_DB: ${DB_DATABASE_NAME} POSTGRES_INITDB_ARGS: '--data-checksums' volumes: - ${DB_DATA_LOCATION}:/var/lib/postgresql/data shm_size: 128mb 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=/Volumes/PrimarySSD/immich-upload/library # The location where your database files are stored. Network shares are not supported for the database DB_DATA_LOCATION=/Volumes/PrimarySSD/immich-db/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=Etc/UTC TZ=Asia/Kolkata # 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=postgres # The values below this line do not need to be changed ################################################################################### DB_USERNAME=postgres DB_DATABASE_NAME=immich # MEDIA_HW_ACCELERATION=true MEDIA_HW_ACCELERATION=false MEDIA_CONCURRENCY=8 MEDIA_TRANSCODE_THREADS=4 # IMMICH_LOG_LEVEL=warn # Use these environment variables if your Immich version supports them IMMICH_FFMPEG_FLAGS="-y -v error -strict -2" IMMICH_FFPROBE_FLAGS="-v error" FFMPEG_ARGS=-vf tonemap=tonemap=bt.2390:desat=0:peak=1000 ``` ### Reproduction steps 1. Upgrade server to v1.144.1. 2. Open Immich iOS mobile app. 3. Let sync run with existing assets. 4. Error appears in client app logs: SqliteException(2067): while executing statement, UNIQUE constraint failed: remote_asset_entity.owner_id, remote_asset_entity.checksum Causing statement: INSERT INTO "remote_asset_entity" ... Error in client SqliteException(2067): while executing statement, UNIQUE constraint failed: remote_asset_entity.owner_id, remote_asset_entity.checksum, constraint failed (code 2067) Causing statement: INSERT INTO "remote_asset_entity" ("name", "type", "created_at", "updated_at", "duration_in_seconds", "id", "checksum", "is_favorite", "owner_id", "local_date_time", "thumb_hash", "deleted_at", "live_photo_video_id", "visibility", "stack_id", "library_id") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT("id") DO UPDATE SET "name" = ?, "type" = ?, "created_at" = ?, "updated_at" = ?, "duration_in_seconds" = ?, "checksum" = ?, "is_favorite" = ?, "owner_id" = ?, "local_date_time" = ?, "thumb_hash" = ?, "deleted_at" = ?, "live_photo_video_id" = ?, "visibility" = ?, "stack_id" = ?, "library_id" = ?, parameters: IMG_5801.MOV, 2, 2025-08-23T05:06:07.000Z, 2025-08-24T12:31:31.000Z, 2, b47509b2-87b9-4e03-b058-1337201093dc, 0UIDkK+sfB4wXWEFQLv4MYQCzZI=, 0, f918d4e0-14f2-48a7-9611-38656bcb7fbc, 2025-08-23T10:36:07.000Z, null, null, null, 1, null, null, IMG_5801.MOV, 2, 2025-08-23T05:06:07.000Z, 2025-08-24T12:31:31.000Z, 2, 0UIDkK+sfB4wXWEFQLv4MYQCzZI=, 0, f918d4e0-14f2-48a7-9611-38656bcb7fbc, 2025-08-23T10:36:07.000Z, null, null, null, 1, null, null package:sqlite3/src/implementation/exception.dart 87 throwException package:sqlite3/src/implementation/statement.dart 109 StatementImplementation._execute package:sqlite3/src/implementation/statement.dart 289 StatementImplementation.executeWith package:sqlite3/src/statement.dart 81 CommonPreparedStatement.execute package:drift/src/sqlite3/database.dart 131 Sqlite3Delegate.runBatchSync package:drift/native.dart 373 _NativeDelegate.runBatched.<fn> dart:async/future.dart 315 new Future.sync package:drift/native.dart 373 _NativeDelegate.runBatched package:drift/src/runtime/executor/helpers/engines.dart 128 _BaseExecutor.runBatched.<fn> package:drift/src/runtime/executor/helpers/engines.dart 62 _BaseExecutor._synchronized package:drift/src/runtime/executor/helpers/engines.dart 122 _BaseExecutor.runBatched package:drift/src/remote/server_impl.dart 170 ServerImplementation._runBatched package:drift/src/remote/communication.dart 165 DriftCommunication.setRequestHandler.<fn> ===== asynchronous gap =========================== package:drift/src/remote/communication.dart 113 DriftCommunication.request package:drift/src/remote/client_impl.dart 84 _BaseExecutor.runBatched package:drift/src/runtime/api/batch.dart 215 Batch._runWith package:drift/src/runtime/api/batch.dart 199 Batch._commit package:immich_mobile/infrastructure/repositories/sync_stream.repository.dart 178 SyncStreamRepository.updateAssetsV1 package:immich_mobile/domain/services/sync_stream.service.dart 67 SyncStreamService._processBatch package:immich_mobile/domain/services/sync_stream.service.dart 58 SyncStreamService._handleEvents package:immich_mobile/infrastructure/repositories/sync_api.repository.dart 105 SyncApiRepository.streamChanges package:immich_mobile/domain/services/sync_stream.service.dart 30 SyncStreamService.sync package:immich_mobile/utils/isolate.dart 57 runInIsolateGentle.<fn>.<fn> package:immich_mobile/utils/isolate.dart 36 runInIsolateGentle.<fn> package:worker_manager/src/worker/worker_io.dart 106 WorkerImpl._anotherIsolate.<fn> ### Relevant log output ```shell Error in client SqliteException(2067): while executing statement, UNIQUE constraint failed: remote_asset_entity.owner_id, remote_asset_entity.checksum, constraint failed (code 2067) Causing statement: INSERT INTO "remote_asset_entity" ("name", "type", "created_at", "updated_at", "duration_in_seconds", "id", "checksum", "is_favorite", "owner_id", "local_date_time", "thumb_hash", "deleted_at", "live_photo_video_id", "visibility", "stack_id", "library_id") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT("id") DO UPDATE SET "name" = ?, "type" = ?, "created_at" = ?, "updated_at" = ?, "duration_in_seconds" = ?, "checksum" = ?, "is_favorite" = ?, "owner_id" = ?, "local_date_time" = ?, "thumb_hash" = ?, "deleted_at" = ?, "live_photo_video_id" = ?, "visibility" = ?, "stack_id" = ?, "library_id" = ?, parameters: IMG_5801.MOV, 2, 2025-08-23T05:06:07.000Z, 2025-08-24T12:31:31.000Z, 2, b47509b2-87b9-4e03-b058-1337201093dc, 0UIDkK+sfB4wXWEFQLv4MYQCzZI=, 0, f918d4e0-14f2-48a7-9611-38656bcb7fbc, 2025-08-23T10:36:07.000Z, null, null, null, 1, null, null, IMG_5801.MOV, 2, 2025-08-23T05:06:07.000Z, 2025-08-24T12:31:31.000Z, 2, 0UIDkK+sfB4wXWEFQLv4MYQCzZI=, 0, f918d4e0-14f2-48a7-9611-38656bcb7fbc, 2025-08-23T10:36:07.000Z, null, null, null, 1, null, null package:sqlite3/src/implementation/exception.dart 87 throwException package:sqlite3/src/implementation/statement.dart 109 StatementImplementation._execute package:sqlite3/src/implementation/statement.dart 289 StatementImplementation.executeWith package:sqlite3/src/statement.dart 81 CommonPreparedStatement.execute package:drift/src/sqlite3/database.dart 131 Sqlite3Delegate.runBatchSync package:drift/native.dart 373 _NativeDelegate.runBatched.<fn> dart:async/future.dart 315 new Future.sync package:drift/native.dart 373 _NativeDelegate.runBatched package:drift/src/runtime/executor/helpers/engines.dart 128 _BaseExecutor.runBatched.<fn> package:drift/src/runtime/executor/helpers/engines.dart 62 _BaseExecutor._synchronized package:drift/src/runtime/executor/helpers/engines.dart 122 _BaseExecutor.runBatched package:drift/src/remote/server_impl.dart 170 ServerImplementation._runBatched package:drift/src/remote/communication.dart 165 DriftCommunication.setRequestHandler.<fn> ===== asynchronous gap =========================== package:drift/src/remote/communication.dart 113 DriftCommunication.request package:drift/src/remote/client_impl.dart 84 _BaseExecutor.runBatched package:drift/src/runtime/api/batch.dart 215 Batch._runWith package:drift/src/runtime/api/batch.dart 199 Batch._commit package:immich_mobile/infrastructure/repositories/sync_stream.repository.dart 178 SyncStreamRepository.updateAssetsV1 package:immich_mobile/domain/services/sync_stream.service.dart 67 SyncStreamService._processBatch package:immich_mobile/domain/services/sync_stream.service.dart 58 SyncStreamService._handleEvents package:immich_mobile/infrastructure/repositories/sync_api.repository.dart 105 SyncApiRepository.streamChanges package:immich_mobile/domain/services/sync_stream.service.dart 30 SyncStreamService.sync package:immich_mobile/utils/isolate.dart 57 runInIsolateGentle.<fn>.<fn> package:immich_mobile/utils/isolate.dart 36 runInIsolateGentle.<fn> package:worker_manager/src/worker/worker_io.dart 106 WorkerImpl._anotherIsolate.<fn> ``` ### Additional information Resetting the mobile DB (deleting & reinstalling app) DOES NOT work. It ideally should have fixed the issue but it didn't.
Author
Owner

@alextran1502 commented on GitHub (Oct 1, 2025):

Hmm, do you mind try to reinstall the app?

@alextran1502 commented on GitHub (Oct 1, 2025): Hmm, do you mind try to reinstall the app?
Author
Owner

@shenlong-tanwen commented on GitHub (Oct 1, 2025):

Hmm, do you mind try to reinstall the app?

@abhishekgupta0511 If reinstalling the app does not fix this issue, Kindly share the output of the following query from the server

select "id", "originalFileName", "ownerId", "libraryId" from asset where checksum = decode('0UIDkK+sfB4wXWEFQLv4MYQCzZI=', 'base64')
@shenlong-tanwen commented on GitHub (Oct 1, 2025): > Hmm, do you mind try to reinstall the app? @abhishekgupta0511 If reinstalling the app does not fix this issue, Kindly share the output of the following query from the server ```sql select "id", "originalFileName", "ownerId", "libraryId" from asset where checksum = decode('0UIDkK+sfB4wXWEFQLv4MYQCzZI=', 'base64') ```
Author
Owner

@Hinfty commented on GitHub (Oct 1, 2025):

Same problem here, I think

SqliteException(2067): while executing statement, UNIQUE constraint failed: remote_asset_entity.owner_id, remote_asset_entity.checksum, constraint failed (code 2067) Causing statement: INSERT INTO "remote_asset_entity" ("name", "type", "created_at", "updated_at", "duration_in_seconds", "id", "checksum", "is_favorite", "owner_id", "local_date_time", "thumb_hash", "deleted_at", "live_photo_video_id", "visibility", "stack_id", "library_id") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT("id") DO UPDATE SET "name" = ?, "type" = ?, "created_at" = ?, "updated_at" = ?, "duration_in_seconds" = ?, "checksum" = ?, "is_favorite" = ?, "owner_id" = ?, "local_date_time" = ?, "thumb_hash" = ?, "deleted_at" = ?, "live_photo_video_id" = ?, "visibility" = ?, "stack_id" = ?, "library_id" = ?, parameters: IMG_20181001_181356.jpg, 1, 2018-10-01T18:13:55.000Z, 2025-07-08T10:49:16.292Z, 0, b52153a0-b7a7-4591-83c3-1afc196daf3a, IJBA50QYkXIWP48Y4pMoGeysPuc=, 0, 65994829-5a61-4859-9848-9a8fac39d7e7, 2018-10-01T20:13:55.000Z, rCgGBQCHp6mHCIXnaXaYiNCdGftr, 2025-10-01T04:41:47.141Z, null, 0, null, null, IMG_20181001_181356.jpg, 1, 2018-10-01T18:13:55.000Z, 2025-07-08T10:49:16.292Z, 0, IJBA50QYkXIWP48Y4pMoGeysPuc=, 0, 65994829-5a61-4859-9848-9a8fac39d7e7, 2018-10-01T20:13:55.000Z, rCgGBQCHp6mHCIXnaXaYiNCdGftr, 2025-10-01T04:41:47.141Z, null, 0, null, null

@Hinfty commented on GitHub (Oct 1, 2025): Same problem here, I think `SqliteException(2067): while executing statement, UNIQUE constraint failed: remote_asset_entity.owner_id, remote_asset_entity.checksum, constraint failed (code 2067) Causing statement: INSERT INTO "remote_asset_entity" ("name", "type", "created_at", "updated_at", "duration_in_seconds", "id", "checksum", "is_favorite", "owner_id", "local_date_time", "thumb_hash", "deleted_at", "live_photo_video_id", "visibility", "stack_id", "library_id") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT("id") DO UPDATE SET "name" = ?, "type" = ?, "created_at" = ?, "updated_at" = ?, "duration_in_seconds" = ?, "checksum" = ?, "is_favorite" = ?, "owner_id" = ?, "local_date_time" = ?, "thumb_hash" = ?, "deleted_at" = ?, "live_photo_video_id" = ?, "visibility" = ?, "stack_id" = ?, "library_id" = ?, parameters: IMG_20181001_181356.jpg, 1, 2018-10-01T18:13:55.000Z, 2025-07-08T10:49:16.292Z, 0, b52153a0-b7a7-4591-83c3-1afc196daf3a, IJBA50QYkXIWP48Y4pMoGeysPuc=, 0, 65994829-5a61-4859-9848-9a8fac39d7e7, 2018-10-01T20:13:55.000Z, rCgGBQCHp6mHCIXnaXaYiNCdGftr, 2025-10-01T04:41:47.141Z, null, 0, null, null, IMG_20181001_181356.jpg, 1, 2018-10-01T18:13:55.000Z, 2025-07-08T10:49:16.292Z, 0, IJBA50QYkXIWP48Y4pMoGeysPuc=, 0, 65994829-5a61-4859-9848-9a8fac39d7e7, 2018-10-01T20:13:55.000Z, rCgGBQCHp6mHCIXnaXaYiNCdGftr, 2025-10-01T04:41:47.141Z, null, 0, null, null `
Author
Owner

@abhishekgupta0511 commented on GitHub (Oct 1, 2025):

Hmm, do you mind try to reinstall the app?

I did and multiple times in multiple ways..... Well if I disable new timeline in advanced settings this issue goes away!!

@abhishekgupta0511 commented on GitHub (Oct 1, 2025): > Hmm, do you mind try to reinstall the app? I did and multiple times in multiple ways..... Well if I disable new timeline in advanced settings this issue goes away!!
Author
Owner

@abhishekgupta0511 commented on GitHub (Oct 1, 2025):

um = decode('0UIDkK+sfB4wXWEFQLv4MYQCzZI=', 'base64')

Can you please help me where and how I should run this query on my iphone?

@abhishekgupta0511 commented on GitHub (Oct 1, 2025): > um = decode('0UIDkK+sfB4wXWEFQLv4MYQCzZI=', 'base64') Can you please help me where and how I should run this query on my iphone?
Author
Owner

@alextran1502 commented on GitHub (Oct 1, 2025):

@abhishekgupta0511 from the command line on your server run

docker exec -it immich_postgres psql --dbname=immich --username=postgres

After that, you can run the query

select "id", "originalFileName", "ownerId", "libraryId" from asset where checksum = decode('0UIDkK+sfB4wXWEFQLv4MYQCzZI=', 'base64');
@alextran1502 commented on GitHub (Oct 1, 2025): @abhishekgupta0511 from the command line on your server run ``` docker exec -it immich_postgres psql --dbname=immich --username=postgres ``` After that, you can run the query ``` select "id", "originalFileName", "ownerId", "libraryId" from asset where checksum = decode('0UIDkK+sfB4wXWEFQLv4MYQCzZI=', 'base64'); ```
Author
Owner

@Hinfty commented on GitHub (Oct 1, 2025):

Same problem here, I think

SqliteException(2067): while executing statement, UNIQUE constraint failed: remote_asset_entity.owner_id, remote_asset_entity.checksum, constraint failed (code 2067) Causing statement: INSERT INTO "remote_asset_entity" ("name", "type", "created_at", "updated_at", "duration_in_seconds", "id", "checksum", "is_favorite", "owner_id", "local_date_time", "thumb_hash", "deleted_at", "live_photo_video_id", "visibility", "stack_id", "library_id") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT("id") DO UPDATE SET "name" = ?, "type" = ?, "created_at" = ?, "updated_at" = ?, "duration_in_seconds" = ?, "checksum" = ?, "is_favorite" = ?, "owner_id" = ?, "local_date_time" = ?, "thumb_hash" = ?, "deleted_at" = ?, "live_photo_video_id" = ?, "visibility" = ?, "stack_id" = ?, "library_id" = ?, parameters: IMG_20181001_181356.jpg, 1, 2018-10-01T18:13:55.000Z, 2025-07-08T10:49:16.292Z, 0, b52153a0-b7a7-4591-83c3-1afc196daf3a, IJBA50QYkXIWP48Y4pMoGeysPuc=, 0, 65994829-5a61-4859-9848-9a8fac39d7e7, 2018-10-01T20:13:55.000Z, rCgGBQCHp6mHCIXnaXaYiNCdGftr, 2025-10-01T04:41:47.141Z, null, 0, null, null, IMG_20181001_181356.jpg, 1, 2018-10-01T18:13:55.000Z, 2025-07-08T10:49:16.292Z, 0, IJBA50QYkXIWP48Y4pMoGeysPuc=, 0, 65994829-5a61-4859-9848-9a8fac39d7e7, 2018-10-01T20:13:55.000Z, rCgGBQCHp6mHCIXnaXaYiNCdGftr, 2025-10-01T04:41:47.141Z, null, 0, null, null

For me this is a file that I used "replace with upload" on, if that might point to the solution.
Running the SQL statement produces just one row:

select "id", "originalFileName", "ownerId", "libraryId" from asset where checksum = decode('IJBA50QYkXIWP48Y4pMoGeysPuc=', 'base64');

              id                  |    originalFileName     |               ownerId                | libraryId

--------------------------------------+-------------------------+--------------------------------------+-----------
b52153a0-b7a7-4591-83c3-1afc196daf3a | IMG_20181001_181356.jpg | 65994829-5a61-4859-9848-9a8fac39d7e7 |
(1 row)

As there is no actual violation of unique ids, I figured resetting DB would work. So deleted SQLite, logged out and in and resynced.
That fixed the mobile DB, but this sure wasn't particularly user friendly.
Question remains why it generated the insert statement instead of an update statement.
Maybe to do with the "replace with upload" action? I'll test this functionality more and see if it breaks anything again.

@Hinfty commented on GitHub (Oct 1, 2025): > Same problem here, I think > > `SqliteException(2067): while executing statement, UNIQUE constraint failed: remote_asset_entity.owner_id, remote_asset_entity.checksum, constraint failed (code 2067) Causing statement: INSERT INTO "remote_asset_entity" ("name", "type", "created_at", "updated_at", "duration_in_seconds", "id", "checksum", "is_favorite", "owner_id", "local_date_time", "thumb_hash", "deleted_at", "live_photo_video_id", "visibility", "stack_id", "library_id") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT("id") DO UPDATE SET "name" = ?, "type" = ?, "created_at" = ?, "updated_at" = ?, "duration_in_seconds" = ?, "checksum" = ?, "is_favorite" = ?, "owner_id" = ?, "local_date_time" = ?, "thumb_hash" = ?, "deleted_at" = ?, "live_photo_video_id" = ?, "visibility" = ?, "stack_id" = ?, "library_id" = ?, parameters: IMG_20181001_181356.jpg, 1, 2018-10-01T18:13:55.000Z, 2025-07-08T10:49:16.292Z, 0, b52153a0-b7a7-4591-83c3-1afc196daf3a, IJBA50QYkXIWP48Y4pMoGeysPuc=, 0, 65994829-5a61-4859-9848-9a8fac39d7e7, 2018-10-01T20:13:55.000Z, rCgGBQCHp6mHCIXnaXaYiNCdGftr, 2025-10-01T04:41:47.141Z, null, 0, null, null, IMG_20181001_181356.jpg, 1, 2018-10-01T18:13:55.000Z, 2025-07-08T10:49:16.292Z, 0, IJBA50QYkXIWP48Y4pMoGeysPuc=, 0, 65994829-5a61-4859-9848-9a8fac39d7e7, 2018-10-01T20:13:55.000Z, rCgGBQCHp6mHCIXnaXaYiNCdGftr, 2025-10-01T04:41:47.141Z, null, 0, null, null ` For me this is a file that I used "replace with upload" on, if that might point to the solution. Running the SQL statement produces just one row: select "id", "originalFileName", "ownerId", "libraryId" from asset where checksum = decode('IJBA50QYkXIWP48Y4pMoGeysPuc=', 'base64'); id | originalFileName | ownerId | libraryId --------------------------------------+-------------------------+--------------------------------------+----------- b52153a0-b7a7-4591-83c3-1afc196daf3a | IMG_20181001_181356.jpg | 65994829-5a61-4859-9848-9a8fac39d7e7 | (1 row) As there is no actual violation of unique ids, I figured resetting DB would work. So deleted SQLite, logged out and in and resynced. That fixed the mobile DB, but this sure wasn't particularly user friendly. Question remains why it generated the insert statement instead of an update statement. Maybe to do with the "replace with upload" action? I'll test this functionality more and see if it breaks anything again.
Author
Owner

@Hinfty commented on GitHub (Oct 1, 2025):

@shenlong-tanwen got it, reproducible.

Steps:

  1. select asset to be rotated in mobile app, edit, crop, rotate as needed and save to gallery
  2. Rotated asset is auto-uploaded due to being in camera folder (upload enabled)
  3. Delete new rotated asset and empty trash
  4. Open old asset in browser, select "replace with upload" and replace with rotated asset from phone
  5. Open mobile app and wait for sync
  6. Sync fails due to incorrectly generated insert statement

Not sure if 2 and 3 are needed to trigger the bug

@Hinfty commented on GitHub (Oct 1, 2025): @shenlong-tanwen got it, reproducible. Steps: 1. select asset to be rotated in mobile app, edit, crop, rotate as needed and save to gallery 2. Rotated asset is auto-uploaded due to being in camera folder (upload enabled) 3. Delete new rotated asset and empty trash 4. Open old asset in browser, select "replace with upload" and replace with rotated asset from phone 5. Open mobile app and wait for sync 6. Sync fails due to incorrectly generated insert statement Not sure if 2 and 3 are needed to trigger the bug
Author
Owner

@abhishekgupta0511 commented on GitHub (Oct 2, 2025):

@abhishekgupta0511 from the command line on your server run

docker exec -it immich_postgres psql --dbname=immich --username=postgres

After that, you can run the query

select "id", "originalFileName", "ownerId", "libraryId" from asset where checksum = decode('0UIDkK+sfB4wXWEFQLv4MYQCzZI=', 'base64');

Thank you for guiding me.. below is the output..

immich=#
immich=# select "id", "originalFileName", "ownerId", "libraryId" from asset where checksum = decode('0UIDkK+sfB4wXWEFQLv4MYQCzZI=', 'base64');

              id                  | originalFileName |               ownerId                | libraryId 

--------------------------------------+------------------+--------------------------------------+-----------
6da39d05-8f4f-41c3-b103-b051bf74f761 | IMG_5801.MOV | f918d4e0-14f2-48a7-9611-38656bcb7fbc |
5ab17647-1962-47f8-a517-bd76947452e3 | IMG_5801.MOV | f918d4e0-14f2-48a7-9611-38656bcb7fbc |
f10de208-1e9b-4a66-b129-5dcd7dc4312a | IMG_5801.MOV | f918d4e0-14f2-48a7-9611-38656bcb7fbc |
5c56a18e-71ee-48f7-88ed-944147bf2942 | IMG_5801.MOV | f918d4e0-14f2-48a7-9611-38656bcb7fbc |
9b2eb48a-8cd1-472e-8e64-52782d77da2f | IMG_5801.MOV | f918d4e0-14f2-48a7-9611-38656bcb7fbc |
b47509b2-87b9-4e03-b058-1337201093dc | IMG_5801.MOV | f918d4e0-14f2-48a7-9611-38656bcb7fbc |
5f125867-bb84-4f61-a43d-6b09f354233c | IMG_5801.MOV | f918d4e0-14f2-48a7-9611-38656bcb7fbc |
a8d77b26-6bc0-42de-bf44-c504773b1c12 | IMG_5801.MOV | f918d4e0-14f2-48a7-9611-38656bcb7fbc |
9e16420d-d56a-4a8c-8efc-246b05f2e7d3 | IMG_5801.MOV | f918d4e0-14f2-48a7-9611-38656bcb7fbc |
68e26ba4-6668-4854-affd-6b0c34e436fb | IMG_5801.MOV | f918d4e0-14f2-48a7-9611-38656bcb7fbc |
(10 rows)

@abhishekgupta0511 commented on GitHub (Oct 2, 2025): > [@abhishekgupta0511](https://github.com/abhishekgupta0511) from the command line on your server run > > ``` > docker exec -it immich_postgres psql --dbname=immich --username=postgres > ``` > > After that, you can run the query > > ``` > select "id", "originalFileName", "ownerId", "libraryId" from asset where checksum = decode('0UIDkK+sfB4wXWEFQLv4MYQCzZI=', 'base64'); > ``` Thank you for guiding me.. below is the output.. immich=# immich=# select "id", "originalFileName", "ownerId", "libraryId" from asset where checksum = decode('0UIDkK+sfB4wXWEFQLv4MYQCzZI=', 'base64'); id | originalFileName | ownerId | libraryId --------------------------------------+------------------+--------------------------------------+----------- 6da39d05-8f4f-41c3-b103-b051bf74f761 | IMG_5801.MOV | f918d4e0-14f2-48a7-9611-38656bcb7fbc | 5ab17647-1962-47f8-a517-bd76947452e3 | IMG_5801.MOV | f918d4e0-14f2-48a7-9611-38656bcb7fbc | f10de208-1e9b-4a66-b129-5dcd7dc4312a | IMG_5801.MOV | f918d4e0-14f2-48a7-9611-38656bcb7fbc | 5c56a18e-71ee-48f7-88ed-944147bf2942 | IMG_5801.MOV | f918d4e0-14f2-48a7-9611-38656bcb7fbc | 9b2eb48a-8cd1-472e-8e64-52782d77da2f | IMG_5801.MOV | f918d4e0-14f2-48a7-9611-38656bcb7fbc | b47509b2-87b9-4e03-b058-1337201093dc | IMG_5801.MOV | f918d4e0-14f2-48a7-9611-38656bcb7fbc | 5f125867-bb84-4f61-a43d-6b09f354233c | IMG_5801.MOV | f918d4e0-14f2-48a7-9611-38656bcb7fbc | a8d77b26-6bc0-42de-bf44-c504773b1c12 | IMG_5801.MOV | f918d4e0-14f2-48a7-9611-38656bcb7fbc | 9e16420d-d56a-4a8c-8efc-246b05f2e7d3 | IMG_5801.MOV | f918d4e0-14f2-48a7-9611-38656bcb7fbc | 68e26ba4-6668-4854-affd-6b0c34e436fb | IMG_5801.MOV | f918d4e0-14f2-48a7-9611-38656bcb7fbc | (10 rows)
Author
Owner

@dshelley66 commented on GitHub (Oct 2, 2025):

This is also happening on Android 1.143.1

@dshelley66 commented on GitHub (Oct 2, 2025): This is also happening on Android 1.143.1
Author
Owner

@abhishekgupta0511 commented on GitHub (Oct 2, 2025):

Please fix this issue.. this client issue is becoming a serious concern...

This is also an issue on v2.0

@abhishekgupta0511 commented on GitHub (Oct 2, 2025): Please fix this issue.. this client issue is becoming a serious concern... This is also an issue on v2.0
Author
Owner

@masymase commented on GitHub (Oct 8, 2025):

I am getting the same or similar error except I'm getting a FOREIGN KEY constraint failed:

Error: updateAlbumToAssetsV1 - user

SqliteException(787): while executing statement, FOREIGN KEY constraint failed, constraint failed (code 787)
  Causing statement: INSERT INTO "remote_album_asset_entity" ("asset_id", "album_id") VALUES (?, ?) ON CONFLICT("asset_id", "album_id") DO NOTHING, parameters: 964c552e-1c89-4214-bc68-ce2f8762e8bb, 392c471d-1dba-4c32-9657-d65eb3b30730

Stack trace:
package:sqlite3/src/implementation/exception.dart 87                               throwException
package:sqlite3/src/implementation/statement.dart 109                              StatementImplementation._execute
package:sqlite3/src/implementation/statement.dart 289                              StatementImplementation.executeWith
package:sqlite3/src/statement.dart 81                                              CommonPreparedStatement.execute
package:drift/src/sqlite3/database.dart 131                                        Sqlite3Delegate.runBatchSync
package:drift/native.dart 373                                                      _NativeDelegate.runBatched.<fn>
dart:async/future.dart 315                                                         new Future.sync
package:drift/native.dart 373                                                      _NativeDelegate.runBatched
package:drift/src/runtime/executor/helpers/engines.dart 128                        _BaseExecutor.runBatched.<fn>
package:drift/src/runtime/executor/helpers/engines.dart 62                         _BaseExecutor._synchronized
package:drift/src/runtime/executor/helpers/engines.dart 122                        _BaseExecutor.runBatched
package:drift/src/remote/server_impl.dart 170                                      ServerImplementation._runBatched
package:drift/src/remote/communication.dart 165                                    DriftCommunication.setRequestHandler.<fn>
===== asynchronous gap ===========================
package:drift/src/remote/communication.dart 113                                    DriftCommunication.request
package:drift/src/remote/client_impl.dart 84                                       _BaseExecutor.runBatched
package:drift/src/runtime/api/batch.dart 215                                       Batch._runWith
package:drift/src/runtime/api/batch.dart 199                                       Batch._commit
package:immich_mobile/infrastructure/repositories/sync_stream.repository.dart 347  SyncStreamRepository.updateAlbumToAssetsV1
package:immich_mobile/domain/services/sync_stream.service.dart 67                  SyncStreamService._processBatch
package:immich_mobile/domain/services/sync_stream.service.dart 58                  SyncStreamService._handleEvents
package:immich_mobile/infrastructure/repositories/sync_api.repository.dart 105     SyncApiRepository.streamChanges
package:immich_mobile/domain/services/sync_stream.service.dart 30                  SyncStreamService.sync
package:immich_mobile/utils/isolate.dart 57                                        runInIsolateGentle.<fn>.<fn>
package:immich_mobile/utils/isolate.dart 36                                        runInIsolateGentle.<fn>
package:worker_manager/src/worker/worker_io.dart 106                               WorkerImpl._anotherIsolate.<fn>

Backup also works for me if I disable the new timeline in advanced settings.

Android app version: 2.0.1 build.3021
Server version: 2.0.1

@masymase commented on GitHub (Oct 8, 2025): I am getting the same or similar error except I'm getting a `FOREIGN KEY constraint failed`: ``` Error: updateAlbumToAssetsV1 - user SqliteException(787): while executing statement, FOREIGN KEY constraint failed, constraint failed (code 787) Causing statement: INSERT INTO "remote_album_asset_entity" ("asset_id", "album_id") VALUES (?, ?) ON CONFLICT("asset_id", "album_id") DO NOTHING, parameters: 964c552e-1c89-4214-bc68-ce2f8762e8bb, 392c471d-1dba-4c32-9657-d65eb3b30730 Stack trace: package:sqlite3/src/implementation/exception.dart 87 throwException package:sqlite3/src/implementation/statement.dart 109 StatementImplementation._execute package:sqlite3/src/implementation/statement.dart 289 StatementImplementation.executeWith package:sqlite3/src/statement.dart 81 CommonPreparedStatement.execute package:drift/src/sqlite3/database.dart 131 Sqlite3Delegate.runBatchSync package:drift/native.dart 373 _NativeDelegate.runBatched.<fn> dart:async/future.dart 315 new Future.sync package:drift/native.dart 373 _NativeDelegate.runBatched package:drift/src/runtime/executor/helpers/engines.dart 128 _BaseExecutor.runBatched.<fn> package:drift/src/runtime/executor/helpers/engines.dart 62 _BaseExecutor._synchronized package:drift/src/runtime/executor/helpers/engines.dart 122 _BaseExecutor.runBatched package:drift/src/remote/server_impl.dart 170 ServerImplementation._runBatched package:drift/src/remote/communication.dart 165 DriftCommunication.setRequestHandler.<fn> ===== asynchronous gap =========================== package:drift/src/remote/communication.dart 113 DriftCommunication.request package:drift/src/remote/client_impl.dart 84 _BaseExecutor.runBatched package:drift/src/runtime/api/batch.dart 215 Batch._runWith package:drift/src/runtime/api/batch.dart 199 Batch._commit package:immich_mobile/infrastructure/repositories/sync_stream.repository.dart 347 SyncStreamRepository.updateAlbumToAssetsV1 package:immich_mobile/domain/services/sync_stream.service.dart 67 SyncStreamService._processBatch package:immich_mobile/domain/services/sync_stream.service.dart 58 SyncStreamService._handleEvents package:immich_mobile/infrastructure/repositories/sync_api.repository.dart 105 SyncApiRepository.streamChanges package:immich_mobile/domain/services/sync_stream.service.dart 30 SyncStreamService.sync package:immich_mobile/utils/isolate.dart 57 runInIsolateGentle.<fn>.<fn> package:immich_mobile/utils/isolate.dart 36 runInIsolateGentle.<fn> package:worker_manager/src/worker/worker_io.dart 106 WorkerImpl._anotherIsolate.<fn> ``` Backup also works for me if I disable the new timeline in advanced settings. Android app version: 2.0.1 build.3021 Server version: 2.0.1
Author
Owner

@EdanBrooke commented on GitHub (Oct 10, 2025):

Just to chime in - I'm having the same issue on iOS and reverting to the old timeline does made syncing work again for me too.

PS congrats on v2 👏

@EdanBrooke commented on GitHub (Oct 10, 2025): Just to chime in - I'm having the same issue on iOS and reverting to the old timeline does made syncing work again for me too. PS congrats on v2 👏
Author
Owner

@rmarkus commented on GitHub (Oct 11, 2025):

same pb here with Server = 2.0.1 and App on Android = 2.0.1

@shenlong-tanwen got it, reproducible.

Steps:

  1. select asset to be rotated in mobile app, edit, crop, rotate as needed and save to gallery
  2. Rotated asset is auto-uploaded due to being in camera folder (upload enabled)
  3. Delete new rotated asset and empty trash
  4. Open old asset in browser, select "replace with upload" and replace with rotated asset from phone
  5. Open mobile app and wait for sync
  6. Sync fails due to incorrectly generated insert statement

Not sure if 2 and 3 are needed to trigger the bug

And indeed, I also have done a rotate & replace with upload of a photo some days earlier.

is there a fix available by deleting something in the SQL database (I am using postgresql)?

@rmarkus commented on GitHub (Oct 11, 2025): same pb here with Server = 2.0.1 and App on Android = 2.0.1 > [@shenlong-tanwen](https://github.com/shenlong-tanwen) got it, reproducible. > > Steps: > > 1. select asset to be rotated in mobile app, edit, crop, rotate as needed and save to gallery > 2. Rotated asset is auto-uploaded due to being in camera folder (upload enabled) > 3. Delete new rotated asset and empty trash > 4. Open old asset in browser, select "replace with upload" and replace with rotated asset from phone > 5. Open mobile app and wait for sync > 6. Sync fails due to incorrectly generated insert statement > > Not sure if 2 and 3 are needed to trigger the bug And indeed, I also have done a rotate & replace with upload of a photo some days earlier. is there a fix available by deleting something in the SQL database (I am using postgresql)?
Author
Owner

@Hinfty commented on GitHub (Oct 11, 2025):

same pb here with Server = 2.0.1 and App on Android = 2.0.1
(...)
And indeed, I also have done a rotate & replace with upload of a photo some days earlier.

is there a fix available by deleting something in the SQL database (I am using postgresql)?

To come back to my error description, I understand its clear that this will cause the duplication error, if the mobile db does not sync between the steps.
But imho this shows that the workflow to rotate uploaded assets does not work out for us. Ideally, we wouldn't be downloading amd uploading the file at all. Especially seeing how date and location are cleared and need to be reset in this process.

@Hinfty commented on GitHub (Oct 11, 2025): > same pb here with Server = 2.0.1 and App on Android = 2.0.1 (...) > And indeed, I also have done a rotate & replace with upload of a photo some days earlier. > > is there a fix available by deleting something in the SQL database (I am using postgresql)? To come back to my error description, I understand its clear that this will cause the duplication error, if the mobile db does not sync between the steps. But imho this shows that the workflow to rotate uploaded assets does not work out for us. Ideally, we wouldn't be downloading amd uploading the file at all. Especially seeing how date and location are cleared and need to be reset in this process.
Author
Owner

@DaJansenGit commented on GitHub (Oct 14, 2025):

Having the same issue after a fresh portainer install of server and application and migration from google photos via immich-go. Did no cropping or any foto editing. Just named some persons. Deactivating new timeline feature as suggested fixes the issue.

Server = 2.0.1 and Android 2.0.1.

@DaJansenGit commented on GitHub (Oct 14, 2025): Having the same issue after a fresh portainer install of server and application and migration from google photos via immich-go. Did no cropping or any foto editing. Just named some persons. Deactivating new timeline feature as suggested fixes the issue. Server = 2.0.1 and Android 2.0.1.
Author
Owner

@SecretAgentOne commented on GitHub (Oct 15, 2025):

I experienced the same failure using Server 2.0.1, android app version 2.0.1 and worked around the issue by disabling the new timeline.

@SecretAgentOne commented on GitHub (Oct 15, 2025): I experienced the same failure using Server 2.0.1, android app version 2.0.1 and worked around the issue by disabling the new timeline.
Author
Owner

@EdanBrooke commented on GitHub (Oct 15, 2025):

Having the same issue after a fresh portainer install of server and application and migration from google photos via immich-go. Did no cropping or any foto editing. Just named some persons. Deactivating new timeline feature as suggested fixes the issue.

Server = 2.0.1 and Android 2.0.1.

For information I also imported my Google Takeout using Immich-Go. Could this bear any relevance?

@EdanBrooke commented on GitHub (Oct 15, 2025): > Having the same issue after a fresh portainer install of server and application and migration from google photos via immich-go. Did no cropping or any foto editing. Just named some persons. Deactivating new timeline feature as suggested fixes the issue. > > Server = 2.0.1 and Android 2.0.1. For information I also imported my Google Takeout using Immich-Go. Could this bear any relevance?
Author
Owner

@Techtony96 commented on GitHub (Oct 16, 2025):

I also am facing this SQL error on iOS, just started using Immich on 2.0.1 (now 2.1) and I also imported using immich-go my Google Photos.

@Techtony96 commented on GitHub (Oct 16, 2025): I also am facing this SQL error on iOS, just started using Immich on 2.0.1 (now 2.1) and I also imported using immich-go my Google Photos.
Author
Owner

@Qhilm commented on GitHub (Oct 19, 2025):

It appears that "replace with upload" triggers this issue. I just did this twice today for the first time ever and I am not hitting this error message.

@Qhilm commented on GitHub (Oct 19, 2025): It appears that "replace with upload" triggers this issue. I just did this twice today for the first time ever and I am not hitting this error message.
Author
Owner

@rmburg commented on GitHub (Oct 20, 2025):

+1 for "replace with upload"

I auto-uploaded an asset from my phone, downloaded it via the web interface and "replace with upload"-ed it with a rotated version. Now sync on my phone is broken with the same SQL error as OP.

I'm on Android/v2.1.0.

@rmburg commented on GitHub (Oct 20, 2025): +1 for "replace with upload" I auto-uploaded an asset from my phone, downloaded it via the web interface and "replace with upload"-ed it with a rotated version. Now sync on my phone is broken with the same SQL error as OP. I'm on Android/v2.1.0.
Author
Owner

@LTe commented on GitHub (Oct 21, 2025):

Having the same issue after a fresh portainer install of server and application and migration from google photos via immich-go. Did no cropping or any foto editing. Just named some persons. Deactivating new timeline feature as suggested fixes the issue.
Server = 2.0.1 and Android 2.0.1.

For information I also imported my Google Takeout using Immich-Go. Could this bear any relevance?

Same here, this happens after import from Google Takeout using Immich-Go.

  1. Install immich on my iPhone
  2. Create backup of my pictures
  3. Do Immich-Go import (it recognize that some assets are the same).
  4. After that sync is not working because of SqliteException(2067): while executing statement, UNIQUE constraint failed: remote_asset_entity.owner_id, remote_asset_entity.checksum
@LTe commented on GitHub (Oct 21, 2025): > > Having the same issue after a fresh portainer install of server and application and migration from google photos via immich-go. Did no cropping or any foto editing. Just named some persons. Deactivating new timeline feature as suggested fixes the issue. > > Server = 2.0.1 and Android 2.0.1. > > For information I also imported my Google Takeout using Immich-Go. Could this bear any relevance? Same here, this happens after import from Google Takeout using Immich-Go. 1. Install immich on my iPhone 2. Create backup of my pictures 3. Do Immich-Go import (it recognize that some assets are the same). 4. After that sync is not working because of `SqliteException(2067): while executing statement, UNIQUE constraint failed: remote_asset_entity.owner_id, remote_asset_entity.checksum`
Author
Owner

@mikeygrier commented on GitHub (Oct 23, 2025):

my wife and i have had this problem since the switch from the old timeline to the new timeline. pretty much every day since, i purge dupes in the DB to get sync to work again using the sql below (i don't advise doing this, im sure it's eating disk space or losing track of extra assets / polluting tables), but I am just kicking the can down the road until this bug gets fixed at which point I'll likely rebuild my immich server

Server=2.1.0; Android=2.1.0

delete from asset
where ctid in (
  select ctid
  from (
    select ctid,
           row_number() over (
             partition by "ownerId", "checksum"
             order by "localDateTime"
           ) as rn
    from asset
  ) t
  where t.rn > 1
)
@mikeygrier commented on GitHub (Oct 23, 2025): my wife and i have had this problem since the switch from the old timeline to the new timeline. pretty much every day since, i purge dupes in the DB to get sync to work again using the sql below (i don't advise doing this, im sure it's eating disk space or losing track of extra assets / polluting tables), but I am just kicking the can down the road until this bug gets fixed at which point I'll likely rebuild my immich server Server=2.1.0; Android=2.1.0 ```sql delete from asset where ctid in ( select ctid from ( select ctid, row_number() over ( partition by "ownerId", "checksum" order by "localDateTime" ) as rn from asset ) t where t.rn > 1 ) ```
Author
Owner

@Qhilm commented on GitHub (Oct 24, 2025):

So, let's say I want to be a little more surgical and fix the issue for one specific image, does anyone has a suggestion for me?

20180201-IMG_1986.jpg is the original image, which I replaced with upload 20180201-072150-IMG_1986.jxl (same RAW file, but reworked and exported as jxl hdr this time).

I don't mind deleting any file starting with 20180201-IMG_1986 because they all refer to the old picture, which was replaced.

I even deleted the old picture from the immich trash, but that did not help.

SqliteException(2067): while executing statement, UNIQUE constraint failed: remote_asset_entity.owner_id, remote_asset_entity.checksum, constraint failed (code 2067)
Causing statement: INSERT INTO "remote_asset_entity" ("name", "type", "created_at", "updated_at", "duration_in_seconds", "id", "checksum", "is_favorite", "owner_id", "local_date_time", "thumb_hash", "deleted_at", "live_photo_video_id", "visibility", "stack_id", "library_id") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT("id") DO UPDATE SET "name" = ?, "type" = ?, "created_at" = ?, "updated_at" = ?, "duration_in_seconds" = ?, "checksum" = ?, "is_favorite" = ?, "owner_id" = ?, "local_date_time" = ?, "thumb_hash" = ?, "deleted_at" = ?, "live_photo_video_id" = ?, "visibility" = ?, "stack_id" = ?, "library_id" = ?, parameters: 20180201-IMG_1986.jpg, 1, 2018-02-01T07:21:50.620Z, 2018-02-01T07:21:50.000Z, 0, 9a320499-179f-4297-8758-795c2e6524f7, l0F5HldmNZSWo0AE4Z/ACx0StvY=, 0, 3fed80d5-f7ad-44e6-b4f7-143d7f0a415e, 2018-02-01T07:21:50.620Z, null, 2025-10-19T11:10:15.648Z, null, 0, null, null, 20180201-IMG_1986.jpg, 1, 2018-02-01T07:21:50.620Z, 2018-02-01T07:21:50.000Z, 0, l0F5HldmNZSWo0AE4Z/ACx0StvY=, 0, 3fed80d5-f7ad-44e6-b4f7-143d7f0a415e, 2018-02-01T07:21:50.620Z, null, 2025-10-19T11:10:15.648Z, null, 0, null, null

@Qhilm commented on GitHub (Oct 24, 2025): So, let's say I want to be a little more surgical and fix the issue for one specific image, does anyone has a suggestion for me? `20180201-IMG_1986.jpg` is the original image, which I replaced with upload `20180201-072150-IMG_1986.jxl` (same RAW file, but reworked and exported as jxl hdr this time). I don't mind deleting any file starting with `20180201-IMG_1986` because they all refer to the old picture, which was replaced. I even deleted the old picture from the immich trash, but that did not help. >SqliteException(2067): while executing statement, UNIQUE constraint failed: remote_asset_entity.owner_id, remote_asset_entity.checksum, constraint failed (code 2067) > Causing statement: INSERT INTO "remote_asset_entity" ("name", "type", "created_at", "updated_at", "duration_in_seconds", "id", "checksum", "is_favorite", "owner_id", "local_date_time", "thumb_hash", "deleted_at", "live_photo_video_id", "visibility", "stack_id", "library_id") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT("id") DO UPDATE SET "name" = ?, "type" = ?, "created_at" = ?, "updated_at" = ?, "duration_in_seconds" = ?, "checksum" = ?, "is_favorite" = ?, "owner_id" = ?, "local_date_time" = ?, "thumb_hash" = ?, "deleted_at" = ?, "live_photo_video_id" = ?, "visibility" = ?, "stack_id" = ?, "library_id" = ?, parameters: 20180201-IMG_1986.jpg, 1, 2018-02-01T07:21:50.620Z, 2018-02-01T07:21:50.000Z, 0, 9a320499-179f-4297-8758-795c2e6524f7, l0F5HldmNZSWo0AE4Z/ACx0StvY=, 0, 3fed80d5-f7ad-44e6-b4f7-143d7f0a415e, 2018-02-01T07:21:50.620Z, null, 2025-10-19T11:10:15.648Z, null, 0, null, null, 20180201-IMG_1986.jpg, 1, 2018-02-01T07:21:50.620Z, 2018-02-01T07:21:50.000Z, 0, l0F5HldmNZSWo0AE4Z/ACx0StvY=, 0, 3fed80d5-f7ad-44e6-b4f7-143d7f0a415e, 2018-02-01T07:21:50.620Z, null, 2025-10-19T11:10:15.648Z, null, 0, null, null
Author
Owner

@Qhilm commented on GitHub (Oct 28, 2025):

I would really appreciate some guidance here, I can't sync a single picture any more from my phone to the Immich instance. I even tried to fully delete the old asset (the one replaced with the upload) from trash, that did not help.

Should I restore the sql DB to before the time when I did "replace with upload"? This is going to throw an error I guess, since the original asset is now deleted?

I would prefer not to blindly run some script on the DB, rather make it asset specific, as I only have 3 pictures causing this issue.

@Qhilm commented on GitHub (Oct 28, 2025): I would really appreciate some guidance here, I can't sync a single picture any more from my phone to the Immich instance. I even tried to fully delete the old asset (the one replaced with the upload) from trash, that did not help. Should I restore the sql DB to before the time when I did "replace with upload"? This is going to throw an error I guess, since the original asset is now deleted? I would prefer not to blindly run some script on the DB, rather make it asset specific, as I only have 3 pictures causing this issue.
Author
Owner

@mikeygrier commented on GitHub (Oct 28, 2025):

if you wanted some confidence using the SQL i posted above, you could do a select to first see the rows that it'd impact:

select "ownerId", "checksum", "originalFileName" from asset
where ctid in (
  select ctid
  from (
    select ctid,
           row_number() over (
             partition by "ownerId", "checksum"
             order by "localDateTime"
           ) as rn
    from asset
  ) t
  where t.rn > 1
);

the sql is simple: if there's a dupe on checksum and ownerId, get rid of all instances except the first one. note: if the checksum matches these are binary identical copies, not resizes or similar images based on content. im not even sure how the database can get like this, you'd think there'd be parity between postgres unique constraints and sqlite. i suppose i could/should dig into and fix this bug myself but i can't even replicate it consistently. im hoping someone with more knowledge about the immich db has an aha moment soon.

@mikeygrier commented on GitHub (Oct 28, 2025): if you wanted some confidence using the SQL i posted above, you could do a select to first see the rows that it'd impact: ```sql select "ownerId", "checksum", "originalFileName" from asset where ctid in ( select ctid from ( select ctid, row_number() over ( partition by "ownerId", "checksum" order by "localDateTime" ) as rn from asset ) t where t.rn > 1 ); ``` the sql is simple: if there's a dupe on checksum and ownerId, get rid of all instances except the first one. note: if the checksum matches these are binary identical copies, not resizes or similar images based on content. im not even sure how the database can get like this, you'd think there'd be parity between postgres unique constraints and sqlite. i suppose i could/should dig into and fix this bug myself but i can't even replicate it consistently. im hoping someone with more knowledge about the immich db has an aha moment soon.
Author
Owner

@Qhilm commented on GitHub (Oct 29, 2025):

Thanks. I decided to try basics first, and uninstall/reinstall the app. And it somehow worked. No idea why it worked for me while it did not for others, but good I tried, I had almost discarded the possibility this could work.

@Qhilm commented on GitHub (Oct 29, 2025): Thanks. I decided to try basics first, and uninstall/reinstall the app. And it somehow worked. No idea why it worked for me while it did not for others, but good I tried, I had almost discarded the possibility this could work.
Author
Owner

@mikeygrier commented on GitHub (Oct 29, 2025):

actually, thinking about this, the dupes happened intermittently in the old timeline too they just weren't fatal errors on the client side in the old timeline implementation. i remember having 20+ copies of the same picture sometimes.

@mikeygrier commented on GitHub (Oct 29, 2025): actually, thinking about this, the dupes happened intermittently in the old timeline too they just weren't fatal errors on the client side in the old timeline implementation. i remember having 20+ copies of the same picture sometimes.
Author
Owner

@Worly commented on GitHub (Oct 29, 2025):

I have the same problem. Logging out and back in fixes the problem, but the problem returns after a couple of days.

@Worly commented on GitHub (Oct 29, 2025): I have the same problem. Logging out and back in fixes the problem, but the problem returns after a couple of days.
Author
Owner

@alextran1502 commented on GitHub (Oct 29, 2025):

@Worly Did you use feature such as "Replace with upload", or recently using immich-go?

Image
@alextran1502 commented on GitHub (Oct 29, 2025): @Worly Did you use feature such as "Replace with upload", or recently using `immich-go`? <img width="212" height="733" alt="Image" src="https://github.com/user-attachments/assets/35765975-9f46-453a-8d51-f32e8a8c144f" />
Author
Owner

@Worly commented on GitHub (Oct 30, 2025):

@alextran1502 I did not use "Replace with upload", but I did use immich-go to upload pretty much all of the assets I currently have, including the one that is causing the error.

@Worly commented on GitHub (Oct 30, 2025): @alextran1502 I did **not** use "Replace with upload", but I did use `immich-go` to upload pretty much all of the assets I currently have, including the one that is causing the error.
Author
Owner

@akaivola commented on GitHub (Oct 31, 2025):

This issue is still occurring with v2.2.0.

  • Have used immich-go,
  • have not used Replace with upload

EDIT:
v2.2.2 did not fix this

  • fixed by Uninstall and reinstall of the iOS app, v2.2.2
@akaivola commented on GitHub (Oct 31, 2025): This issue is still occurring with `v2.2.0`. - Have used `immich-go`, - have not used `Replace with upload` EDIT: v2.2.2 did not fix this - *fixed* by Uninstall and reinstall of the iOS app, v2.2.2
Author
Owner

@tomas-lejdung commented on GitHub (Nov 1, 2025):

I am also getting this issue on ios. Server version 2.2.1 and app 2.2.0. I cannot view any of the uploaded assets, and only my local photos shows up with the icon for ”not uploaded”. My locked folder is also empty. When using the web version everything works as intended.

SqliteException(787): while executing statement, FOREIGN KEY constraint failed, constraint failed (code 787) Causing statement: INSERT INTO "memory_asset_entity" ("asset_id", "memory_id") VALUES (?, ?) ON CONFLICT("asset_id", "memory_id") DO NOTHING, parameters: 707555c6-d035-4927-b5fb-f414c28f782c, c9bde5af-2dfb-4e17-8dff-96325be42f3f

package:sqlite3/src/implementation/exception.dart 87 throwException package:sqlite3/src/implementation/statement.dart 109 StatementImplementation._execute package:sqlite3/src/implementation/statement.dart 289 StatementImplementation.executeWith package:sqlite3/src/statement.dart 81 CommonPreparedStatement.execute package:drift/src/sqlite3/database.dart 131 Sqlite3Delegate.runBatchSync package:drift/native.dart 373 _NativeDelegate.runBatched.<fn> dart:async/future.dart 315 new Future.sync package:drift/native.dart 373 _NativeDelegate.runBatched package:drift/src/runtime/executor/helpers/engines.dart 128 _BaseExecutor.runBatched.<fn> package:drift/src/runtime/executor/helpers/engines.dart 62 _BaseExecutor._synchronized package:drift/src/runtime/executor/helpers/engines.dart 122 _BaseExecutor.runBatched package:drift/src/remote/server_impl.dart 170 ServerImplementation._runBatched package:drift/src/remote/communication.dart 165 DriftCommunication.setRequestHandler.<fn> ===== asynchronous gap =========================== package:drift/src/remote/communication.dart 113 DriftCommunication.request package:drift/src/remote/client_impl.dart 84 _BaseExecutor.runBatched package:drift/src/runtime/api/batch.dart 215 Batch._runWith package:drift/src/runtime/api/batch.dart 199 Batch._commit package:immich_mobile/infrastructure/repositories/sync_stream.repository.dart 408 SyncStreamRepository.updateMemoryAssetsV1 package:immich_mobile/domain/services/sync_stream.service.dart 67 SyncStreamService._processBatch package:immich_mobile/domain/services/sync_stream.service.dart 48 SyncStreamService._handleEvents package:immich_mobile/infrastructure/repositories/sync_api.repository.dart 110 SyncApiRepository.streamChanges package:immich_mobile/domain/services/sync_stream.service.dart 30 SyncStreamService.sync package:immich_mobile/utils/isolate.dart 58 runInIsolateGentle.<fn>.<fn> package:immich_mobile/utils/isolate.dart 37 runInIsolateGentle.<fn> package:worker_manager/src/worker/worker_io.dart 106 WorkerImpl._anotherIsolate.<fn>

@tomas-lejdung commented on GitHub (Nov 1, 2025): I am also getting this issue on ios. Server version 2.2.1 and app 2.2.0. I cannot view any of the uploaded assets, and only my local photos shows up with the icon for ”not uploaded”. My locked folder is also empty. When using the web version everything works as intended. `SqliteException(787): while executing statement, FOREIGN KEY constraint failed, constraint failed (code 787) Causing statement: INSERT INTO "memory_asset_entity" ("asset_id", "memory_id") VALUES (?, ?) ON CONFLICT("asset_id", "memory_id") DO NOTHING, parameters: 707555c6-d035-4927-b5fb-f414c28f782c, c9bde5af-2dfb-4e17-8dff-96325be42f3f ` `package:sqlite3/src/implementation/exception.dart 87 throwException package:sqlite3/src/implementation/statement.dart 109 StatementImplementation._execute package:sqlite3/src/implementation/statement.dart 289 StatementImplementation.executeWith package:sqlite3/src/statement.dart 81 CommonPreparedStatement.execute package:drift/src/sqlite3/database.dart 131 Sqlite3Delegate.runBatchSync package:drift/native.dart 373 _NativeDelegate.runBatched.<fn> dart:async/future.dart 315 new Future.sync package:drift/native.dart 373 _NativeDelegate.runBatched package:drift/src/runtime/executor/helpers/engines.dart 128 _BaseExecutor.runBatched.<fn> package:drift/src/runtime/executor/helpers/engines.dart 62 _BaseExecutor._synchronized package:drift/src/runtime/executor/helpers/engines.dart 122 _BaseExecutor.runBatched package:drift/src/remote/server_impl.dart 170 ServerImplementation._runBatched package:drift/src/remote/communication.dart 165 DriftCommunication.setRequestHandler.<fn> ===== asynchronous gap =========================== package:drift/src/remote/communication.dart 113 DriftCommunication.request package:drift/src/remote/client_impl.dart 84 _BaseExecutor.runBatched package:drift/src/runtime/api/batch.dart 215 Batch._runWith package:drift/src/runtime/api/batch.dart 199 Batch._commit package:immich_mobile/infrastructure/repositories/sync_stream.repository.dart 408 SyncStreamRepository.updateMemoryAssetsV1 package:immich_mobile/domain/services/sync_stream.service.dart 67 SyncStreamService._processBatch package:immich_mobile/domain/services/sync_stream.service.dart 48 SyncStreamService._handleEvents package:immich_mobile/infrastructure/repositories/sync_api.repository.dart 110 SyncApiRepository.streamChanges package:immich_mobile/domain/services/sync_stream.service.dart 30 SyncStreamService.sync package:immich_mobile/utils/isolate.dart 58 runInIsolateGentle.<fn>.<fn> package:immich_mobile/utils/isolate.dart 37 runInIsolateGentle.<fn> package:worker_manager/src/worker/worker_io.dart 106 WorkerImpl._anotherIsolate.<fn> `
Author
Owner

@AndrewMcAwesome commented on GitHub (Nov 2, 2025):

also having this issue on android, everything seems to work as expected with the old timeline, but the phone app is basically completely non functional when using the new timeline

@AndrewMcAwesome commented on GitHub (Nov 2, 2025): also having this issue on android, everything seems to work as expected with the old timeline, but the phone app is basically completely non functional when using the new timeline
Author
Owner

@beyertom commented on GitHub (Nov 2, 2025):

chiming in, my wife has the same issue with newest server and android app (both 2.2.1):

SqliteException(787): while executing statement, FOREIGN KEY constraint failed, constraint failed (code 787)
  Causing statement: INSERT INTO "remote_album_asset_entity" ("asset_id", "album_id") VALUES (?, ?) ON CONFLICT("asset_id", "album_id") DO NOTHING, parameters: b7847f5c-7d91-41f5-919e-7c8fef0e1929, e6459f7a-9420-463f-b450-8835d2821cbe
@beyertom commented on GitHub (Nov 2, 2025): chiming in, my wife has the same issue with newest server and android app (both 2.2.1): ``` SqliteException(787): while executing statement, FOREIGN KEY constraint failed, constraint failed (code 787) Causing statement: INSERT INTO "remote_album_asset_entity" ("asset_id", "album_id") VALUES (?, ?) ON CONFLICT("asset_id", "album_id") DO NOTHING, parameters: b7847f5c-7d91-41f5-919e-7c8fef0e1929, e6459f7a-9420-463f-b450-8835d2821cbe ```
Author
Owner

@polomani commented on GitHub (Nov 5, 2025):

Having this issue after I uploaded the last bits of my photos using immich-go (this was part of my celebration for the stable release of immich 😅 )

@polomani commented on GitHub (Nov 5, 2025): Having this issue after I uploaded the last bits of my photos using immich-go (this was part of my celebration for the stable release of immich 😅 )
Author
Owner

@dhlavaty commented on GitHub (Nov 6, 2025):

This started appearing after I upgraded to v2.2.3 (both server and iOS app). Previous versions worked fine I think.

( iOS 18.7.1 )

2025-11-06 12:36:53.178202 | info     | HashService          | Starting hashing of assets |
2025-11-06 12:36:51.169402 | severe   | IsolateLogger        | Error in runInIsolateGentle  for remote-sync | SqliteException(2067): while executing statement, UNIQUE constraint failed: remote_asset_entity.owner_id, remote_asset_entity.checksum, constraint failed (code 2067)
  Causing statement: INSERT INTO "remote_asset_entity" ("name", "type", "created_at", "updated_at", "duration_in_seconds", "id", "checksum", "is_favorite", "owner_id", "local_date_time", "thumb_hash", "deleted_at", "live_photo_video_id", "visibility", "stack_id", "library_id") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT("id") DO UPDATE SET "name" = ?, "type" = ?, "created_at" = ?, "updated_at" = ?, "duration_in_seconds" = ?, "checksum" = ?, "is_favorite" = ?, "owner_id" = ?, "local_date_time" = ?, "thumb_hash" = ?, "deleted_at" = ?, "live_photo_video_id" = ?, "visibility" = ?, "stack_id" = ?, "library_id" = ?, parameters: 20220612_095530.jpg, 1, 2022-06-12T08:55:30.000Z, 2022-06-12T07:55:30.000Z, 0, f07aba74-a6fe-47e0-b4fb-9ff60dcdc452, ZsfsHtu6/yrtvuVt2WXHZOjXQrI=, 0, 80217e23-d83e-4848-a0cd-d4978908f124, 2022-06-12T09:55:30.000Z, 6gcGDYJlZlmLpGefafdmuamAsAoY, 2025-11-01T19:26:45.072Z, null, 0, null, null, 20220612_095530.jpg, 1, 2022-06-12T08:55:30.000Z, 2022-06-12T07:55:30.000Z, 0, ZsfsHtu6/yrtvuVt2WXHZOjXQrI=, 0, 80217e23-d83e-4848-a0cd-d4978908f124, 2022-06-12T09:55:30.000Z, 6gcGDYJlZlmLpGefafdmuamAsAoY, 2025-11-01T19:26:45.072Z, null, 0, null, null |
package:sqlite3/src/implementation/exception.dart 87                               throwException
package:sqlite3/src/implementation/statement.dart 109                              StatementImplementation._execute
package:sqlite3/src/implementation/statement.dart 289                              StatementImplementation.executeWith
package:sqlite3/src/statement.dart 81                                              CommonPreparedStatement.execute
package:drift/src/sqlite3/database.dart 131                                        Sqlite3Delegate.runBatchSync
package:drift/native.dart 373                                                      _NativeDelegate.runBatched.<fn>
dart:async/future.dart 315                                                         new Future.sync
package:drift/native.dart 373                                                      _NativeDelegate.runBatched
package:drift/src/runtime/executor/helpers/engines.dart 128                        _BaseExecutor.runBatched.<fn>
package:drift/src/runtime/executor/helpers/engines.dart 62                         _BaseExecutor._synchronized
package:drift/src/runtime/executor/helpers/engines.dart 122                        _BaseExecutor.runBatched
package:drift/src/remote/server_impl.dart 170                                      ServerImplementation._runBatched
package:drift/src/remote/communication.dart 165                                    DriftCommunication.setRequestHandler.<fn>
===== asynchronous gap ===========================
package:drift/src/remote/communication.dart 113                                    DriftCommunication.request
package:drift/src/remote/client_impl.dart 84                                       _BaseExecutor.runBatched
package:drift/src/runtime/api/batch.dart 215                                       Batch._runWith
package:drift/src/runtime/api/batch.dart 199                                       Batch._commit
package:immich_mobile/infrastructure/repositories/sync_stream.repository.dart 179  SyncStreamRepository.updateAssetsV1
package:immich_mobile/domain/services/sync_stream.service.dart 67                  SyncStreamService._processBatch
package:immich_mobile/domain/services/sync_stream.service.dart 58                  SyncStreamService._handleEvents
package:immich_mobile/infrastructure/repositories/sync_api.repository.dart 105     SyncApiRepository.streamChanges
package:immich_mobile/domain/services/sync_stream.service.dart 30                  SyncStreamService.sync
package:immich_mobile/utils/isolate.dart 58                                        runInIsolateGentle.<fn>.<fn>
package:immich_mobile/utils/isolate.dart 37                                        runInIsolateGentle.<fn>
package:worker_manager/src/worker/worker_io.dart 106                               WorkerImpl._anotherIsolate.<fn>

2025-11-06 12:36:51.168556 | severe   | DriftSyncStreamRepository | Error: updateAssetsV1 - user | SqliteException(2067): while executing statement, UNIQUE constraint failed: remote_asset_entity.owner_id, remote_asset_entity.checksum, constraint failed (code 2067)
  Causing statement: INSERT INTO "remote_asset_entity" ("name", "type", "created_at", "updated_at", "duration_in_seconds", "id", "checksum", "is_favorite", "owner_id", "local_date_time", "thumb_hash", "deleted_at", "live_photo_video_id", "visibility", "stack_id", "library_id") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT("id") DO UPDATE SET "name" = ?, "type" = ?, "created_at" = ?, "updated_at" = ?, "duration_in_seconds" = ?, "checksum" = ?, "is_favorite" = ?, "owner_id" = ?, "local_date_time" = ?, "thumb_hash" = ?, "deleted_at" = ?, "live_photo_video_id" = ?, "visibility" = ?, "stack_id" = ?, "library_id" = ?, parameters: 20220612_095530.jpg, 1, 2022-06-12T08:55:30.000Z, 2022-06-12T07:55:30.000Z, 0, f07aba74-a6fe-47e0-b4fb-9ff60dcdc452, ZsfsHtu6/yrtvuVt2WXHZOjXQrI=, 0, 80217e23-d83e-4848-a0cd-d4978908f124, 2022-06-12T09:55:30.000Z, 6gcGDYJlZlmLpGefafdmuamAsAoY, 2025-11-01T19:26:45.072Z, null, 0, null, null, 20220612_095530.jpg, 1, 2022-06-12T08:55:30.000Z, 2022-06-12T07:55:30.000Z, 0, ZsfsHtu6/yrtvuVt2WXHZOjXQrI=, 0, 80217e23-d83e-4848-a0cd-d4978908f124, 2022-06-12T09:55:30.000Z, 6gcGDYJlZlmLpGefafdmuamAsAoY, 2025-11-01T19:26:45.072Z, null, 0, null, null |
package:sqlite3/src/implementation/exception.dart 87                               throwException
package:sqlite3/src/implementation/statement.dart 109                              StatementImplementation._execute
package:sqlite3/src/implementation/statement.dart 289                              StatementImplementation.executeWith
package:sqlite3/src/statement.dart 81                                              CommonPreparedStatement.execute
package:drift/src/sqlite3/database.dart 131                                        Sqlite3Delegate.runBatchSync
package:drift/native.dart 373                                                      _NativeDelegate.runBatched.<fn>
dart:async/future.dart 315                                                         new Future.sync
package:drift/native.dart 373                                                      _NativeDelegate.runBatched
package:drift/src/runtime/executor/helpers/engines.dart 128                        _BaseExecutor.runBatched.<fn>
package:drift/src/runtime/executor/helpers/engines.dart 62                         _BaseExecutor._synchronized
package:drift/src/runtime/executor/helpers/engines.dart 122                        _BaseExecutor.runBatched
package:drift/src/remote/server_impl.dart 170                                      ServerImplementation._runBatched
package:drift/src/remote/communication.dart 165                                    DriftCommunication.setRequestHandler.<fn>
===== asynchronous gap ===========================
package:drift/src/remote/communication.dart 113                                    DriftCommunication.request
package:drift/src/remote/client_impl.dart 84                                       _BaseExecutor.runBatched
package:drift/src/runtime/api/batch.dart 215                                       Batch._runWith
package:drift/src/runtime/api/batch.dart 199                                       Batch._commit
package:immich_mobile/infrastructure/repositories/sync_stream.repository.dart 179  SyncStreamRepository.updateAssetsV1
package:immich_mobile/domain/services/sync_stream.service.dart 67                  SyncStreamService._processBatch
package:immich_mobile/domain/services/sync_stream.service.dart 58                  SyncStreamService._handleEvents
package:immich_mobile/infrastructure/repositories/sync_api.repository.dart 105     SyncApiRepository.streamChanges
package:immich_mobile/domain/services/sync_stream.service.dart 30                  SyncStreamService.sync
package:immich_mobile/utils/isolate.dart 58                                        runInIsolateGentle.<fn>.<fn>
package:immich_mobile/utils/isolate.dart 37                                        runInIsolateGentle.<fn>
package:worker_manager/src/worker/worker_io.dart 106                               WorkerImpl._anotherIsolate.<fn>

2025-11-06 12:36:49.518611 | info     | DeviceSyncService    | Device sync took - 41ms |
2025-11-06 12:36:49.476983 | info     | SyncStreamService    | Remote sync request for user |

EDIT: added logs

@dhlavaty commented on GitHub (Nov 6, 2025): This started appearing after I upgraded to v2.2.3 (both server and iOS app). Previous versions worked fine I think. ( iOS 18.7.1 ) ``` 2025-11-06 12:36:53.178202 | info | HashService | Starting hashing of assets | 2025-11-06 12:36:51.169402 | severe | IsolateLogger | Error in runInIsolateGentle for remote-sync | SqliteException(2067): while executing statement, UNIQUE constraint failed: remote_asset_entity.owner_id, remote_asset_entity.checksum, constraint failed (code 2067) Causing statement: INSERT INTO "remote_asset_entity" ("name", "type", "created_at", "updated_at", "duration_in_seconds", "id", "checksum", "is_favorite", "owner_id", "local_date_time", "thumb_hash", "deleted_at", "live_photo_video_id", "visibility", "stack_id", "library_id") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT("id") DO UPDATE SET "name" = ?, "type" = ?, "created_at" = ?, "updated_at" = ?, "duration_in_seconds" = ?, "checksum" = ?, "is_favorite" = ?, "owner_id" = ?, "local_date_time" = ?, "thumb_hash" = ?, "deleted_at" = ?, "live_photo_video_id" = ?, "visibility" = ?, "stack_id" = ?, "library_id" = ?, parameters: 20220612_095530.jpg, 1, 2022-06-12T08:55:30.000Z, 2022-06-12T07:55:30.000Z, 0, f07aba74-a6fe-47e0-b4fb-9ff60dcdc452, ZsfsHtu6/yrtvuVt2WXHZOjXQrI=, 0, 80217e23-d83e-4848-a0cd-d4978908f124, 2022-06-12T09:55:30.000Z, 6gcGDYJlZlmLpGefafdmuamAsAoY, 2025-11-01T19:26:45.072Z, null, 0, null, null, 20220612_095530.jpg, 1, 2022-06-12T08:55:30.000Z, 2022-06-12T07:55:30.000Z, 0, ZsfsHtu6/yrtvuVt2WXHZOjXQrI=, 0, 80217e23-d83e-4848-a0cd-d4978908f124, 2022-06-12T09:55:30.000Z, 6gcGDYJlZlmLpGefafdmuamAsAoY, 2025-11-01T19:26:45.072Z, null, 0, null, null | package:sqlite3/src/implementation/exception.dart 87 throwException package:sqlite3/src/implementation/statement.dart 109 StatementImplementation._execute package:sqlite3/src/implementation/statement.dart 289 StatementImplementation.executeWith package:sqlite3/src/statement.dart 81 CommonPreparedStatement.execute package:drift/src/sqlite3/database.dart 131 Sqlite3Delegate.runBatchSync package:drift/native.dart 373 _NativeDelegate.runBatched.<fn> dart:async/future.dart 315 new Future.sync package:drift/native.dart 373 _NativeDelegate.runBatched package:drift/src/runtime/executor/helpers/engines.dart 128 _BaseExecutor.runBatched.<fn> package:drift/src/runtime/executor/helpers/engines.dart 62 _BaseExecutor._synchronized package:drift/src/runtime/executor/helpers/engines.dart 122 _BaseExecutor.runBatched package:drift/src/remote/server_impl.dart 170 ServerImplementation._runBatched package:drift/src/remote/communication.dart 165 DriftCommunication.setRequestHandler.<fn> ===== asynchronous gap =========================== package:drift/src/remote/communication.dart 113 DriftCommunication.request package:drift/src/remote/client_impl.dart 84 _BaseExecutor.runBatched package:drift/src/runtime/api/batch.dart 215 Batch._runWith package:drift/src/runtime/api/batch.dart 199 Batch._commit package:immich_mobile/infrastructure/repositories/sync_stream.repository.dart 179 SyncStreamRepository.updateAssetsV1 package:immich_mobile/domain/services/sync_stream.service.dart 67 SyncStreamService._processBatch package:immich_mobile/domain/services/sync_stream.service.dart 58 SyncStreamService._handleEvents package:immich_mobile/infrastructure/repositories/sync_api.repository.dart 105 SyncApiRepository.streamChanges package:immich_mobile/domain/services/sync_stream.service.dart 30 SyncStreamService.sync package:immich_mobile/utils/isolate.dart 58 runInIsolateGentle.<fn>.<fn> package:immich_mobile/utils/isolate.dart 37 runInIsolateGentle.<fn> package:worker_manager/src/worker/worker_io.dart 106 WorkerImpl._anotherIsolate.<fn> 2025-11-06 12:36:51.168556 | severe | DriftSyncStreamRepository | Error: updateAssetsV1 - user | SqliteException(2067): while executing statement, UNIQUE constraint failed: remote_asset_entity.owner_id, remote_asset_entity.checksum, constraint failed (code 2067) Causing statement: INSERT INTO "remote_asset_entity" ("name", "type", "created_at", "updated_at", "duration_in_seconds", "id", "checksum", "is_favorite", "owner_id", "local_date_time", "thumb_hash", "deleted_at", "live_photo_video_id", "visibility", "stack_id", "library_id") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT("id") DO UPDATE SET "name" = ?, "type" = ?, "created_at" = ?, "updated_at" = ?, "duration_in_seconds" = ?, "checksum" = ?, "is_favorite" = ?, "owner_id" = ?, "local_date_time" = ?, "thumb_hash" = ?, "deleted_at" = ?, "live_photo_video_id" = ?, "visibility" = ?, "stack_id" = ?, "library_id" = ?, parameters: 20220612_095530.jpg, 1, 2022-06-12T08:55:30.000Z, 2022-06-12T07:55:30.000Z, 0, f07aba74-a6fe-47e0-b4fb-9ff60dcdc452, ZsfsHtu6/yrtvuVt2WXHZOjXQrI=, 0, 80217e23-d83e-4848-a0cd-d4978908f124, 2022-06-12T09:55:30.000Z, 6gcGDYJlZlmLpGefafdmuamAsAoY, 2025-11-01T19:26:45.072Z, null, 0, null, null, 20220612_095530.jpg, 1, 2022-06-12T08:55:30.000Z, 2022-06-12T07:55:30.000Z, 0, ZsfsHtu6/yrtvuVt2WXHZOjXQrI=, 0, 80217e23-d83e-4848-a0cd-d4978908f124, 2022-06-12T09:55:30.000Z, 6gcGDYJlZlmLpGefafdmuamAsAoY, 2025-11-01T19:26:45.072Z, null, 0, null, null | package:sqlite3/src/implementation/exception.dart 87 throwException package:sqlite3/src/implementation/statement.dart 109 StatementImplementation._execute package:sqlite3/src/implementation/statement.dart 289 StatementImplementation.executeWith package:sqlite3/src/statement.dart 81 CommonPreparedStatement.execute package:drift/src/sqlite3/database.dart 131 Sqlite3Delegate.runBatchSync package:drift/native.dart 373 _NativeDelegate.runBatched.<fn> dart:async/future.dart 315 new Future.sync package:drift/native.dart 373 _NativeDelegate.runBatched package:drift/src/runtime/executor/helpers/engines.dart 128 _BaseExecutor.runBatched.<fn> package:drift/src/runtime/executor/helpers/engines.dart 62 _BaseExecutor._synchronized package:drift/src/runtime/executor/helpers/engines.dart 122 _BaseExecutor.runBatched package:drift/src/remote/server_impl.dart 170 ServerImplementation._runBatched package:drift/src/remote/communication.dart 165 DriftCommunication.setRequestHandler.<fn> ===== asynchronous gap =========================== package:drift/src/remote/communication.dart 113 DriftCommunication.request package:drift/src/remote/client_impl.dart 84 _BaseExecutor.runBatched package:drift/src/runtime/api/batch.dart 215 Batch._runWith package:drift/src/runtime/api/batch.dart 199 Batch._commit package:immich_mobile/infrastructure/repositories/sync_stream.repository.dart 179 SyncStreamRepository.updateAssetsV1 package:immich_mobile/domain/services/sync_stream.service.dart 67 SyncStreamService._processBatch package:immich_mobile/domain/services/sync_stream.service.dart 58 SyncStreamService._handleEvents package:immich_mobile/infrastructure/repositories/sync_api.repository.dart 105 SyncApiRepository.streamChanges package:immich_mobile/domain/services/sync_stream.service.dart 30 SyncStreamService.sync package:immich_mobile/utils/isolate.dart 58 runInIsolateGentle.<fn>.<fn> package:immich_mobile/utils/isolate.dart 37 runInIsolateGentle.<fn> package:worker_manager/src/worker/worker_io.dart 106 WorkerImpl._anotherIsolate.<fn> 2025-11-06 12:36:49.518611 | info | DeviceSyncService | Device sync took - 41ms | 2025-11-06 12:36:49.476983 | info | SyncStreamService | Remote sync request for user | ``` EDIT: added logs
Author
Owner

@mikekuzak commented on GitHub (Nov 6, 2025):

Try disabling Advanced -> New Timeline. Restart the App. Go back reenable New Timeline, Restart App. This worked for me, no errors in the App logs anymore. Work on Android for me.

@mikekuzak commented on GitHub (Nov 6, 2025): Try disabling Advanced -> New Timeline. Restart the App. Go back reenable New Timeline, Restart App. This worked for me, no errors in the App logs anymore. Work on Android for me.
Author
Owner

@dhlavaty commented on GitHub (Nov 6, 2025):

@mikekuzak > Wow, yes, that helped. 🥇

EDIT: But I've lost all selections ( selected albums ) in Backup. :-(

@dhlavaty commented on GitHub (Nov 6, 2025): @mikekuzak > Wow, yes, that helped. 🥇 EDIT: But I've lost all selections ( selected albums ) in Backup. :-(
Author
Owner

@beyertom commented on GitHub (Nov 7, 2025):

Try disabling Advanced -> New Timeline. Restart the App. Go back reenable New Timeline, Restart App. This worked for me, no errors in the App logs anymore.

I tried this, didnt work for me. Still the same issue and error in the logs.

I found another issue, probably linked to this error:

All Albums (shared and owned) show they have 0 items.

@beyertom commented on GitHub (Nov 7, 2025): > Try disabling Advanced -> New Timeline. Restart the App. Go back reenable New Timeline, Restart App. This worked for me, no errors in the App logs anymore. I tried this, didnt work for me. Still the same issue and error in the logs. I found another issue, probably linked to this error: All Albums (shared and owned) show they have 0 items.
Author
Owner

@hch2904 commented on GitHub (Nov 7, 2025):

Try disabling Advanced -> New Timeline. Restart the App. Go back reenable New Timeline, Restart App. This worked for me, no errors in the App logs anymore.

I tried this and I can say this workaround works.

Thank you @mikekuzak

@hch2904 commented on GitHub (Nov 7, 2025): > Try disabling Advanced -> New Timeline. Restart the App. Go back reenable New Timeline, Restart App. This worked for me, no errors in the App logs anymore. I tried this and I can say this workaround works. Thank you @mikekuzak
Author
Owner

@AndrewMcAwesome commented on GitHub (Nov 7, 2025):

I realize the issue is marked as IOS but the work around is sill not working for me on android with docker version 2.2.3 and most recent android app

@AndrewMcAwesome commented on GitHub (Nov 7, 2025): I realize the issue is marked as IOS but the work around is sill not working for me on android with docker version 2.2.3 and most recent android app
Author
Owner

@justinmklam commented on GitHub (Nov 10, 2025):

Try disabling Advanced -> New Timeline. Restart the App. Go back reenable New Timeline, Restart App. This worked for me, no errors in the App logs anymore. Work on Android for me.

This also fixed the issue for me, but like @dhlavaty mentioned, it also resets your phone's backup configuration so you'll need to reselect which albums you want to sync. It did successfully rehash all the files on my phones so it didn't upload any duplicates, but this process can take some time depending on how many photos you have and how fast your phone's processor is.

@justinmklam commented on GitHub (Nov 10, 2025): > Try disabling Advanced -> New Timeline. Restart the App. Go back reenable New Timeline, Restart App. This worked for me, no errors in the App logs anymore. Work on Android for me. This also fixed the issue for me, but like @dhlavaty mentioned, it also resets your phone's backup configuration so you'll need to reselect which albums you want to sync. It did successfully rehash all the files on my phones so it didn't upload any duplicates, but this process can take some time depending on how many photos you have and how fast your phone's processor is.
Author
Owner

@veryaner commented on GitHub (Nov 12, 2025):

Try disabling Advanced -> New Timeline. Restart the App. Go back reenable New Timeline, Restart App. This worked for me, no errors in the App logs anymore. Work on Android for me.

Tried this o Android and also works my backup started again. Thanks!

@veryaner commented on GitHub (Nov 12, 2025): > Try disabling Advanced -> New Timeline. Restart the App. Go back reenable New Timeline, Restart App. This worked for me, no errors in the App logs anymore. Work on Android for me. Tried this o Android and also works my backup started again. Thanks!
Author
Owner

@beyertom commented on GitHub (Nov 30, 2025):

The problem is still open for me. Tried again the above mentioned fix (disabling & enabling timeline) but no luck.

@beyertom commented on GitHub (Nov 30, 2025): The problem is still open for me. Tried again the above mentioned fix (disabling & enabling timeline) but no luck.
Author
Owner

@ufgkirk commented on GitHub (Dec 12, 2025):

I experienced this same problem this week on the client app version 2.3.0 build 236 on iOS. I had used the "Replace Upload" feature from PC to replace an upload my phone originally uploaded. This caused the app to experience the same "SqliteException(2067): while executing statement, UNIQUE constraint failed" error that everyone else is reporting.

My Immich app on my iPad, which uploads to the same library, was working fine. I had only replaced that single upload from my iPhone, so clearly this was caused by replacing that upload.

I tried the suggestion of toggling off the New Timeline feature, and that seemed to fix the issue, all my photos taken since the bug are now uploaded. I was then able to subsequently re-enable the "New Timeline" feature and take a screenshot, which uploaded too. So simply toggling the feature off and on fixed the problem for me.

@ufgkirk commented on GitHub (Dec 12, 2025): I experienced this same problem this week on the client app version 2.3.0 build 236 on iOS. I had used the "Replace Upload" feature from PC to replace an upload my phone originally uploaded. This caused the app to experience the same "SqliteException(2067): while executing statement, UNIQUE constraint failed" error that everyone else is reporting. My Immich app on my iPad, which uploads to the same library, was working fine. I had only replaced that single upload from my iPhone, so clearly this was caused by replacing that upload. I tried the suggestion of toggling off the New Timeline feature, and that seemed to fix the issue, all my photos taken since the bug are now uploaded. I was then able to subsequently re-enable the "New Timeline" feature and take a screenshot, which uploaded too. So simply toggling the feature off and on fixed the problem for me.
Author
Owner

@mateiuli commented on GitHub (Jan 18, 2026):

I have encountered the same problem on server version 2.4.1 with Android App 2.4.1 build.3030.

I managed to work around it by going into the web interface, selected "Filename" search in the search bar and entered the file name from the logs in the mobile app ... parameters: IMG_20181001_181356.jpg, 1, ....

First I downloaded the photos, then moved to trash, then deleted permanently from trash. After that it resume working. I didn't have to disable/enable the new timeline as suggested above.

@mateiuli commented on GitHub (Jan 18, 2026): I have encountered the same problem on server version 2.4.1 with Android App 2.4.1 build.3030. I managed to work around it by going into the web interface, selected "Filename" search in the search bar and entered the file name from the logs in the mobile app ``` ... parameters: IMG_20181001_181356.jpg, 1, ...```. First I downloaded the photos, then moved to trash, then deleted permanently from trash. After that it resume working. I didn't have to disable/enable the new timeline as suggested above.
Author
Owner

@schobernoise commented on GitHub (Feb 4, 2026):

I have encountered the same problem on server version 2.4.1 with Android App 2.4.1 build.3030.

I managed to work around it by going into the web interface, selected "Filename" search in the search bar and entered the file name from the logs in the mobile app ... parameters: IMG_20181001_181356.jpg, 1, ....

First I downloaded the photos, then moved to trash, then deleted permanently from trash. After that it resume working. I didn't have to disable/enable the new timeline as suggested above.

Can confirm, worked for me too!

@schobernoise commented on GitHub (Feb 4, 2026): > I have encountered the same problem on server version 2.4.1 with Android App 2.4.1 build.3030. > > I managed to work around it by going into the web interface, selected "Filename" search in the search bar and entered the file name from the logs in the mobile app ` ... parameters: IMG_20181001_181356.jpg, 1, ...`. > > First I downloaded the photos, then moved to trash, then deleted permanently from trash. After that it resume working. I didn't have to disable/enable the new timeline as suggested above. Can confirm, worked for me too!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#7385