This is great! We will most likely need this when we can no longer avoid updating to a >128 release because of crucial bugfixes. I don't have the time to evaluate your "patch" right now but I sure will do. You're bookmarked. :-)
Without looking at your code, I guess you patched only a small couple of lines in H2 core to detect whether the database format is old and jump to your migration tool entry point. Maybe the H2 core could be changed so that this becomes an extension point where third party libraries could add their logic? H2 could search for those extension libraries using the standard Java service lookup mechanism (META-INF/ services). That way H2 could remain unpatched, and the migration tool could be distributed as a separate add-on. What do you think? Anyway, great work. Many thanks! Dirk. On 9 Jun., 23:23, Christian Peter <[email protected]> wrote: > Usage: Just replace your h2 jar file with this version and launch your > app. If your app connects to an old database, it will be converted > automatically to a page store version. Apart from that, it will act > like the default H2 version. > > See the class comment above for more options. > > Christian Peter > > On Jun 9, 9:55 pm, Christian Peter <[email protected]> > wrote: > > > Hi list, > > > as a H2 developer and user myself, I was unhappy about the situation, > > that one can't open a non page store database with version 1.2. Thomas > > wrote a little tool for converting the database, but I think the tool > > lacks some important things: > > > - Doesn't care about connect parameters (like split:) > > - The old version (h2-1.2.127.jar) must be shipped or the tool must > > download it > > - The users must include the code in their software and customize it > > (no drop in replacement) > > > I respect Thomas decision to drop the non page store format, because > > he has reasonable arguments for doing that. But I know at least two > > companies which are unhappy about the current situation. > > > So I decided to write my own tool. Of course the database must be > > converted, so it internally uses "script to" and "runscript from". But > > the main point is, that the last non page store version (1.2.128) is > > integrated in the new h2 versions relocated as a new package > > (org.h2.upgrade.v1_1_to_v1_2). > > > /** > > * Class org.h2.upgrade.v1_1_to_v1_2.Migrate > > * > > * Class to convert a 1.1 DB (non page store) to a 1.2 DB (page store) > > format. > > * Conversion is done via "script to" and "runscript from" > > * > > * Features: > > * - Every database opened will be converted on the fly, by calling > > * > > org.h2.upgrade.v1_1_to_v1_2.Migrate.convertToPageStoreIfNeeded(url, > > info) > > * from org.h2.Driver.connect(url, info) > > * - Conversion can be customized via > > * public static void > > org.h2.upgrade.v1_1_to_v1_2.Migrate.initConversion( > > * PrintStream outputStream, the stream to print info messages > > * PrintStream errorStream, the stream to print error messages > > * boolean scriptInDbDir true if the temporary conversion > > script should be placed > > * in the db dir rather than the > > default tmp dir > > * ) > > * - To get information, if a conversion is needed, the function > > * public static boolean > > org.h2.upgrade.v1_1_to_v1_2.Migrate.mustBeConverted(String url, > > Properties info) > > * can be used. The parameters are the same as for a Driver connect. > > * - To convert before connecting, the function > > * public static void > > org.h2.upgrade.v1_1_to_v1_2.Migrate.convertToPageStoreIfNeeded(String > > url, Properties info) > > * can be used. The parameters are the same as for a Driver connect. > > * - To get information, whether the conversion was sucessfully, use > > * public static boolean > > org.h2.upgrade.v1_1_to_v1_2.Migrate.wasSuccessful() > > * afterwards. > > * > > */ > > > The files are located here: > > >http://inputsys.de/h2/h2mig-1.2.137.jar <= Every version will get a > > new filenamehttp://inputsys.de/h2/h2mig-latest.jar <= Points to the > > latest > > versionhttp://inputsys.de/h2/Migrate.java <= Sourcecode of the > > main conversion class > > > This works for me, but of course it may not work for you. So please > > give me feedback! > > > Regards > > > Christian Peter -- You received this message because you are subscribed to the Google Groups "H2 Database" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.
