环境运维

umami需要mysql的版本升级到5.7以上


Tip: Easily identify and fix slow SQL queries in your app. Optimize helps you enhance your visibility: https://pris.ly/--optimize

$ node scripts/check-db.js
✓ DATABASE_URL is defined.
✓ Database connection successful.
✗ Database version is not compatible. Please upgrade mysql version to 5.7.0 or greater
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ERROR: "check-db" exited with 1.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
 

为此,把腾讯云mysql从用了多年的5.6在线升级到了5.7,

Specified key was too long; max key length is 767 bytes

Please check the query number 1 from the migration file.


✗ Command failed: prisma migrate deploy
Error: P3018

A migration failed to apply. New migrations cannot be applied before the error is recovered from. Read more about how to resolve migration issues in a production database: https://pris.ly/d/migrate-resolve

Migration name: 01_init

Database error code: 1071

Database error:
Specified key was too long; max key length is 767 bytes

Please check the query number 1 from the migration file.

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ERROR: "check-db" exited with 1.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

出现以上报错后,干脆把mysql版本升级到8.0,操作过程如下

$ node scripts/check-db.js
✓ DATABASE_URL is defined.
✓ Database connection successful.
✓ Database version check successful.
Error: P3009

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
The `01_init` migration started at 2024-11-20 06:29:15.037 UTC failed


✗ Command failed: prisma migrate deploy
Error: P3009

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
The `01_init` migration started at 2024-11-20 06:29:15.037 UTC failed

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ERROR: "check-db" exited with 1.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

解决过程:删除数据库中的表: _prisma_migrations 然后继续执行yarn build 通过!