Skip to content

Latest commit

 

History

History
34 lines (30 loc) · 1.05 KB

README.md

File metadata and controls

34 lines (30 loc) · 1.05 KB

Build Status

Java library that helps you to create simple H2 Database snapshots

Add H2-Snaphosts to your project. For maven projects just add this dependency:

<dependency>
    <groupId>com.afrunt.h2s</groupId>
    <artifactId>h2-snapshots</artifactId>
    <version>0.4</version>
</dependency>

Usage

Basically, you need to create the instance of the H2Snapshot class in order to create the snapshot of the current state.

import com.afrunt.h2s.H2Snapshot;
import com.sql.DataSource;

// ...
final H2Snapshot initialStateSnapshot = new H2Snapshot(dataSource);
// ...

To move database to the previous state, just invoke the apply(...) method like shown below

import com.afrunt.h2s.H2Snapshot;
import com.sql.DataSource;

// Remember the previous state
final H2Snapshot initialStateSnapshot = new H2Snapshot(dataSource);

// ...
// Apply previously created snapshot to db
initialStateSnapshot.apply(dataSource);
// ...