Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reset H2 Database to the original state after Jhipster jdl-generation?

I have this project that I ran in Jhipster with the generator yo jhipster:import-jdl. When it ends, everything is clean and ready to start. This is the state I would like to easily return to, in the H2 persistent disk copy, when I do tests, changes and so on, to start all over again.

I guess that using H2 non-persistent memory would create everything every time I start the project, but is there any easy way to get that result in a disk persistent type? (Please confirm)

Or, better, is there a way to tell Jhipter to change from a memory to a persistent database to a memory persistence, at will, before you yarn start the project?

If there is no way to change this at will, I googled for a solution and it looks like I should DROP ALL OBJECTS Reset Embedded H2 database periodically and then I do not know what to do to get to a clean database.

like image 440
Mike Avatar asked Mar 07 '23 00:03

Mike


1 Answers

When you use a H2 disk database, the files related to your database is in target/h2db/db/ folder, with *.db extension.

To get a clean H2 database, you simply need to launch ./mvnw clean, so it will delete the target folder.

like image 176
Pascal Grimaud Avatar answered Mar 20 '23 09:03

Pascal Grimaud