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

OF-2940: After database install, run database upgrade check #2679

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2008 Jive Software, 2016-2023 Ignite Realtime Foundation. All rights reserved.
* Copyright (C) 2005-2008 Jive Software, 2016-2025 Ignite Realtime Foundation. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -95,7 +95,7 @@ public InputStream loadResource(String resourceName) {
return null;
}
}
});
}, true); // Recursion shouldn't be needed, as the Openfire devs are in control of both the installation and upgrade scripts. Then again, it doesn't hurt to check (OF-2940).
}
catch (Exception e) {
Log.error(LocaleUtils.getLocalizedString("upgrade.database.failure"), e);
Expand Down Expand Up @@ -138,7 +138,7 @@ public InputStream loadResource(String resourceName) {
return null;
}
}
});
}, true); // Recursion is advisable, as third-party plugin developers may not keep the database install and upgrade scripts 'in sync' (OF-2940).
}
catch (Exception e) {
Log.error(LocaleUtils.getLocalizedString("upgrade.database.failure"), e);
Expand All @@ -158,11 +158,12 @@ public InputStream loadResource(String resourceName) {
* @param schemaKey the database schema key (name).
* @param requiredVersion the version that the schema should be at.
* @param resourceLoader a resource loader that knows how to load schema files.
* @throws Exception if an error occured.
* @param allowRecursion controls if the method is allowed to recursively call itself.
* @throws Exception if an error occurred.
* @return True if the schema update was successful.
*/
private boolean checkSchema(Connection con, String schemaKey, int requiredVersion,
ResourceLoader resourceLoader) throws Exception
ResourceLoader resourceLoader, boolean allowRecursion) throws Exception
{
int currentVersion = -1;
PreparedStatement pstmt = null;
Expand Down Expand Up @@ -240,6 +241,12 @@ else if (currentVersion == -1) {
Log.error(e.getMessage(), e);
return false;
}

// OF-2940: If the original installation doesn't include all upgrades, the individual upgrades need to be executed, too.
if (allowRecursion) {
checkSchema(con, schemaKey, requiredVersion, resourceLoader, false);
}

Log.info(LocaleUtils.getLocalizedString("upgrade.database.success"));
System.out.println(LocaleUtils.getLocalizedString("upgrade.database.success"));
return true;
Expand Down
Loading