On 07/26/2014 10:18 AM, Dave wrote:
On Thu, Jul 24, 2014 at 2:22 PM, <gma...@apache.org> wrote:
Author: gmazza
Date: Thu Jul 24 18:22:11 2014
New Revision: 1613234
URL: http://svn.apache.org/r1613234
Log:
Tested migration process. Reactivated dropIndex commands (as they are
needed if they exist and one is dropping a column), however process changed
to now ignores any index-doesn't-exist errors.
Modified:
roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/startup/SQLScriptRunner.java
roller/trunk/app/src/main/resources/sql/500-to-510-migration.vm
Modified:
roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/startup/SQLScriptRunner.java
URL:
http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/startup/SQLScriptRunner.java?rev=1613234&r1=1613233&r2=1613234&view=diff
==============================================================================
---
roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/startup/SQLScriptRunner.java
(original)
+++
roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/startup/SQLScriptRunner.java
Thu Jul 24 18:22:11 2014
@@ -126,6 +126,10 @@ public class SQLScriptRunner {
successMessage(command);
} catch (SQLException ex) {
+ if (command.contains("drop foreign key") ||
command.contains("drop index")) {
+ errorMessage("INFO: SQL command [" + command + "]
failed, ignored.");
+ continue;
+ }
// add error message with text of SQL command to messages
errorMessage("ERROR: SQLException executing SQL [" +
command
+ "] : " + ex.getLocalizedMessage());
I don't think this is a sufficient solution to the problem because many sys
admins insist on doing database upgrades manually and do not trust
automatic schema creation and update.
This is just approximating the "drop index if exists" functionality you
were looking for last weekend, i.e., if it doesn't exist, report back
that it doesn't and continue on.
The database creation script should be able to run on the command line
without modification and without error.
It won't run with an error in that case, just an INFO, that it wasn't
able to delete the index, which normally means that it doesn't already
exist.
Is it critical that those indexes be deleted?
Usually, yes, because other columns can't be dropped if the indexes
still exist. I had the problem with a vanilla MySQL (IIRC, maybe it was
Derby) w/Roller 5.0.x instance earlier this week, which is why I made
the change. This way it works for the Apache MySQL DB as well as other
databases containing that key.
Glen
- Dave