mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 18:14:26 +00:00
Support case-insensitive table name searches to determine DSpace version
This commit is contained in:
@@ -13,6 +13,7 @@ import java.sql.Connection;
|
|||||||
import java.sql.DatabaseMetaData;
|
import java.sql.DatabaseMetaData;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
@@ -246,9 +247,6 @@ public class DatabaseUtils
|
|||||||
private static int getDbMigrationStatus(Connection connection, Flyway flyway)
|
private static int getDbMigrationStatus(Connection connection, Flyway flyway)
|
||||||
throws SQLException
|
throws SQLException
|
||||||
{
|
{
|
||||||
// Get information about our database. We'll use this to determine DB status.
|
|
||||||
DatabaseMetaData meta = connection.getMetaData();
|
|
||||||
|
|
||||||
// First, is this a "fresh_install"? Check for an "item" table.
|
// First, is this a "fresh_install"? Check for an "item" table.
|
||||||
if(!tableExists(connection, "item"))
|
if(!tableExists(connection, "item"))
|
||||||
{
|
{
|
||||||
@@ -302,6 +300,17 @@ public class DatabaseUtils
|
|||||||
// Get information about our database.
|
// Get information about our database.
|
||||||
DatabaseMetaData meta = connection.getMetaData();
|
DatabaseMetaData meta = connection.getMetaData();
|
||||||
|
|
||||||
|
// Check how this database stores its table names.
|
||||||
|
// i.e. lowercase vs uppercase (by default we assume mixed case)
|
||||||
|
if(meta.storesLowerCaseIdentifiers())
|
||||||
|
{
|
||||||
|
tableName = StringUtils.lowerCase(tableName);
|
||||||
|
}
|
||||||
|
else if(meta.storesUpperCaseIdentifiers())
|
||||||
|
{
|
||||||
|
tableName = StringUtils.upperCase(tableName);
|
||||||
|
}
|
||||||
|
|
||||||
// Search for a table of the given name in our current schema
|
// Search for a table of the given name in our current schema
|
||||||
results = meta.getTables(null, schema, tableName, null);
|
results = meta.getTables(null, schema, tableName, null);
|
||||||
if (results!=null && results.next())
|
if (results!=null && results.next())
|
||||||
|
@@ -17,6 +17,7 @@ import java.sql.SQLException;
|
|||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.dspace.core.ConfigurationManager;
|
import org.dspace.core.ConfigurationManager;
|
||||||
import org.dspace.storage.rdbms.DatabaseManager;
|
import org.dspace.storage.rdbms.DatabaseManager;
|
||||||
|
import org.dspace.storage.rdbms.DatabaseUtils;
|
||||||
import org.flywaydb.core.api.migration.MigrationChecksumProvider;
|
import org.flywaydb.core.api.migration.MigrationChecksumProvider;
|
||||||
import org.flywaydb.core.api.migration.jdbc.JdbcMigration;
|
import org.flywaydb.core.api.migration.jdbc.JdbcMigration;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -76,11 +77,8 @@ public class V5_0_2014_01_01__XMLWorkflow_Migration
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now, check if the XMLWorkflow table (cwf_workflowitem) already exists in this database
|
// Now, check if the XMLWorkflow table (cwf_workflowitem) already exists in this database
|
||||||
DatabaseMetaData meta = connection.getMetaData();
|
|
||||||
ResultSet tables = meta.getTables(null, schema, "cwf_workflowitem", null);
|
|
||||||
|
|
||||||
// If XMLWorkflow Table does NOT exist in this database, then lets do the migration!
|
// If XMLWorkflow Table does NOT exist in this database, then lets do the migration!
|
||||||
if (!tables.next())
|
if (!DatabaseUtils.tableExists(connection, "cwf_workflowitem"))
|
||||||
{
|
{
|
||||||
// Run the DB Migration first!
|
// Run the DB Migration first!
|
||||||
DatabaseManager.loadSql(new FileReader(dbMigration));
|
DatabaseManager.loadSql(new FileReader(dbMigration));
|
||||||
|
Reference in New Issue
Block a user