umami: [Docker] Upgrade from 2.4.1 to 2.5.0 fail

Describe the Bug

I updated the docker image to the latest version and got a prisma migrate deploy command error after container boot.

Database

MySQL

Relevant log output

umami-umami-1  | yarn run v1.22.19
umami-umami-1  | $ npm-run-all check-db update-tracker start-server
umami-umami-1  | $ node scripts/check-db.js
umami-umami-1  | ✓ DATABASE_URL is defined.
umami-umami-1  | ✓ Database connection successful.
umami-umami-1  | ✓ Database version check successful.
umami-umami-1  | Error: P3009
umami-umami-1  | 
umami-umami-1  | 
umami-umami-1  | migrate found failed migrations in the target database, new migrations will not be applied. Read more about how to resolve migration issues in a production database: https://pris.ly/d/migrate-resolve
umami-umami-1  | The `03_metric_performance_index` migration started at 2023-08-18 06:55:19.444 UTC failed
umami-umami-1  | 
umami-umami-1  | 
umami-umami-1  | 
umami-umami-1  | 
umami-umami-1  | 
umami-umami-1  | 
umami-umami-1  | error Command failed with exit code 1.
umami-umami-1  | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
umami-umami-1  | ERROR: "check-db" exited with 1.
umami-umami-1  | error Command failed with exit code 1.

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

Docker

Temp fix:

UPDATE _prisma_migrations SET `finished_at` = CURRENT_TIMESTAMP WHERE `migration_name` = '03_metric_performance_index';

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 28 (2 by maintainers)

Most upvoted comments

I have been facing the same issue since yesterday while trying to upgrade from 2.2.0 to 2.17.0 (guilty of procrastinating 😢 ). I came across this post while looking for solution. There was no log produced to log column in _prisma_migrations table. So I didn’t have any idea how to solve it, then I found a comment in this post that says some index couldn’t be created. Immediately it hit my mind that my database size is huge and it is failing to create indexes within the timeout set by my docker container. So here is the catch, if you have a very large database and the umami service is running in a docker container, it is possible that the service timeout is reached before the initial migration is completed. Based on the type of your migration, it may take quite a while.

So, once I have identified the underlying issue, solution was very easy. I manually ran the migration (for 2.4.1 to 2.5.0 it’s 03_metric_performance_index) directly in the database using pgAdmin. Then I created a row in _prisma_migrations for 03_metric_performance_index to suppress migration next time when I would run the application. You can duplicate previous row 02_.... and update the necessary column values. Or you can run the application with v2.5.0 once without updating _prisma_migrations table, certainly it will fail, but it will create a row for 03_..., then modify the column values, especially applied_steps_count=1. Run the application with v2.5.0 again after saving the row.

I could upgrade to v2.10.2 by doing this. But I am stuck again since there are more migrations to run before I could upgrade to v2.17.0. Migration 05_add_visit_id is taking way longer than I expected since it includes query for updating a large table website_event (16M rows for my case).

FWIW, this did work:

docker compose pull docker compose down docker compose up -d

Same here with Postgres