Commit bfaccdb4 authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

Checking old version table as well as new one now.

Also now changing jid column to varchar(1024).

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@10160 b35dd754-fafc-0310-a699-88a17e54d16e
parent 1e4165bf
...@@ -31,6 +31,9 @@ RENAME TABLE jiveOffline TO ofOffline; ...@@ -31,6 +31,9 @@ RENAME TABLE jiveOffline TO ofOffline;
# Rename jivePresence to ofPresence # Rename jivePresence to ofPresence
RENAME TABLE jivePresence TO ofPresence; RENAME TABLE jivePresence TO ofPresence;
# Make sure that the jid column of jiveRoster is a varchar instead of text
ALTER TABLE jiveRoster CHANGE COLUMN jid jid VARCHAR(1024) NOT NULL;
# Rename jiveRoster to ofRoster # Rename jiveRoster to ofRoster
ALTER TABLE jiveRoster DROP INDEX jiveRoster_unameid_idx; ALTER TABLE jiveRoster DROP INDEX jiveRoster_unameid_idx;
ALTER TABLE jiveRoster DROP INDEX jiveRoster_jid_idx; ALTER TABLE jiveRoster DROP INDEX jiveRoster_jid_idx;
......
...@@ -37,9 +37,11 @@ import java.util.Arrays; ...@@ -37,9 +37,11 @@ import java.util.Arrays;
public class SchemaManager { public class SchemaManager {
private static final String CHECK_VERSION_OLD = private static final String CHECK_VERSION_OLD =
"SELECT minorVersion FROM ofVersion"; "SELECT minorVersion FROM jiveVersion";
private static final String CHECK_VERSION = private static final String CHECK_VERSION =
"SELECT version FROM ofVersion WHERE name=?"; "SELECT version FROM ofVersion WHERE name=?";
private static final String CHECK_VERSION_JIVE =
"SELECT version FROM jiveVersion WHERE name=?";
/** /**
* Current Openfire database schema version. * Current Openfire database schema version.
...@@ -158,23 +160,36 @@ public class SchemaManager { ...@@ -158,23 +160,36 @@ public class SchemaManager {
catch (SQLException sqle) { catch (SQLException sqle) {
DbConnectionManager.closeResultSet(rs); DbConnectionManager.closeResultSet(rs);
DbConnectionManager.closeStatement(pstmt); DbConnectionManager.closeStatement(pstmt);
// Releases of Openfire before 2.6.0 stored a major and minor version
// number so the normal check for version can fail. Check for the
// version using the old format in that case.
if (schemaKey.equals("openfire")) { if (schemaKey.equals("openfire")) {
try { try {
if (pstmt != null) { // Releases of Openfire before 3.6.0 stored the version in a jiveVersion table.
pstmt.close(); pstmt = con.prepareStatement(CHECK_VERSION_JIVE);
} pstmt.setString(1, schemaKey);
pstmt = con.prepareStatement(CHECK_VERSION_OLD);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) { if (rs.next()) {
currentVersion = rs.getInt(1); currentVersion = rs.getInt(1);
} }
} }
catch (SQLException sqle2) { catch (SQLException sqlea) {
// The database schema must not be installed. DbConnectionManager.closeResultSet(rs);
Log.debug("SchemaManager: Error verifying server version", sqle2); DbConnectionManager.closeStatement(pstmt);
// Releases of Openfire before 2.6.0 stored a major and minor version
// number so the normal check for version can fail. Check for the
// version using the old format in that case.
try {
if (pstmt != null) {
pstmt.close();
}
pstmt = con.prepareStatement(CHECK_VERSION_OLD);
rs = pstmt.executeQuery();
if (rs.next()) {
currentVersion = rs.getInt(1);
}
}
catch (SQLException sqle2) {
// The database schema must not be installed.
Log.debug("SchemaManager: Error verifying server version", sqle2);
}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment