Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Roller 6.1 db table upgrade logic + maven dependency upgrades #82

Merged
merged 2 commits into from
Mar 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,26 @@ limitations under the License.
<java-mail.version>1.4.7</java-mail.version>
<jstl.version>1.2</jstl.version>
<angular.version>1.7.8</angular.version>
<ant.version>1.10.8</ant.version>
<asm.version>9.0-beta</asm.version>
<ant.version>1.10.9</ant.version>
<asm.version>9.1</asm.version>
<commons-validator.version>1.7</commons-validator.version>
<commons-beanutils.version>1.9.4</commons-beanutils.version>
<commons-httpclient.version>3.1</commons-httpclient.version>
<commons-codec.version>1.15</commons-codec.version>
<eclipse-link.version>2.7.7</eclipse-link.version>
<guice.version>4.2.3</guice.version>
<log4j2.version>2.13.3</log4j2.version>
<lucene.version>8.6.2</lucene.version>
<eclipse-link.version>2.7.8</eclipse-link.version>
<guice.version>5.0.1</guice.version>
<log4j2.version>2.14.1</log4j2.version>
<lucene.version>8.8.1</lucene.version>
<oauth-core.version>20100527</oauth-core.version>
<maven-war.version>3.2.3</maven-war.version>
<maven-surefire.version>2.17</maven-surefire.version>
<maven-surefire.version>2.22.2</maven-surefire.version>
<maven-antrun.version>1.0b3</maven-antrun.version>
<rome.version>1.15.0</rome.version>
<slf4j.version>1.7.30</slf4j.version>
<spring.version>5.2.9.RELEASE</spring.version>
<spring.security.version>5.4.0</spring.security.version>
<struts.version>2.5.22</struts.version>
<velocity.version>2.2</velocity.version>
<spring.version>5.3.5</spring.version>
<spring.security.version>5.4.5</spring.security.version>
<struts.version>2.5.26</struts.version>
<velocity.version>2.3</velocity.version>
<webjars.version>1.5</webjars.version>
<ws-commons-util.version>1.0.2</ws-commons-util.version>
<xml-security.version>1.3.0</xml-security.version>
Expand Down Expand Up @@ -251,23 +251,24 @@ limitations under the License.
<artifactId>struts2-tiles-plugin</artifactId>
<version>${struts.version}</version>
</dependency>


<!-- note: update head.jsp on webjar version change -->
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>3.3.7</version>
<version>3.4.1</version>
</dependency>

<dependency>
<groupId>org.webjars</groupId>
<artifactId>clipboard.js</artifactId>
<version>2.0.0</version>
<version>2.0.6</version>
</dependency>

<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>3.3.1</version>
<version>3.6.0</version>
</dependency>

<dependency>
Expand All @@ -279,13 +280,13 @@ limitations under the License.
<dependency>
<groupId>org.webjars.bower</groupId>
<artifactId>summernote</artifactId>
<version>0.8.11</version>
<version>0.8.12</version>
</dependency>

<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery-validation</artifactId>
<version>1.19.0</version>
<version>1.19.3</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -499,7 +500,6 @@ limitations under the License.
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>${guice.version}</version>
<classifier>no_aop</classifier>
<exclusions>
<exclusion>
<groupId>aopalliance</groupId>
Expand Down Expand Up @@ -744,7 +744,7 @@ limitations under the License.

<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<version>${maven-surefire.version}</version>
<configuration>
<systemProperties>
<property>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
}
}

Expand Down
7 changes: 7 additions & 0 deletions app/src/main/resources/sql/520-to-610-migration.vm
Original file line number Diff line number Diff line change
@@ -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')
2 changes: 1 addition & 1 deletion app/src/main/resources/sql/dbscripts.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 14 additions & 0 deletions app/src/main/resources/sql/macros.vm
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 8 additions & 8 deletions app/src/main/webapp/WEB-INF/jsps/tiles/head.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -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" %>

<script src="<s:url value='/webjars/jquery/3.3.1/jquery.min.js' />"></script>
<script src="<s:url value='/webjars/jquery/3.6.0/jquery.min.js' />"></script>

<script src="<s:url value='/webjars/jquery-ui/1.12.1/jquery-ui.min.js' />"></script>
<link href="<s:url value='/webjars/jquery-ui/1.12.1/jquery-ui.css' />" rel="stylesheet" />

<script src="<s:url value='/webjars/jquery-validation/1.19.0/jquery.validate.min.js' />"></script>
<script src="<s:url value='/webjars/jquery-validation/1.19.3/jquery.validate.min.js' />"></script>

<link href="<s:url value='/webjars/bootstrap/3.3.7/css/bootstrap.min.css' />" rel="stylesheet" />
<link href="<s:url value='/webjars/bootstrap/3.3.7/css/bootstrap-theme.min.css' />" rel="stylesheet" />
<script src="<s:url value='/webjars/bootstrap/3.3.7/js/bootstrap.min.js' />"></script>
<link href="<s:url value='/webjars/bootstrap/3.4.1/css/bootstrap.min.css' />" rel="stylesheet" />
<link href="<s:url value='/webjars/bootstrap/3.4.1/css/bootstrap-theme.min.css' />" rel="stylesheet" />
<script src="<s:url value='/webjars/bootstrap/3.4.1/js/bootstrap.min.js' />"></script>

<script src="<s:url value='/webjars/clipboard.js/2.0.0/clipboard.min.js' />"></script>
<script src="<s:url value='/webjars/clipboard.js/2.0.6/clipboard.min.js' />"></script>

<script src="<s:url value='/webjars/summernote/0.8.11/dist/summernote.min.js' />"></script>
<link href="<s:url value='/webjars/summernote/0.8.11/dist/summernote.css' />" rel="stylesheet" />
<script src="<s:url value='/webjars/summernote/0.8.12/dist/summernote.min.js' />"></script>
<link href="<s:url value='/webjars/summernote/0.8.12/dist/summernote.css' />" rel="stylesheet" />

<link rel="stylesheet" media="all" href='<s:url value="/roller-ui/styles/roller.css"/>' />

Expand Down
9 changes: 8 additions & 1 deletion it-selenium/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,14 @@

<build>
<plugins>


<!-- bump plugin version for JDK 16 compatibility (old guice version),
can be removed once maven itself bumped the version -->
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
</plugin>

<!-- Activates integration tests (by default, classes under tests that end with "IT") -->
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ limitations under the License.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.7</version>
<version>2.8.1</version>
<configuration>
<rulesUri>file:version-rules.xml</rulesUri>
</configuration>
Expand All @@ -106,7 +106,7 @@ limitations under the License.
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.6.2</version>
<version>5.7.1</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down