-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
support snapshots or similar #2906
Comments
and a dozen lines later
Looks like a contradiction to me. |
I do not think it is a contradiction, because when triggered from within h2, the database can be prepared for the whole process. I see a lot of reasons why the whole snapshot-process should be covered by the database itself, and not from the outside:
None of these future changes would break existing code that relies on the proposed |
But what is there to loose, besides connection itself, if all transactions need to be closed, therefore all connections will be idle anyway? Also IMHO, it is not a good idea to keep connection open between test cases. As far as use of in-memory database in conjunction with copying to/from real file - that popped up a few times before, i.e. here. In any case, it is not a trivial exercise, but approach with shutdown / copy / start, or shutdown / start with initialization script (for in-memory case) may solve your problem today. |
These are the messages in the mentioned google group:
(not including a mention of savepoint/rollback, because this would need a single running transaction) |
Hi Mick. Pardon my ignorance, but have you tried to simply Copy that H2 Database file (e. g. using Apache Commons IO) in order to create your snapshot? Our biggest challenge from that practise is, that we have now a large zoo of such H2 database files laying around and when we want to migrate to a newer H2 version, we need to migrate all of them, while each may have its own incompatibilities (depending, when exactly they have been created). But that's the only Contra argument I have in mind. Cheers |
Alternatively: Why not just loop through all schemas and tables (e.g. via JDBC DatabaseMetaData) and create snapshots as per If the schemas do not change, then you could add a timestamp field in order to identify your snapshot. Cheers |
thanks for your ideas, but:
We now went with SCRIPT command for dumping and DROP ALL OBJECTS + executing the generated script for restoring. I hoped for a more native approach but it seems this won't happen in the near future. regards, |
One of the use cases for h2 databases is definitley being a storage backend for testing. We use it for our integration tests and really like its speed and ease to use 馃憤
Now we want to isolate our tests and for that, we currently rely on basically 3 schemes:
We generally have a few megabytes (10..100) of database data as a 'base line', and each test creates a very small amount of data on top of that.
I am aware of
SCRIPT
/RUNSCRIPT
or the possibility to 'manually' backup/restore the underlying database files. But all of these solutions have their own drawbacks:A really nice feature would be to have a
createsnapshot
/restoresnapshot
functionality built into h2.From my point of view it could work as follows:
createsnapshot
:restoresnapshot
:Any in-memory-objects could:
Now, what do you think?
The text was updated successfully, but these errors were encountered: