Author: gmazza
Date: Tue Jul 23 12:04:26 2013
New Revision: 1506004
URL: http://svn.apache.org/r1506004
Log:
Removed old upgrade scripts from Roller trunk. Minimum version supported for
upgrades now Roller 3.1.
Removed:
roller/trunk/app/src/main/resources/dbscripts/
roller/trunk/app/src/main/resources/sql/200-to-210-migration.vm
roller/trunk/app/src/main/resources/sql/210-to-230-migration.vm
roller/trunk/app/src/main/resources/sql/230-to-240-migration.vm
roller/trunk/app/src/main/resources/sql/240-to-300-migration.vm
roller/trunk/app/src/main/resources/sql/300-to-310-migration.vm
Modified:
roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/startup/DatabaseInstaller.java
roller/trunk/app/src/main/resources/sql/dbscripts.properties
Modified:
roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/startup/DatabaseInstaller.java
URL:
http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/startup/DatabaseInstaller.java?rev=1506004&r1=1506003&r2=1506004&view=diff
==============================================================================
---
roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/startup/DatabaseInstaller.java
(original)
+++
roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/startup/DatabaseInstaller.java
Tue Jul 23 12:04:26 2013
@@ -203,6 +203,11 @@ public class DatabaseInstaller {
String msg = "Cannot upgrade database tables, Roller database
version cannot be determined";
errorMessage(msg);
throw new StartupException(msg);
+ } else if (dbversion < 310) {
+ String msg = "Roller " + myVersion + " cannot upgrade from
versions older than 3.10; " +
+ "try first upgrading to an earlier version of Roller.";
+ errorMessage(msg);
+ throw new StartupException(msg);
} else if(dbversion >= myVersion) {
log.info("Database is current, no upgrade needed");
return;
@@ -213,34 +218,7 @@ public class DatabaseInstaller {
// iterate through each upgrade as needed
// to add to the upgrade sequence simply add a new "if" statement
// for whatever version needed and then define a new method
upgradeXXX()
- if(dbversion < 130) {
- upgradeTo130(con, runScripts);
- dbversion = 130;
- }
- if (dbversion < 200) {
- upgradeTo200(con, runScripts);
- dbversion = 200;
- }
- if(dbversion < 210) {
- upgradeTo210(con, runScripts);
- dbversion = 210;
- }
- if(dbversion < 230) {
- upgradeTo230(con, runScripts);
- dbversion = 230;
- }
- if(dbversion < 240) {
- upgradeTo240(con, runScripts);
- dbversion = 240;
- }
- if(dbversion < 300) {
- upgradeTo300(con, runScripts);
- dbversion = 300;
- }
- if(dbversion < 310) {
- upgradeTo310(con, runScripts);
- dbversion = 310;
- }
+
if(dbversion < 400) {
upgradeTo400(con, runScripts);
dbversion = 400;
@@ -264,433 +242,7 @@ public class DatabaseInstaller {
try { if (con != null) con.close(); } catch (Exception ignored) {}
}
}
-
-
- /**
- * Upgrade database for Roller 1.3.0
- */
- private void upgradeTo130(Connection con, boolean runScripts) throws
StartupException {
- SQLScriptRunner runner = null;
- try {
- if (runScripts) {
- String handle = getDatabaseHandle(con);
- String scriptPath = handle + "/120-to-130-migration.sql";
- successMessage("Running database upgrade script:
"+scriptPath);
- runner = new
SQLScriptRunner(scripts.getDatabaseScript(scriptPath));
- runner.runScript(con, true);
- messages.addAll(runner.getMessages());
- }
-
- /*
- * The new theme management code is going into place and it uses
- * the old website.themeEditor attribute to store a users theme.
- *
- * In pre-1.3 Roller *all* websites are considered to be using a
- * custom theme, so we need to make sure this is properly defined
- * by setting the theme on all websites to custom.
- *
- * NOTE: If we don't do this then nothing would break, but some
users
- * would be suprised that their template customizations are no
longer
- * in effect because they are using a shared theme instead.
- */
-
- successMessage("Doing upgrade to 130 ...");
- successMessage("Ensuring that all website themes are set to
custom");
-
- PreparedStatement setCustomThemeStmt = con.prepareStatement(
- "update website set editortheme = ?");
-
- setCustomThemeStmt.setString(1,
org.apache.roller.weblogger.pojos.WeblogTheme.CUSTOM);
- setCustomThemeStmt.executeUpdate();
-
- if (!con.getAutoCommit()) con.commit();
-
- successMessage("Upgrade to 130 complete.");
-
- } catch (Exception e) {
- log.error("ERROR running 310 database upgrade script", e);
- if (runner != null) messages.addAll(runner.getMessages());
-
- errorMessage("Problem upgrading database to version 130", e);
- throw new StartupException("Problem upgrading database to version
130", e);
- }
-
- updateDatabaseVersion(con, 130);
- }
-
- /**
- * Upgrade database for Roller 2.0.0
- */
- private void upgradeTo200(Connection con, boolean runScripts) throws
StartupException {
- SQLScriptRunner runner = null;
- try {
- if (runScripts) {
- String handle = getDatabaseHandle(con);
- String scriptPath = handle + "/130-to-200-migration.sql";
- successMessage("Running database upgrade script:
"+scriptPath);
- runner = new
SQLScriptRunner(scripts.getDatabaseScript(scriptPath));
- runner.runScript(con, true);
- messages.addAll(runner.getMessages());
- }
-
- successMessage("Doing upgrade to 200 ...");
- successMessage("Populating roller_user_permissions table");
-
- PreparedStatement websitesQuery = con.prepareStatement(
- "select w.id as wid, u.id as uid, u.username as uname from
"
- + "website as w, rolleruser as u where u.id=w.userid");
- PreparedStatement websiteUpdate = con.prepareStatement(
- "update website set handle=? where id=?");
- PreparedStatement entryUpdate = con.prepareStatement(
- "update weblogentry set userid=?, status=?, "
- + "pubtime=pubtime, updatetime=updatetime "
- + "where publishentry=? and websiteid=?");
- PreparedStatement permsInsert = con.prepareStatement(
- "insert into roller_permissions "
- + "(id, username, actions, objectid, objecttype, pending,
datecreated) "
- + "values (?,?,?,?,?,?,?)");
-
- // loop through websites, each has a user
- java.sql.Date now = new java.sql.Date(new Date().getTime());
- ResultSet websiteSet = websitesQuery.executeQuery();
- while (websiteSet.next()) {
- String websiteid = websiteSet.getString("wid");
- String userid = websiteSet.getString("uid");
- String username = websiteSet.getString("uname");
- successMessage("Processing website: " + username);
-
- // use website user's username as website handle
- websiteUpdate.clearParameters();
- websiteUpdate.setString(1, username);
- websiteUpdate.setString(2, websiteid);
- websiteUpdate.executeUpdate();
-
- // update all of pubished entries to include userid and status
- entryUpdate.clearParameters();
- entryUpdate.setString( 1, userid);
- entryUpdate.setString( 2, "PUBLISHED");
- entryUpdate.setBoolean(3, true);
- entryUpdate.setString( 4, websiteid);
- entryUpdate.executeUpdate();
-
- // update all of draft entries to include userid and status
- entryUpdate.clearParameters();
- entryUpdate.setString( 1, userid);
- entryUpdate.setString( 2, "DRAFT");
- entryUpdate.setBoolean(3, false);
- entryUpdate.setString( 4, websiteid);
- entryUpdate.executeUpdate();
-
- // add permission for user in website
- permsInsert.clearParameters();
- permsInsert.setString( 1, websiteid+"p");
- permsInsert.setString( 2, username);
- permsInsert.setString( 3, WeblogPermission.ADMIN);
- permsInsert.setString( 4, websiteid);
- permsInsert.setString( 5, "Weblog");
- permsInsert.setBoolean(6, false);
- permsInsert.setDate( 7, now);
- permsInsert.setBoolean(5, false);
- permsInsert.executeUpdate();
- }
-
- if (!con.getAutoCommit()) con.commit();
-
- successMessage("Upgrade to 200 complete.");
-
- } catch (Exception e) {
- log.error("ERROR running 310 database upgrade script", e);
- if (runner != null) messages.addAll(runner.getMessages());
-
- errorMessage("Problem upgrading database to version 200", e);
- throw new StartupException("Problem upgrading database to version
200", e);
- }
-
- updateDatabaseVersion(con, 200);
- }
-
-
- /**
- * Upgrade database for Roller 2.1.0
- */
- private void upgradeTo210(Connection con, boolean runScripts) throws
StartupException {
- SQLScriptRunner runner = null;
- try {
- if (runScripts) {
- String handle = getDatabaseHandle(con);
- String scriptPath = handle + "/200-to-210-migration.sql";
- successMessage("Running database upgrade script:
"+scriptPath);
- runner = new
SQLScriptRunner(scripts.getDatabaseScript(scriptPath));
- runner.runScript(con, true);
- messages.addAll(runner.getMessages());
- }
-
- /*
- * For Roller 2.1.0 we are going to standardize some of the
- * weblog templates and make them less editable. To do this
- * we need to do a little surgery.
- *
- * The goal for this upgrade is to ensure that ALL weblogs now have
- * the required "Weblog" template as their default template.
- */
-
- successMessage("Doing upgrade to 210 ...");
- successMessage("Ensuring that all weblogs use the 'Weblog'
template as their default page");
-
- // this query will give us all websites that have modified their
- // default page to link to something other than "Weblog"
- PreparedStatement selectUpdateWeblogs = con.prepareStatement(
- "select website.id,template,website.handle from
website,webpage "+
- "where webpage.id = website.defaultpageid "+
- "and webpage.link != 'Weblog'");
-
- PreparedStatement selectWeblogTemplate = con.prepareStatement(
- "select id from webpage where websiteid = ? and link =
'Weblog'");
-
- PreparedStatement updateWeblogTemplate = con.prepareStatement(
- "update webpage set template = ? where id = ?");
-
- // insert a new template for a website
- PreparedStatement insertWeblogTemplate = con.prepareStatement(
- "insert into webpage"+
- "(id, name, description, link, websiteid, template,
updatetime) "+
- "values(?,?,?,?,?,?,?)");
-
- // update the default page for a website
- PreparedStatement updateDefaultPage = con.prepareStatement(
- "update website set defaultpageid = ? "+
- "where id = ?");
-
- String description = "This template is used to render the main "+
- "page of your weblog.";
- ResultSet websiteSet = selectUpdateWeblogs.executeQuery();
- Date now = new Date();
- while (websiteSet.next()) {
- String websiteid = websiteSet.getString(1);
- String template = websiteSet.getString(2);
- String handle = websiteSet.getString(3);
- successMessage("Processing website: " + handle);
-
- String defaultpageid = null;
-
- // it's possible that this weblog has a "Weblog" template, but
just
- // isn't using it as their default. if so we need to fix that.
- selectWeblogTemplate.clearParameters();
- selectWeblogTemplate.setString(1, websiteid);
- ResultSet weblogPageSet = selectWeblogTemplate.executeQuery();
- if(weblogPageSet.next()) {
- // this person already has a "Weblog" template, so update
it
- String id = weblogPageSet.getString(1);
-
- updateWeblogTemplate.clearParameters();
- updateWeblogTemplate.setString(1, template);
- updateWeblogTemplate.setString(2, id);
- updateWeblogTemplate.executeUpdate();
-
- // make sure and adjust what default page id we want to use
- defaultpageid = id;
- } else {
- // no "Weblog" template, so insert a new one
- insertWeblogTemplate.clearParameters();
- insertWeblogTemplate.setString( 1, websiteid+"q");
- insertWeblogTemplate.setString( 2, "Weblog");
- insertWeblogTemplate.setString( 3, description);
- insertWeblogTemplate.setString( 4, "Weblog");
- insertWeblogTemplate.setString( 5, websiteid);
- insertWeblogTemplate.setString( 6, template);
- insertWeblogTemplate.setDate( 7, new
java.sql.Date(now.getTime()));
- insertWeblogTemplate.executeUpdate();
-
- // set the new default page id
- defaultpageid = websiteid+"q";
- }
-
- // update defaultpageid value
- updateDefaultPage.clearParameters();
- updateDefaultPage.setString( 1, defaultpageid);
- updateDefaultPage.setString( 2, websiteid);
- updateDefaultPage.executeUpdate();
- }
-
-
- if (!con.getAutoCommit()) con.commit();
-
- successMessage("Upgrade to 210 complete.");
-
- } catch (Exception e) {
- log.error("ERROR running 310 database upgrade script", e);
- if (runner != null) messages.addAll(runner.getMessages());
-
- log.error("Problem upgrading database to version 210", e);
- throw new StartupException("Problem upgrading database to version
210", e);
- }
-
- updateDatabaseVersion(con, 210);
- }
-
-
- /**
- * Upgrade database for Roller 2.3.0
- */
- private void upgradeTo230(Connection con, boolean runScripts) throws
StartupException {
- SQLScriptRunner runner = null;
- try {
- if (runScripts) {
- String handle = getDatabaseHandle(con);
- String scriptPath = handle + "/210-to-230-migration.sql";
- successMessage("Running database upgrade script:
"+scriptPath);
- runner = new
SQLScriptRunner(scripts.getDatabaseScript(scriptPath));
- runner.runScript(con, true);
- messages.addAll(runner.getMessages());
- }
- } catch (Exception e) {
- log.error("ERROR running 310 database upgrade script", e);
- if (runner != null) messages.addAll(runner.getMessages());
-
- errorMessage("Problem upgrading database to version 230", e);
- throw new StartupException("Problem upgrading database to version
230", e);
- }
-
- updateDatabaseVersion(con, 230);
- }
-
-
- /**
- * Upgrade database for Roller 2.4.0
- */
- private void upgradeTo240(Connection con, boolean runScripts) throws
StartupException {
- SQLScriptRunner runner = null;
- try {
- if (runScripts) {
- String handle = getDatabaseHandle(con);
- String scriptPath = handle + "/230-to-240-migration.sql";
- successMessage("Running database upgrade script:
"+scriptPath);
- runner = new
SQLScriptRunner(scripts.getDatabaseScript(scriptPath));
- runner.runScript(con, true);
- messages.addAll(runner.getMessages());
- }
- } catch (Exception e) {
- log.error("ERROR running 310 database upgrade script", e);
- if (runner != null) messages.addAll(runner.getMessages());
-
- errorMessage("Problem upgrading database to version 240", e);
- throw new StartupException("Problem upgrading database to version
240", e);
- }
-
- updateDatabaseVersion(con, 240);
- }
-
-
- /**
- * Upgrade database for Roller 3.0.0
- */
- private void upgradeTo300(Connection con, boolean runScripts) throws
StartupException {
- SQLScriptRunner runner = null;
- try {
- if (runScripts) {
- String handle = getDatabaseHandle(con);
- String scriptPath = handle + "/240-to-300-migration.sql";
- successMessage("Running database upgrade script:
"+scriptPath);
- runner = new
SQLScriptRunner(scripts.getDatabaseScript(scriptPath));
- runner.runScript(con, true);
- messages.addAll(runner.getMessages());
- }
-
- /*
- * For Roller 3.0.0 we are allowing each weblogentry to track a
- * locale now so that we can support multi-lingual blogs. As part
- * of the upgrade process we want to do 2 things ..
- *
- * 1. make sure all weblogs have a locale
- * 2. set the locale on all entries to the locale for the weblog
- */
-
- successMessage("Doing upgrade to 300 ...");
-
- // get system default language
- String locale = java.util.Locale.getDefault().getLanguage();
-
- successMessage("Setting website locale to "+locale+" for websites
with no locale");
-
- // update all weblogs where locale is "null"
- PreparedStatement updateNullWeblogLocale = con.prepareStatement(
- "update website set locale = ? where locale is NULL");
- // update all weblogs where locale is empty string ""
- PreparedStatement updateEmptyWeblogLocale = con.prepareStatement(
- "update website set locale = ? where locale = ''");
- updateNullWeblogLocale.setString( 1, locale);
- updateEmptyWeblogLocale.setString( 1, locale);
- updateNullWeblogLocale.executeUpdate();
- updateEmptyWeblogLocale.executeUpdate();
-
- successMessage("Setting weblogentry locales to website locale");
-
- // get all entries and the locale of its website
- PreparedStatement selectWeblogsLocale = con.prepareStatement(
- "select weblogentry.id,website.locale "+
- "from weblogentry,website "+
- "where weblogentry.websiteid = website.id");
-
- // set the locale for an entry
- PreparedStatement updateWeblogLocale = con.prepareStatement(
- "update weblogentry set locale = ? where id = ?");
-
- ResultSet websiteSet = selectWeblogsLocale.executeQuery();
- while (websiteSet.next()) {
- String entryid = websiteSet.getString(1);
- String entrylocale = websiteSet.getString(2);
-
- // update entry locale
- updateWeblogLocale.clearParameters();
- updateWeblogLocale.setString( 1, entrylocale);
- updateWeblogLocale.setString( 2, entryid);
- updateWeblogLocale.executeUpdate();
- }
-
-
- if (!con.getAutoCommit()) con.commit();
-
- successMessage("Upgrade to 300 complete.");
-
- } catch (Exception e) {
- log.error("ERROR running 310 database upgrade script", e);
- if (runner != null) messages.addAll(runner.getMessages());
-
- errorMessage("Problem upgrading database to version 300", e);
- throw new StartupException("Problem upgrading database to version
300", e);
- }
-
- updateDatabaseVersion(con, 300);
- }
-
-
- /**
- * Upgrade database for Roller 3.1.0
- */
- private void upgradeTo310(Connection con, boolean runScripts) throws
StartupException {
- SQLScriptRunner runner = null;
- try {
- if (runScripts) {
- String handle = getDatabaseHandle(con);
- String scriptPath = handle + "/300-to-310-migration.sql";
- successMessage("Running database upgrade script:
"+scriptPath);
- runner = new
SQLScriptRunner(scripts.getDatabaseScript(scriptPath));
- runner.runScript(con, true);
- messages.addAll(runner.getMessages());
- }
- } catch (Exception e) {
- log.error("ERROR running 310 database upgrade script", e);
- if (runner != null) messages.addAll(runner.getMessages());
-
- errorMessage("Problem upgrading database to version 310", e);
- throw new StartupException("Problem upgrading database to version
310", e);
- }
-
- updateDatabaseVersion(con, 310);
- }
-
-
/**
* Upgrade database for Roller 4.0.0
*/
Modified: roller/trunk/app/src/main/resources/sql/dbscripts.properties
URL:
http://svn.apache.org/viewvc/roller/trunk/app/src/main/resources/sql/dbscripts.properties?rev=1506004&r1=1506003&r2=1506004&view=diff
==============================================================================
--- roller/trunk/app/src/main/resources/sql/dbscripts.properties (original)
+++ roller/trunk/app/src/main/resources/sql/dbscripts.properties Tue Jul 23
12:04:26 2013
@@ -5,7 +5,5 @@
databases=db2 derby hsqldb mssql mysql oracle postgresql
# list all db templates to generate, separated by spaces
-templates=createdb 200-to-210-migration 210-to-230-migration \
-230-to-240-migration 240-to-300-migration 300-to-310-migration \
-310-to-400-migration 400-to-500-migration 500-to-510-migration
-
+templates=createdb 310-to-400-migration 400-to-500-migration \
+500-to-510-migration