How to create the Javers tables such as jv_snapshot, from scratch every time the Spring Boot Application is run?
Javers - How to drop and create Javers tables in Spring Boot?
789 views Asked by Charlie At
3
There are 3 answers
0
On
I had the same issue as I wanted to clear all the data from JaVers for every start of my Spring Boot application in my dev environment using postgres.
I set up in my application.properties as follow:
spring:
profiles: dev
jpa:
hibernate:
ddl-auto: create-drop
datasource:
initialization-mode: always
continue-on-error: true
Since initialization-mode is now active, Spring boot will look at the file data.sql under src/main/ressources and run the SQL inside.
TRUNCATE jv_commit CASCADE;
TRUNCATE jv_commit_property CASCADE;
TRUNCATE jv_global_id CASCADE;
TRUNCATE jv_snapshot CASCADE;
Even if the tables don't exist, Spring Boot will still start thanks to the continue-on-error setting.
JaVers creates its tables if they not exist and never drops them. There is no
create-dropoption like in Hibernate. For testing we recommend using in-memory db (H2) and running each test on a new and empty db instance.