Author: agilliland
Date: Thu Jun 14 09:56:44 2007
New Revision: 547310

URL: http://svn.apache.org/viewvc?view=rev&rev=547310
Log:
fixing a bug in the upgrade process where we set the default template for 
weblogs with the action='weblog' attribute.  we actually can't do this by 
simply applying the 'weblog' action to templates named Weblog because some 
older versions of Roller allowed people to modify the name of their Weblog 
template, so instead we need to rely on the weblog.defaultPageId property.  to 
do this in a database independent fashion now requires putting the code in the 
UpgradeDatabase code.


Modified:
    
roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/utils/UpgradeDatabase.java
    roller/trunk/apps/weblogger/src/sql/3xx-to-400-migration.vm

Modified: 
roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/utils/UpgradeDatabase.java
URL: 
http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/utils/UpgradeDatabase.java?view=diff&rev=547310&r1=547309&r2=547310
==============================================================================
--- 
roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/utils/UpgradeDatabase.java
 (original)
+++ 
roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/utils/UpgradeDatabase.java
 Thu Jun 14 09:56:44 2007
@@ -664,7 +664,38 @@
         
         mLogger.info("Doing upgrade to 400 ...");
         
-        try {    
+        try {
+            mLogger.info("Setting all weblog default templates with action 
'weblog'");
+            
+            // we are taking all of the weblog defaulte templates defined by 
the
+            // website.defaultpageid column and setting their action value to 
'weblog'
+            
+            // select default page ids
+            PreparedStatement selectDefaultTemplateIds = con.prepareStatement(
+                    "select defaultpageid from website");
+            
+            // update template with action value 'weblog'
+            PreparedStatement updateTemplateAction = con.prepareStatement(
+                    "update webpage set action = ? where id = ?");
+            
+            // lets get to it
+            ResultSet rs = selectDefaultTemplateIds.executeQuery();
+            while (rs.next()) {
+                updateTemplateAction.clearParameters();
+                updateTemplateAction.setString(1, "weblog");
+                updateTemplateAction.setString(2, rs.getString(1));
+                updateTemplateAction.executeUpdate();
+            }
+            
+            if (!con.getAutoCommit()) con.commit();
+            
+        } catch (SQLException e) {
+            mLogger.error("Problem upgrading database to version 400", e);
+            throw new WebloggerException("Problem upgrading database to 
version 400", e);
+        }
+        
+        
+        try {
             mLogger.info("Merging planet groups 'all' and 'external'");
             
             // Move all subscriptions in the planet group 'external' to group 
'all'

Modified: roller/trunk/apps/weblogger/src/sql/3xx-to-400-migration.vm
URL: 
http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/sql/3xx-to-400-migration.vm?view=diff&rev=547310&r1=547309&r2=547310
==============================================================================
--- roller/trunk/apps/weblogger/src/sql/3xx-to-400-migration.vm (original)
+++ roller/trunk/apps/weblogger/src/sql/3xx-to-400-migration.vm Thu Jun 14 
09:56:44 2007
@@ -26,9 +26,6 @@
 insert into rag_planet (id,title,handle) values 
('zzz_default_planet_zzz','Default Planet','zzz_default_planet_zzz');
 update rag_group set planet_id='zzz_default_planet_zzz';
 
--- drop old planet config table
-drop table if exists rag_config;
-
 
 -- new column to support account activation by email
 #addColumnNull("rolleruser" "activationcode" "varchar(48)")
@@ -48,24 +45,32 @@
 
 -- add new action column to webpage table, default value is custom
 #addColumnNotNull("webpage" "action" "varchar(16)" "'custom'")
-update webpage set action = 'weblog' where name = 'Weblog';
 
 -- add new custom stylesheet column to website table
 #addColumnNull("website" "customstylesheet" "varchar(128)")
 
+
+
+
+-- The rest of these statements are just deleting old columns/tables which
+-- are no longer used by Roller starting in 4.0.  If you want to be a cautious
+-- upgrader then you can wait and run these statements only after you have
+-- finished upgrading to 4.0 and feel that things are stable.
+
+-- drop old planet config table
+drop table if exists rag_config;
+
 -- remove old id column of group subscription table
 alter table rag_group_subscription drop column id;
 
--- remove old usercookie table which has been unused since 0.x?
+-- remove old usercookie table which hasn't been unused since 0.x?
 drop table if exists usercookie;
 
--- remove old assoc tables which were EOLed in 3.2
+-- remove old assoc tables
 drop table if exists folderassoc;
 drop table if exists weblogcategoryassoc;
 
 -- remove old rollerconfig table which has been deprecated since 1.2
--- NOTE: since this breaks the pre-1.2 -> 4.0+ direct upgrade path then
---       maybe we want to attempt to fix that by doing that upgrade via sql?
 drop table if exists rollerconfig;
 
 -- remove old approved, spam, pending columns from comment table


Reply via email to