JITHIN_PATHROSE
JITHIN_PATHROSE

Reputation: 1406

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

Upvotes: 13

Views: 20067

Answers (3)

Andrey Oganesyan
Andrey Oganesyan

Reputation: 585

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

Upvotes: 20

M.F
M.F

Reputation: 443

You have to create a schema with persistence properties according to Database Schema Creation and then use the Liquibase generateChangeLog command.

Upvotes: 2

bilak
bilak

Reputation: 4932

Try to use liquibase-hibernate-plugin

Upvotes: 4

Related Questions