我需要为我的 JPA 实体生成 Liquibase 变更集。我怎样才能做到这一点?

JIT*_*HIN 12 spring hibernate jpa liquibase spring-boot

我尝试过以下方法

liquibase:generateChangeLog- 它从我的数据库生成更改日志。我需要change-log从我的JPA entities.

liquibase:diff- 它生成我的数据库和实体之间差异的更改日志JPA。我不能说我的数据库总是空的,我想生成可以应用于新数据库的创建脚本。

如何仅Liquibase根据我的实体生成脚本JPA

注意:我可以提供有关我的数据库的详细信息,例如网址、驱动程序等

小智 19

If your IDE of choice is IntelliJ IDEA, I'd recommend using the JPA Buddy plugin to do this. It can generate Liquibase changelogs by comparing your Java model to the target DB.

So if your DB is empty, you'll get a changelog that describes your whole model. But it is also useful to keep your evolving model and your changelogs in sync.

Once you have it installed and have Liquibase as your Maven/Gradle dependency, you can generate a changelog like this: 使用 JPA Buddy 生成 liquibase 变更日志

  • 遗憾的是,这现在是 JPA Buddy 的一项高级功能! (4认同)