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

[jdbc] Upgrade H2 to 2.2.224 #15726

Merged
merged 1 commit into from
Oct 10, 2023
Merged

[jdbc] Upgrade H2 to 2.2.224 #15726

merged 1 commit into from
Oct 10, 2023

Conversation

wborn
Copy link
Member

@wborn wborn commented Oct 9, 2023

Upgrades H2 database from 1.4.191 to 2.2.224.

Add the ;NON_KEYWORDS=VALUE configuration option at the end of your H2 JDBC URL because the add-on uses 'value' (which is also a keyword) as column name, e.g.: jdbc:h2:./testH2;NON_KEYWORDS=VALUE

Also fixes some queries used by the command extension because H2 always uses upper case table names.

For the change log, see:

https://h2database.com/html/changelog.html

For migration notes, see:

https://h2database.com/html/migration-to-v2.html

Fixes #13115


I also wrote a small migration script using Bash to migrate databases from H2 1.4 to H2 2.2:

#!/usr/bin/env bash

set -eo pipefail

if [ $# -eq 0 ]; then
    echo "This script migrates an H2 1.4 database to H2 2.2"
    echo
    echo "Usage: ./$(basename "$0") <h2-1.4-database.mv.db>"
    echo "Example: ./$(basename "$0") /var/lib/openhab/database.mv.db"
    exit 1
fi

if [ ! -e $1 ]; then
    echo "File '$1' does not exist"
    exit 1
fi

if [[ "$1" != *.mv.db ]]; then
    echo "File '$1' is not an H2 database because it has no '.mv.db' extension"
    exit 1
fi

DATABASE_PATH=$(realpath $1 | sed 's#.mv.db##')

echo "Downloading H2 JARs"
wget -q -O /tmp/h2-1.4.191.jar https://repo1.maven.org/maven2/com/h2database/h2/1.4.191/h2-1.4.191.jar
wget -q -O /tmp/h2-2.2.224.jar https://repo1.maven.org/maven2/com/h2database/h2/2.2.224/h2-2.2.224.jar

echo "Exporting H2 1.4 database"
java -cp /tmp/h2-1.4.191.jar org.h2.tools.Shell -url "jdbc:h2:$DATABASE_PATH" -sql "SCRIPT BLOCKSIZE 1000 TO '/tmp/h2-1.4-export.sql'" >/dev/null

echo "Renaming old database to: $DATABASE_PATH.mv.db.old"
mv $DATABASE_PATH.mv.db $DATABASE_PATH.mv.db.old

echo "Restoring H2 2.2 database from export"
java -cp /tmp/h2-2.2.224.jar org.h2.tools.RunScript -url "jdbc:h2:$DATABASE_PATH;NON_KEYWORDS=VALUE" -script "/tmp/h2-1.4-export.sql" -options FROM_1X >/dev/null

echo "Removing temporary files"
rm -f /tmp/h2-1.4.191.jar /tmp/h2-2.2.224.jar /tmp/h2-1.4-export.sql

echo "Done!"

@wborn wborn added enhancement An enhancement or new feature for an existing add-on (potentially) not backward compatible labels Oct 9, 2023
@wborn wborn requested a review from a team as a code owner October 9, 2023 19:56
Upgrades H2 database from 1.4.191 to 2.2.224.

Add ';NON_KEYWORDS=VALUE' to the JDBC URL because the add-on uses 'value' (which is also a keyword) as column name.

Also fixes some queries used by the command extension because H2 always uses upper case table names.

For the change log, see:

https://h2database.com/html/changelog.html

For migration notes, see:

https://h2database.com/html/migration-to-v2.html

Fixes openhab#13115

Signed-off-by: Wouter Born <github@maindrain.net>
Copy link
Contributor

@jlaur jlaur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking the time to do this upgrade! I'm sure this is great news to @wollyd, @dependabot and others. 🙂

Do you think it would be reasonable to add a small note somewhere around here to mention the need to upgrade the database?
https://github.com/openhab/openhab-distro/blob/678720a9db8f9a7cfa6bb5f1f0e51666eaa9dcc6/distributions/openhab/src/main/resources/bin/update.lst#L119

@wborn
Copy link
Member Author

wborn commented Oct 9, 2023

Do you think it would be reasonable to add a small note somewhere around here to mention the need to upgrade the database?

Yes that is also part of the upgrade plan. 🙂

wborn added a commit to wborn/openhab-distro that referenced this pull request Oct 10, 2023
Related to openhab/openhab-addons#15726

Signed-off-by: Wouter Born <github@maindrain.net>
@wborn wborn added rebuild Triggers Jenkins PR build and removed rebuild Triggers Jenkins PR build labels Oct 10, 2023
@jlaur jlaur merged commit 1759058 into openhab:main Oct 10, 2023
2 checks passed
@jlaur jlaur added this to the 4.1 milestone Oct 10, 2023
@wborn wborn deleted the jdbc-upgrade-h2 branch October 10, 2023 12:31
pat-git023 pushed a commit to pat-git023/openhab-addons that referenced this pull request Oct 13, 2023
Upgrades H2 database from 1.4.191 to 2.2.224.

Add ';NON_KEYWORDS=VALUE' to the JDBC URL because the add-on uses 'value' (which is also a keyword) as column name.

Also fixes some queries used by the command extension because H2 always uses upper case table names.

For the change log, see:

https://h2database.com/html/changelog.html

For migration notes, see:

https://h2database.com/html/migration-to-v2.html

Fixes openhab#13115

Signed-off-by: Wouter Born <github@maindrain.net>
querdenker2k pushed a commit to querdenker2k/openhab-addons that referenced this pull request Oct 21, 2023
Upgrades H2 database from 1.4.191 to 2.2.224.

Add ';NON_KEYWORDS=VALUE' to the JDBC URL because the add-on uses 'value' (which is also a keyword) as column name.

Also fixes some queries used by the command extension because H2 always uses upper case table names.

For the change log, see:

https://h2database.com/html/changelog.html

For migration notes, see:

https://h2database.com/html/migration-to-v2.html

Fixes openhab#13115

Signed-off-by: Wouter Born <github@maindrain.net>
wborn added a commit to wborn/openhab-distro that referenced this pull request Oct 22, 2023
Related to openhab/openhab-addons#15726

Signed-off-by: Wouter Born <github@maindrain.net>
querdenker2k pushed a commit to querdenker2k/openhab-addons that referenced this pull request Oct 29, 2023
Upgrades H2 database from 1.4.191 to 2.2.224.

Add ';NON_KEYWORDS=VALUE' to the JDBC URL because the add-on uses 'value' (which is also a keyword) as column name.

Also fixes some queries used by the command extension because H2 always uses upper case table names.

For the change log, see:

https://h2database.com/html/changelog.html

For migration notes, see:

https://h2database.com/html/migration-to-v2.html

Fixes openhab#13115

Signed-off-by: Wouter Born <github@maindrain.net>
Signed-off-by: querdenker2k <querdenker2k@gmx.de>
J-N-K pushed a commit to openhab/openhab-distro that referenced this pull request Oct 31, 2023
@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/openhab-4-1-release-discussion/152252/129

austvik pushed a commit to austvik/openhab-addons that referenced this pull request Mar 27, 2024
Upgrades H2 database from 1.4.191 to 2.2.224.

Add ';NON_KEYWORDS=VALUE' to the JDBC URL because the add-on uses 'value' (which is also a keyword) as column name.

Also fixes some queries used by the command extension because H2 always uses upper case table names.

For the change log, see:

https://h2database.com/html/changelog.html

For migration notes, see:

https://h2database.com/html/migration-to-v2.html

Fixes openhab#13115

Signed-off-by: Wouter Born <github@maindrain.net>
Signed-off-by: Jørgen Austvik <jaustvik@acm.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature for an existing add-on (potentially) not backward compatible
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[jdbc] Upgrade H2 driver to 2.2.224
3 participants