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
: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:Anyone?
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.
thank you
previously executed migration is missingTypically 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)?
@Sergey Katsubo here they are. It has 2 cycles.
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.
And one more to check DB schema: current vs expected
UPD. Oops, this command most likely will fail because immich_server is crash looping / restarting.
Here are the outputs of the first two docker commands. The last one, as expected failed because the container is restarting.
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:
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?
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 missingvs 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?
It assumes network cnetwork and Postgres user/pass/dbname postgres/postgres/immich2 -
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
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.
2. Stop Immich, start fatrace and Immich in the same terminal/session to have joint logs.
3. Post logs from one restart cycle (between "docker compose up" and "Killing api process")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.
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.
Nice, if recreating the container solved the issue for you folks, then I guess it's resolved 🎉
@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.
v2.1.0 works fine.
v2.2.0 and onwards fails
@Gritador then I suggest to debug with fatrace as outlined above.
Another option: to try in a fresh VM.
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.
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.
@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.
@Gritador @reinoudb could you describe your platform/hardware and post system info such as
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
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: 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!
This is the output of your commands on 1 of the nodes, the other ones are using the same setup: 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!