You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by gm...@apache.org on 2014/07/24 20:22:11 UTC

svn commit: r1613234 - in /roller/trunk/app/src/main: java/org/apache/roller/weblogger/business/startup/SQLScriptRunner.java resources/sql/500-to-510-migration.vm

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());

Modified: roller/trunk/app/src/main/resources/sql/500-to-510-migration.vm
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/resources/sql/500-to-510-migration.vm?rev=1613234&r1=1613233&r2=1613234&view=diff
==============================================================================
--- roller/trunk/app/src/main/resources/sql/500-to-510-migration.vm (original)
+++ roller/trunk/app/src/main/resources/sql/500-to-510-migration.vm Thu Jul 24 18:22:11 2014
@@ -12,7 +12,7 @@ DON'T RUN THIS, IT'S NOT A DATABASE CREA
 #dropColumn('weblog' 'defaultpageid')
 #dropColumn('weblog' 'weblogdayid')
 #dropColumn('weblog' 'defaultplugins')
-#addColumnNotNull('weblog' 'visible' $db.BOOLEAN_SQL_TYPE_TRUE)
+#addColumnNotNull('weblog' 'visible' $db.BOOLEAN_SQL_TYPE $db.BOOLEAN_TRUE)
 #addColumnNull('weblog' 'tagline'  "varchar(255)")
 
 update weblog set visible = isenabled;
@@ -57,12 +57,10 @@ delete from weblogcategory where name = 
 
 -- Removal of custom ping targets
 delete from pingtarget where websiteid is not null;
--- (this indexes do not exist on all Roller databases for some reason)
--- #dropIndex("pingtarget" "pt_websiteid_fk")
+#dropIndex("pingtarget" "pt_websiteid_fk")
 #dropColumn("pingtarget" "websiteid")
 
--- NOTE: you might need to drop this index on some Roller databases
--- drop index folder_namefolderid_uq on bookmark_folder;
+#dropIndex("bookmark_folder" "folder_namefolderid_uq")
 
 -- Removal of bookmark subfolders and renaming of former root folder to 'default'
 -- If a bookmark folder with name 'default' already exists, rename it by adding its id to it.
@@ -86,6 +84,5 @@ update roller_mediafiledir set name = 'd
 
 -- Referer table no longer populated, retaining for older DB's in case legacy data
 -- is desired to keep; but removing its FK relationships to other tables
--- (these indexes do not exist on all Roller databases for some reason)
--- #dropIndex("referer" "ref_entryid_fk")
--- #dropIndex("referer" "ref_websiteid_fk")
+#dropIndex("referer" "ref_entryid_fk")
+#dropIndex("referer" "ref_websiteid_fk")



Re: svn commit: r1613234 - in /roller/trunk/app/src/main: java/org/apache/roller/weblogger/business/startup/SQLScriptRunner.java resources/sql/500-to-510-migration.vm

Posted by Glen Mazza <gl...@gmail.com>.
On 07/26/2014 10:18 AM, Dave wrote:
> On Thu, Jul 24, 2014 at 2:22 PM, <gm...@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
>


Re: svn commit: r1613234 - in /roller/trunk/app/src/main: java/org/apache/roller/weblogger/business/startup/SQLScriptRunner.java resources/sql/500-to-510-migration.vm

Posted by Dave <sn...@gmail.com>.
Actually, I may have found the root cause for these "missing indexes."

So, you can disregard my previous email on this topic.

Thanks,
Dave




On Sat, Jul 26, 2014 at 10:18 AM, Dave <sn...@gmail.com> wrote:

>
> On Thu, Jul 24, 2014 at 2:22 PM, <gm...@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.
>
> The database creation script should be able to run on the command line
> without modification and without error.
>
> Is it critical that those indexes be deleted?
>
> - Dave
>
>
>
>

Re: svn commit: r1613234 - in /roller/trunk/app/src/main: java/org/apache/roller/weblogger/business/startup/SQLScriptRunner.java resources/sql/500-to-510-migration.vm

Posted by Dave <sn...@gmail.com>.
On Thu, Jul 24, 2014 at 2:22 PM, <gm...@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.

The database creation script should be able to run on the command line
without modification and without error.

Is it critical that those indexes be deleted?

- Dave