Spring Data Envers + Liquibase: how to create audited tables and update them automatically?

Viewed 921

I would like to audit my models in my Spring Boot app. I use Liquibase for db migration. Say I have this entity :

@Entity
@Audited
public class User {
 @Id
 private Long id;
 private String name;
 private String firstName;
}

I create the user table using Liquibase

<changeSet id="user_table">
        <createTable tableName="user">
            <column name="id" type="bigint">
                <constraints primaryKey="true"/>
            </column>
            <column name="name" type="VARCHAR(255)"/>
            <column name="first_name" type="varchar(255)"/>
        </createTable>
</changeSet>

How can I create the user_AUD table used for auditing? I would like to avoid creating it manually because if later I add other fields to the User entity I am sure that I will forget to add them to user_AUD, and it's too tedious to do it manually. The same question is for the REVINFO table (how to auto create it?)

Note that I disabled hibernate.ddl-auto property since I use Liquibase.

Thanks a lot for your help.

0 Answers
Related