Spring Boot 中的 Keycloak 无法应用 Liquibase 补丁

Keycloak in Spring Boot cannot apply Liquibase patches

我正在尝试启动一个 Spring 引导服务器,其中包含一个嵌入式 Keycloak 授权服务器,following this tutorial. Tutorial's code is here。我自己的改编是 MySQL 数据库,而不是 H2,通过 docker-compose

启动

在服务器启动时,应用数据库补丁时出现此错误: Caused by: java.sql.SQLSyntaxErrorException: Table 'auth.client_session' doesn't exist。 SequelPro 抛出同样的错误,但 table 是可见的。我通过 looking around this thread 解决了这个问题。 (重启对我来说就足够了)

下一个错误来自下一个补丁,引用:keycloak java.sql.SQLSyntaxErrorException: Table 'client_attributes' already exists,而对于这个错误,我陷入了数据库迁移的困境,因为如果我删除它,它将回到“不存在”错误。

版本:

将 MySQL 的 lower_case_table_names 配置更改为 1 可以解决此问题。灵感来自 this answer.

要通过 docker-compose 刻录此设置,请在 yaml 文件中自定义您的命令(受 this repo 启发):

db-service:
  [...]
  ports:
    - 3306:3306
  command: mysqld --lower_case_table_names=1 

还要确保 table 的编码是 UTF-8,以避免另一个头刮擦错误:keycloak Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535

其他参考资料: