Skip to content
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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve H2 migration procedure #90

Closed
The4thLaw opened this issue Apr 27, 2019 · 3 comments
Closed

Improve H2 migration procedure #90

The4thLaw opened this issue Apr 27, 2019 · 3 comments

Comments

@The4thLaw
Copy link
Owner

The4thLaw commented Apr 27, 2019

Description

In order to limit data corruption during H2 updates, Demyo should use the recommended procedure for updates : https://h2database.com/html/tutorial.html#upgrade_backup_restore .

The recommended way to upgrade from one version of the database engine to the next version is to create a backup of the database (in the form of a SQL script) using the old engine, and then execute the SQL script using the new engine.

@The4thLaw
Copy link
Owner Author

See h2database/h2database#2078 for instructions on how to open the database in RO first to improve migration.

If you want to know the version of H2's jar, you can use Constants.BUILD_ID, better with reflection for safety, because that class is not a part of API of H2. If you have some opened database, you can use CALL H2VERSION().

If you want to know the create version of a database, you need to open it (possibly in read-only mode for safety), and execute SELECT VALUE FROM INFORMATION_SCHEMA.SETTINGS WHERE NAME = 'CREATE_BUILD'. If version is the same, you can close it and reopen in read-write mode. If it isn't the same, especially if database is newer that you current jar, you need to do something with it. For example, export it to a SQL script, create a new database and fill it with that script.

Unfortunately, there is no way to prevent corruption of a database by IntelliJ if you open it in read-write mode by its database tool, is uses an entirely outdated version of H2. If multiple versions of H2 are in use, you need a standalone H2 Server process and remote corrections to it instead of embedded databases.

@The4thLaw The4thLaw changed the title Implement automated backups of the database before migration Improve H2 migration procedure Dec 31, 2019
@The4thLaw The4thLaw modified the milestones: v3.1.0, v3.2.0 Apr 16, 2021
@The4thLaw The4thLaw modified the milestones: v3.2.0, v3.1.0 Mar 29, 2022
@The4thLaw
Copy link
Owner Author

The solution is to extends org.h2.tools.Upgrade in order to load the driver from the filesystem rather than Maven Central. We will need a plugin in the POM of demyo-app to download the various H2 versions we used in Demyo and keep all of them with all releases.

The4thLaw added a commit that referenced this issue Aug 30, 2022
Still missing the release packaging.

Refs #90
The4thLaw added a commit that referenced this issue Aug 30, 2022
The4thLaw added a commit that referenced this issue Aug 30, 2022
The4thLaw added a commit that referenced this issue Aug 30, 2022
Update Spring to follow Hibernate.

Also update Node to restore the build, which was nonfunctional after so long.

Refs #90
The4thLaw added a commit that referenced this issue Aug 30, 2022
The4thLaw added a commit that referenced this issue Aug 30, 2022
Breaking the migration is not fun, but I have no choice.

Refs #90.
The4thLaw added a commit that referenced this issue Aug 30, 2022
Since the migrations changed, we need a way to ask Flyway to adjust the checksums.

Refs #90.
The4thLaw added a commit that referenced this issue Aug 30, 2022
The H2 updated pinpointed an issue with it.

Refs #90.
@The4thLaw
Copy link
Owner Author

Merged to master.

The4thLaw added a commit that referenced this issue Sep 3, 2022
The4thLaw added a commit that referenced this issue Sep 3, 2022
The4thLaw added a commit that referenced this issue Feb 22, 2024
H2 v2 deviated from MySQL so there's not auto-update of the internal counters.

Refs #90
The4thLaw added a commit to The4thLaw/java-commons that referenced this issue Feb 29, 2024
Currently broken, as they should.

Refs The4thLaw/demyo#90
The4thLaw added a commit to The4thLaw/java-commons that referenced this issue Feb 29, 2024
Dates from v1.3.x and earlier, fairly uncommon but used by early Demyo versions.

Refs The4thLaw/demyo#90.
The4thLaw added a commit that referenced this issue Mar 1, 2024
Early Demyo 2 version had .h2 stores.

Refs #90
The4thLaw added a commit that referenced this issue Mar 1, 2024
It's best not to keep old stuff around if we have the opportunity to change it.

Refs #90
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant