From 2c269835d82350f171b83f94fdea138b30a4bf7a Mon Sep 17 00:00:00 2001 From: Michael Bien Date: Mon, 21 Sep 2020 14:51:24 +0200 Subject: [PATCH 1/2] added missing roller 6.1 db table upgrade functionality. --- .../business/startup/DatabaseInstaller.java | 72 +++++++------------ .../resources/sql/520-to-610-migration.vm | 7 ++ .../main/resources/sql/dbscripts.properties | 2 +- app/src/main/resources/sql/macros.vm | 14 ++++ 4 files changed, 48 insertions(+), 47 deletions(-) create mode 100644 app/src/main/resources/sql/520-to-610-migration.vm diff --git a/app/src/main/java/org/apache/roller/weblogger/business/startup/DatabaseInstaller.java b/app/src/main/java/org/apache/roller/weblogger/business/startup/DatabaseInstaller.java index d3705791ef..f1df8947f7 100644 --- a/app/src/main/java/org/apache/roller/weblogger/business/startup/DatabaseInstaller.java +++ b/app/src/main/java/org/apache/roller/weblogger/business/startup/DatabaseInstaller.java @@ -246,6 +246,10 @@ public void upgradeDatabase(boolean runScripts) throws StartupException { upgradeTo520(con, runScripts); dbversion = 520; } + if(dbversion < 610) { + upgradeTo610(con, runScripts); + dbversion = 610; + } // make sure the database version is the exact version // we are upgrading too. @@ -709,80 +713,56 @@ private void upgradeTo400(Connection con, boolean runScripts) throws StartupExce * Upgrade database to Roller 5.0 */ private void upgradeTo500(Connection con, boolean runScripts) throws StartupException { - - // first we need to run upgrade scripts - SQLScriptRunner runner = null; - try { - if (runScripts) { - String handle = getDatabaseHandle(con); - String scriptPath = handle + "/400-to-500-migration.sql"; - successMessage("Running database upgrade script: "+scriptPath); - runner = new SQLScriptRunner(scripts.getDatabaseScript(scriptPath)); - runner.runScript(con, true); - messages.addAll(runner.getMessages()); - } - } catch(Exception ex) { - log.error("ERROR running 500 database upgrade script", ex); - if (runner != null) { - messages.addAll(runner.getMessages()); - } - - errorMessage("Problem upgrading database to version 500", ex); - throw new StartupException("Problem upgrading database to version 500", ex); - } + simpleUpgrade(con, 400, 500, runScripts); } /** * Upgrade database to Roller 5.1 */ private void upgradeTo510(Connection con, boolean runScripts) throws StartupException { - - // first we need to run upgrade scripts - SQLScriptRunner runner = null; - try { - if (runScripts) { - String handle = getDatabaseHandle(con); - String scriptPath = handle + "/500-to-510-migration.sql"; - successMessage("Running database upgrade script: "+scriptPath); - runner = new SQLScriptRunner(scripts.getDatabaseScript(scriptPath)); - runner.runScript(con, true); - messages.addAll(runner.getMessages()); - } - } catch(Exception ex) { - log.error("ERROR running 510 database upgrade script", ex); - if (runner != null) { - messages.addAll(runner.getMessages()); - } - - errorMessage("Problem upgrading database to version 510", ex); - throw new StartupException("Problem upgrading database to version 510", ex); - } + simpleUpgrade(con, 500, 510, runScripts); } /** * Upgrade database to Roller 5.2 */ private void upgradeTo520(Connection con, boolean runScripts) throws StartupException { + simpleUpgrade(con, 510, 520, runScripts); + } + + /** + * Upgrade database to Roller 6.1 + */ + private void upgradeTo610(Connection con, boolean runScripts) throws StartupException { + simpleUpgrade(con, 520, 610, runScripts); + } + + /** + * Simple upgrade using single SQL migration script. + */ + private void simpleUpgrade(Connection con, int fromVersion, int toVersion, boolean runScripts) throws StartupException { // first we need to run upgrade scripts SQLScriptRunner runner = null; try { if (runScripts) { String handle = getDatabaseHandle(con); - String scriptPath = handle + "/510-to-520-migration.sql"; + String scriptPath = handle + "/"+fromVersion+"-to-"+toVersion+"-migration.sql"; + successMessage("Running database upgrade script: "+scriptPath); + runner = new SQLScriptRunner(scripts.getDatabaseScript(scriptPath)); runner.runScript(con, true); messages.addAll(runner.getMessages()); } } catch(Exception ex) { - log.error("ERROR running 520 database upgrade script", ex); + log.error("ERROR running "+fromVersion+"->"+toVersion+" database upgrade script", ex); if (runner != null) { messages.addAll(runner.getMessages()); } - errorMessage("Problem upgrading database to version 520", ex); - throw new StartupException("Problem upgrading database to version 520", ex); + errorMessage("Problem upgrading database to version "+toVersion, ex); + throw new StartupException("Problem upgrading database to version "+toVersion, ex); } } diff --git a/app/src/main/resources/sql/520-to-610-migration.vm b/app/src/main/resources/sql/520-to-610-migration.vm new file mode 100644 index 0000000000..35599ed6cc --- /dev/null +++ b/app/src/main/resources/sql/520-to-610-migration.vm @@ -0,0 +1,7 @@ +#** + 520-to-610-migration.vm: Velocity template that generates vendor-specific database scripts + + DON'T RUN THIS, IT'S NOT A DATABASE CREATION SCRIPT!!! + **# + +#alterColumnName('weblog' 'blacklist' 'bannedwordslist') diff --git a/app/src/main/resources/sql/dbscripts.properties b/app/src/main/resources/sql/dbscripts.properties index 0e773a6aa7..9cc8184f7b 100644 --- a/app/src/main/resources/sql/dbscripts.properties +++ b/app/src/main/resources/sql/dbscripts.properties @@ -6,4 +6,4 @@ databases=db2 derby hsqldb mssql mysql oracle postgresql # list all db templates to generate, separated by spaces templates=createdb 310-to-400-migration 400-to-500-migration \ -500-to-510-migration 510-to-520-migration +500-to-510-migration 510-to-520-migration 520-to-610-migration diff --git a/app/src/main/resources/sql/macros.vm b/app/src/main/resources/sql/macros.vm index 7754c608a2..0c74ddd470 100644 --- a/app/src/main/resources/sql/macros.vm +++ b/app/src/main/resources/sql/macros.vm @@ -160,4 +160,18 @@ alter table $tableName alter column $columnName $columnType; #else -- You should alter type of column $columnName of table $tableName to $columnType #end +#end + +#** +Rename a table column. +this is trivial generic SQL - this should work everywhere, right? +**# +#macro(alterColumnName $tableName $columnName $newColumnName) +#if ($db.DBTYPE == "MSSQL") +sp_rename '$tableName.$columnName', '$newColumnName', 'COLUMN'; +#elseif ($db.DBTYPE == "HSQLDB") +alter table $tableName alter column $columnName rename to $newColumnName; +#else +alter table $tableName rename column $columnName to $newColumnName; +#end #end \ No newline at end of file From ac26e05be99c4f68358618e57c499aeaca2416a3 Mon Sep 17 00:00:00 2001 From: Michael Bien Date: Tue, 6 Oct 2020 18:20:50 +0200 Subject: [PATCH 2/2] updated dependencies + JDK16 compatibility. updated maven dependencies - guice 5 can be used again without the noaop tag on latest jdks - asm, spring, lucene, velocity etc updated webjars - bootstrap 3.4.1 is the last version before 4.x which comes with breaking changes checked JDK16 compatibility - required war plugin update in selenium pom --- app/pom.xml | 38 +++++++++---------- .../main/webapp/WEB-INF/jsps/tiles/head.jsp | 16 ++++---- it-selenium/pom.xml | 9 ++++- pom.xml | 4 +- 4 files changed, 37 insertions(+), 30 deletions(-) diff --git a/app/pom.xml b/app/pom.xml index fc76577fc1..045f24eb6f 100644 --- a/app/pom.xml +++ b/app/pom.xml @@ -39,26 +39,26 @@ limitations under the License. 1.4.7 1.2 1.7.8 - 1.10.8 - 9.0-beta + 1.10.9 + 9.1 1.7 1.9.4 3.1 1.15 - 2.7.7 - 4.2.3 - 2.13.3 - 8.6.2 + 2.7.8 + 5.0.1 + 2.14.1 + 8.8.1 20100527 3.2.3 - 2.17 + 2.22.2 1.0b3 1.15.0 1.7.30 - 5.2.9.RELEASE - 5.4.0 - 2.5.22 - 2.2 + 5.3.5 + 5.4.5 + 2.5.26 + 2.3 1.5 1.0.2 1.3.0 @@ -251,23 +251,24 @@ limitations under the License. struts2-tiles-plugin ${struts.version} - + + org.webjars bootstrap - 3.3.7 + 3.4.1 org.webjars clipboard.js - 2.0.0 + 2.0.6 org.webjars jquery - 3.3.1 + 3.6.0 @@ -279,13 +280,13 @@ limitations under the License. org.webjars.bower summernote - 0.8.11 + 0.8.12 org.webjars jquery-validation - 1.19.0 + 1.19.3 @@ -499,7 +500,6 @@ limitations under the License. com.google.inject guice ${guice.version} - no_aop aopalliance @@ -744,7 +744,7 @@ limitations under the License. maven-surefire-plugin - 2.22.0 + ${maven-surefire.version} diff --git a/app/src/main/webapp/WEB-INF/jsps/tiles/head.jsp b/app/src/main/webapp/WEB-INF/jsps/tiles/head.jsp index 8a31d67ef0..f205baf26b 100644 --- a/app/src/main/webapp/WEB-INF/jsps/tiles/head.jsp +++ b/app/src/main/webapp/WEB-INF/jsps/tiles/head.jsp @@ -5,21 +5,21 @@ You can override it with your own file via WEB-INF/tiles-def.xml <%@ include file="/WEB-INF/jsps/taglibs-struts2.jsp" %> - + - + - - - + + + - + - - + + diff --git a/it-selenium/pom.xml b/it-selenium/pom.xml index d2e7559a9b..5c94bac536 100644 --- a/it-selenium/pom.xml +++ b/it-selenium/pom.xml @@ -120,7 +120,14 @@ - + + + + maven-war-plugin + 3.3.1 + + maven-failsafe-plugin diff --git a/pom.xml b/pom.xml index 1269eb78fe..4f2256888d 100644 --- a/pom.xml +++ b/pom.xml @@ -92,7 +92,7 @@ limitations under the License. org.codehaus.mojo versions-maven-plugin - 2.7 + 2.8.1 file:version-rules.xml @@ -106,7 +106,7 @@ limitations under the License. org.junit.jupiter junit-jupiter-engine - 5.6.2 + 5.7.1 test