2

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.

akuma8
  • 4,160
  • 5
  • 46
  • 82
  • This question seems to answer your question https://stackoverflow.com/questions/47810697/the-hibernate-envers-with-liquibase – Jens Schauder Jun 15 '20 at 05:50
  • Does this answer your question? [Can I create Hibernate Envers specific tables using Liquibase](https://stackoverflow.com/questions/28059650/can-i-create-hibernate-envers-specific-tables-using-liquibase) – Jens Schauder Jun 15 '20 at 05:51
  • @JensSchauder Thanks for the link, I already read that post before posting this one. I want to avoid doing what he did in that post, I don't want to create audited tables manually. I have lot ot tables that why I am looking for a way to generate them automatically. – akuma8 Jun 15 '20 at 14:51
  • @akuma8 Were you able to find a solution? – Anmol Vijaywargiya Oct 08 '22 at 09:30
  • @AnmolVijaywargiya nop unfortunately, I had to create all tables manually! Sad – akuma8 Oct 10 '22 at 14:13
  • Still no solution to this? Is the manual creation the only way? – sebasira Jun 04 '23 at 20:52
  • @sebasira still, I think the manual way is the only solution. – akuma8 Jun 20 '23 at 07:22

0 Answers0