mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +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.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import javax.sql.DataSource;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
@@ -246,9 +247,6 @@ public class DatabaseUtils
|
||||
private static int getDbMigrationStatus(Connection connection, Flyway flyway)
|
||||
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.
|
||||
if(!tableExists(connection, "item"))
|
||||
{
|
||||
@@ -302,6 +300,17 @@ public class DatabaseUtils
|
||||
// Get information about our database.
|
||||
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
|
||||
results = meta.getTables(null, schema, tableName, null);
|
||||
if (results!=null && results.next())
|
||||
|
@@ -17,6 +17,7 @@ import java.sql.SQLException;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
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.jdbc.JdbcMigration;
|
||||
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
|
||||
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 (!tables.next())
|
||||
if (!DatabaseUtils.tableExists(connection, "cwf_workflowitem"))
|
||||
{
|
||||
// Run the DB Migration first!
|
||||
DatabaseManager.loadSql(new FileReader(dbMigration));
|
||||
|
Reference in New Issue
Block a user