You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

如何通过Spring Boot配置文件重命名Liquibase变更日志表?

Customizing Liquibase Changelog Table Names in Spring Boot 1.5.3

Absolutely! For your Spring Boot 1.5.3 + Liquibase 3.5.3 stack, you don’t have to rely solely on system properties to rename the Liquibase changelog and lock tables. You can directly set these values in your Spring Boot configuration files (application.properties or application.yml), which is the more idiomatic approach for Spring Boot apps.

Using application.properties

Add these lines to your properties file, replacing the table names with your desired custom names:

# Override default Liquibase changelog table name
liquibase.change-log-table=my_custom_db_changelog
# Override default Liquibase lock table name
liquibase.change-log-lock-table=my_custom_db_changelog_lock

Using application.yml

If you prefer YAML format, use this structure instead:

liquibase:
  change-log-table: my_custom_db_changelog
  change-log-lock-table: my_custom_db_changelog_lock

How this works

Spring Boot's auto-configuration for Liquibase (in version 1.5.x) maps these configuration properties directly to Liquibase's internal settings. Specifically:

  • liquibase.change-log-table corresponds to Liquibase's databaseChangeLogTableName
  • liquibase.change-log-lock-table corresponds to Liquibase's databaseChangeLogLockTableName

When your app starts up, Spring Boot will pass these custom values to the Liquibase instance it initializes, so you don’t need any extra code or manual system property setup.

内容的提问来源于stack exchange,提问作者mkhaired

火山引擎 最新活动