Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I need to generate Liquibase Change-set for my JPA entities. How can I do that?

I have tried the following

liquibase:generateChangeLog - It generated the change log from my db.I need to generate the change-log from my JPA entities.

liquibase:diff - It generates the change log for the difference between my db and JPA entities. I cannot say that my db is always empty and I want to generate the create scripts which can be applied on fresh db.

How can I use Liquibase to generate the scripts based on my JPA entities only ?

Note : I am ok in providing the details about my db such as url,driver etc

like image 791
JITHIN_PATHROSE Avatar asked Jan 01 '23 03:01

JITHIN_PATHROSE


2 Answers

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: generating a liquibase changelog with JPA Buddy

like image 133
Andrey Oganesyan Avatar answered Jan 04 '23 17:01

Andrey Oganesyan


Try to use liquibase-hibernate-plugin

like image 33
bilak Avatar answered Jan 04 '23 17:01

bilak