I
Immich•3w ago
Gritador

Migrations failed: Error: corrupted migrations: previously executed migration 1758705774125-CreateA

I was running immich with docker v2.1.0. Everything was running smooth. I tried to upgrade the docker image to v2.2.0 and I got this error. I've attached my compose and logs files.
25 Replies
Immich
Immich•3w ago
:wave: Hey @Gritador, Thanks for reaching out to us. Please carefully read this message and follow the recommended actions. This will help us be more effective in our support effort and leave more time for building Immich :immich:. References - Container Logs: docker compose logs docs - Container Status: docker ps -a docs - Reverse Proxy: https://immich.app/docs/administration/reverse-proxy - Code Formatting https://support.discord.com/hc/en-us/articles/210298617-Markdown-Text-101-Chat-Formatting-Bold-Italic-Underline#h_01GY0DAKGXDEHE263BCAYEGFJA Checklist I have... 1. :ballot_box_with_check: verified I'm on the latest release(note that mobile app releases may take some time). 2. :ballot_box_with_check: read applicable release notes. 3. :ballot_box_with_check: reviewed the FAQs for known issues. 4. :ballot_box_with_check: reviewed Github for known issues. 5. :ballot_box_with_check: tried accessing Immich via local ip (without a custom reverse proxy). 6. :ballot_box_with_check: uploaded the relevant information (see below). 7. :ballot_box_with_check: tried an incognito window, disabled extensions, cleared mobile app cache, logged out and back in, different browsers, etc. as applicable (an item can be marked as "complete" by reacting with the appropriate number) Information In order to be able to effectively help you, we need you to provide clear information to show what the problem is. The exact details needed vary per case, but here is a list of things to consider: - Your docker-compose.yml and .env files. - Logs from all the containers and their status (see above). - All the troubleshooting steps you've tried so far. - Any recent changes you've made to Immich or your system. - Details about your system (both software/OS and hardware). - Details about your storage (filesystems, type of disks, output of commands like fdisk -l and df -h). - The version of the Immich server, mobile app, and other relevant pieces. - Any other information that you think might be relevant. Please paste files and logs with proper code formatting, and especially avoid blurry screenshots. Without the right information we can't work out what the problem is. Help us help you ;) If this ticket can be closed you can use the /close command, and re-open it later if needed. Successfully submitted, a tag has been added to inform contributors. :white_check_mark:
Gritador
GritadorOP•3w ago
Anyone?
reinoudb
reinoudb•3w ago
I don't have a solution for you but im experiencing the same issue. I found https://github.com/immich-app/immich/discussions/23587 but this also doesn't have a solution but might but worth following.
Immich
Immich•3w ago
[Discussion] killing api process (immich-app/immich#23587)
Gritador
GritadorOP•3w ago
thank you
Sergey Katsubo
Sergey Katsubo•3w ago
previously executed migration is missing
Typically means that you have upgraded successfully and ran newer version of immich-server, so it upgraded ("migration") the database schema. Then supposedly you started previous/older version of immich-server. So it complains about newer "migrations" that older version is not aware of. @Gritador could you post full log from one restart cycle (between two "Killing api process" lines)?
Gritador
GritadorOP•3w ago
@Sergey Katsubo here they are. It has 2 cycles.
Sergey Katsubo
Sergey Katsubo•3w ago
Thanks Could you run these commands? To make sure that sql migration files are present in the docker image. And to check their state in the database.
docker run --rm --entrypoint bash ghcr.io/immich-app/immich-server:v2.2.0 -c "find server/dist/schema/migrations -name '*.js' -ls"
docker exec -ti immich_postgres psql -U postgres -Ppager=no -Pexpanded=auto -d immich -c 'table version_history' -c 'table kysely_migrations'
docker run --rm --entrypoint bash ghcr.io/immich-app/immich-server:v2.2.0 -c "find server/dist/schema/migrations -name '*.js' -ls"
docker exec -ti immich_postgres psql -U postgres -Ppager=no -Pexpanded=auto -d immich -c 'table version_history' -c 'table kysely_migrations'
And one more to check DB schema: current vs expected
docker exec --user root immich_server sh -c 'DB_URL=postgres://$DB_USERNAME:$DB_PASSWORD@database:5432/$DB_DATABASE_NAME node /usr/src/app/server/dist/bin/migrations.js debug && cat migrations.sql'
docker exec --user root immich_server sh -c 'DB_URL=postgres://$DB_USERNAME:$DB_PASSWORD@database:5432/$DB_DATABASE_NAME node /usr/src/app/server/dist/bin/migrations.js debug && cat migrations.sql'
UPD. Oops, this command most likely will fail because immich_server is crash looping / restarting.
Gritador
GritadorOP•3w ago
Here are the outputs of the first two docker commands. The last one, as expected failed because the container is restarting.
Sergey Katsubo
Sergey Katsubo•3w ago
Interesting. The list of migration files (js) in the Immich docker image v2.2.0 looks normal. The list of migrations in the database (kysely_migrations) looks normal too. Based on the log: Initializing Immich v2.2.0 so it should have 1758705774125-CreateAssetOCRTable... If this was an isolated case, I would suspect container corruption. But we have 3 reports already (two here on Discord and one on Github). So this isn't a random corruption. 1. To eliminate the possibility of container corruption:
docker compose down immich-server
docker compose up -d
docker inspect immich_server
docker compose down immich-server
docker compose up -d
docker inspect immich_server
2. What is your platform / OS? 3. You don't use ML features, right? 4. Upgrade history has a couple of version changes/downgrades separated by ~12 seconds. Do you have an idea what was happening at that time?
createdAt | version
-------------------------------+---------
2025-10-17 05:35:11.566874+00 | 2.1.0
2025-10-17 05:35:23.361591+00 | 2.0.1
...
2025-11-04 22:47:16.902861+00 | 2.1.0
2025-11-04 22:47:29.295361+00 | 2.0.1

2025-11-05 12:45:26.370301+00 | 2.2.0
createdAt | version
-------------------------------+---------
2025-10-17 05:35:11.566874+00 | 2.1.0
2025-10-17 05:35:23.361591+00 | 2.0.1
...
2025-11-04 22:47:16.902861+00 | 2.1.0
2025-11-04 22:47:29.295361+00 | 2.0.1

2025-11-05 12:45:26.370301+00 | 2.2.0
5. Log timestamp 11/04/2025, 7:11:50 PM in
11/04/2025, 7:11:50 PM ERROR [Microservices:DatabaseRepository] Migrations failed: Error: corrupted migrations: previously executed migration 1758705774125-CreateAssetOCRTable is missing
vs upgrade history 2025-11-05 12:45:26.370301+00 | 2.2.0 Looks like the DB changes of 2.2.0 were already applied on Nov 4. But 2.2.0 appears in upgrade history only on Nov 5. Puzzling... What is your server timezone, btw? 6. Have you performed any backup-restore already? 7. Could you try another command to check DB schema?
docker run --rm --network cnetwork --entrypoint bash ghcr.io/immich-app/immich-server:v2.2.0 -c 'DB_URL=postgres://postgres:postgres@database:5432/immich node /usr/src/app/server/dist/bin/migrations.js debug && cat migrations.sql'
docker run --rm --network cnetwork --entrypoint bash ghcr.io/immich-app/immich-server:v2.2.0 -c 'DB_URL=postgres://postgres:postgres@database:5432/immich node /usr/src/app/server/dist/bin/migrations.js debug && cat migrations.sql'
It assumes network cnetwork and Postgres user/pass/dbname postgres/postgres/immich
Gritador
GritadorOP•3w ago
2 -
ubuntu server 24.04gamariel@ubuntuserver01:~/containers/immich$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 24.04.3 LTS
Release: 24.04
Codename: noble
ubuntu server 24.04gamariel@ubuntuserver01:~/containers/immich$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 24.04.3 LTS
Release: 24.04
Codename: noble
3 - yes 4 - Probably I upgraded, did not work, then I downgraded? 5 - Europe/Lisbon (probably from upgrading downgrading stuff) 6 - From immich backup or from my own container backups? 7 - gamariel@ubuntuserver01:~/containers/immich$ docker run --rm --network cnetwork --entrypoint bash ghcr.io/immich-app/immich-server:v2.2.0 -c 'DB_URL=postgres://postgres:postgres@database:5432/immich node /usr/src/app/server/dist/bin/migrations.js debug && cat migrations.sql' Wrote migrations.sql -- UP
Sergey Katsubo
Sergey Katsubo•3w ago
Thank you Re 6 - backup-restore. Just wondering if there was any restore (that potentially could somehow mess things up). Re 7 - schema. So there is no schema drift if comparing actual DB to the v2.2.0 image. This just confirms once more that DB schema is fully upgraded to v2.2. So the docker image and the database look fine. Next I suggest to focus on the container. Let's check if Immich can find the migration file CreateAssetOCRTable.js during start-up. 1. Install fatrace package.
apt get update && apt-get install fatrace
apt get update && apt-get install fatrace
2. Stop Immich, start fatrace and Immich in the same terminal/session to have joint logs.
docker compose down immich-server
sudo fatrace -t -C immich | grep -v node_modules &
docker compose up --timestamps immich-server
docker compose down immich-server
sudo fatrace -t -C immich | grep -v node_modules &
docker compose up --timestamps immich-server
3. Post logs from one restart cycle (between "docker compose up" and "Killing api process")
Gritador
GritadorOP•3w ago
Re-Re-6: probably After letting it run for almost a minute there is no Killing api process. If you want I can continue to help the debugging. If not, I can just restart immich from scratch and be more careful with the upgrades/downgrades stuff.
reinoudb
reinoudb•3w ago
I don't know if the OP was able to solve it but I recreated the container (which i thought had done before) and let it run for a while and it seems to work now. Not sure what the cause was.
Sergey Katsubo
Sergey Katsubo•3w ago
Nice, if recreating the container solved the issue for you folks, then I guess it's resolved 🎉
Gritador
GritadorOP•3w ago
@Sergey Katsubo hello. I've clean everything. Started from scratch (rm -rf the entire folder) Pruned the volumes, images,even rmi all images from immich. The problem still persists and i've updated the compose to v2.2.3. Changed the network because it was something I was. going to do anyway.
Gritador
GritadorOP•3w ago
v2.1.0 works fine. v2.2.0 and onwards fails
Sergey Katsubo
Sergey Katsubo•3w ago
@Gritador then I suggest to debug with fatrace as outlined above. Another option: to try in a fresh VM.
Gritador
GritadorOP•3w ago
Something is clearly wrong with my server. Just installed the same compose in my macbook pro and the migration ran fime. Thanks for the help and your time.
Sergey Katsubo
Sergey Katsubo•3w ago
Let us know if you discover the root cause / difference. I've thought about maybe a docker engine bug. You can also inspect file system inside a running container or in overlayfs folder.
Gritador
GritadorOP•3w ago
@Sergey Katsubo I did not find anything. I went even further and re-installed ubuntu server and with everything completly empty it breaks with the same errors. I'm gonna go with v2.1.0 that works.
Sergey Katsubo
Sergey Katsubo•3w ago
@Gritador @reinoudb could you describe your platform/hardware and post system info such as
uname -a
lsb_release -a
sudo docker info
uname -a
lsb_release -a
sudo docker info
Gritador
GritadorOP•3w ago
uname -a Linux ubuntu-server01 6.8.0-87-generic #88-Ubuntu SMP PREEMPT_DYNAMIC Sat Oct 11 09:28:41 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 24.04.3 LTS Release: 24.04 Codename: noble sudo docker info Client: Docker Engine - Community Version: 28.5.2 Context: default Debug Mode: false Plugins: buildx: Docker Buildx (Docker Inc.) Version: v0.29.1 Path: /usr/libexec/docker/cli-plugins/docker-buildx compose: Docker Compose (Docker Inc.) Version: v2.40.3 Path: /usr/libexec/docker/cli-plugins/docker-compose Server: Containers: 20 Running: 20 Paused: 0 Stopped: 0 Images: 29 Server Version: 28.5.2 Storage Driver: overlay2 Backing Filesystem: btrfs Supports d_type: true Using metacopy: false Native Overlay Diff: true userxattr: false Logging Driver: json-file Cgroup Driver: systemd Cgroup Version: 2 Plugins: Volume: local Network: bridge host ipvlan macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog CDI spec directories: /etc/cdi /var/run/cdi Swarm: inactive Runtimes: io.containerd.runc.v2 runc Default Runtime: runc Init Binary: docker-init containerd version: 442cb34bda9a6a0fed82a2ca7cade05c5c749582 runc version: v1.3.3-0-gd842d771 init version: de40ad0 Security Options: apparmor seccomp Profile: builtin cgroupns Kernel Version: 6.8.0-87-generic Operating System: Ubuntu 24.04.3 LTS OSType: linux Architecture: x86_64 CPUs: 4 Total Memory: 23.35GiB Name: ubuntu-server01 ID: 22932e5b-250a-41b8-9344-ed3dd7d9378c Docker Root Dir: /mnt/docker-data Debug Mode: false Experimental: false Insecure Registries: ::1/128 127.0.0.0/8 Live Restore Enabled: false hp elitedesk 6th gen Intel with 24gb ram
reinoudb
reinoudb•2w ago
Hey, im running a k8s setup so i will provide you with the relevant info. Its running on k3s (v1.33.4) with alpine (3.22) as host OS.
This is the output of your commands on 1 of the nodes, the other ones are using the same setup:
Linux k3s-alpine-1 6.12.55-0-lts #1-Alpine SMP PREEMPT_DYNAMIC 2025-10-27 09:36:08 x86_64 Linux
k3s-alpine-1:~# lsb_release -a
No LSB modules are available.
Distributor ID: Alpine
Description: Alpine Linux v3.22
Release: 3.22.2
Codename: n/a
k3s-alpine-1:~#
Linux k3s-alpine-1 6.12.55-0-lts #1-Alpine SMP PREEMPT_DYNAMIC 2025-10-27 09:36:08 x86_64 Linux
k3s-alpine-1:~# lsb_release -a
No LSB modules are available.
Distributor ID: Alpine
Description: Alpine Linux v3.22
Release: 3.22.2
Codename: n/a
k3s-alpine-1:~#
And i think its using containerd but im not sure how to get usefull info from it to provide to you. I hope this helps, if you want additional info pls let me know!

Did you find this page helpful?