Skip to content

Commit 664ec33

Browse files
authored
Merge pull request #82 from mbien/table_upgrade
Roller 6.1 db table upgrade logic + maven dependency upgrades
2 parents ad63868 + ac26e05 commit 664ec33

File tree

8 files changed

+85
-77
lines changed

8 files changed

+85
-77
lines changed

app/pom.xml

+19-19
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,26 @@ limitations under the License.
3939
<java-mail.version>1.4.7</java-mail.version>
4040
<jstl.version>1.2</jstl.version>
4141
<angular.version>1.7.8</angular.version>
42-
<ant.version>1.10.8</ant.version>
43-
<asm.version>9.0-beta</asm.version>
42+
<ant.version>1.10.9</ant.version>
43+
<asm.version>9.1</asm.version>
4444
<commons-validator.version>1.7</commons-validator.version>
4545
<commons-beanutils.version>1.9.4</commons-beanutils.version>
4646
<commons-httpclient.version>3.1</commons-httpclient.version>
4747
<commons-codec.version>1.15</commons-codec.version>
48-
<eclipse-link.version>2.7.7</eclipse-link.version>
49-
<guice.version>4.2.3</guice.version>
50-
<log4j2.version>2.13.3</log4j2.version>
51-
<lucene.version>8.6.2</lucene.version>
48+
<eclipse-link.version>2.7.8</eclipse-link.version>
49+
<guice.version>5.0.1</guice.version>
50+
<log4j2.version>2.14.1</log4j2.version>
51+
<lucene.version>8.8.1</lucene.version>
5252
<oauth-core.version>20100527</oauth-core.version>
5353
<maven-war.version>3.2.3</maven-war.version>
54-
<maven-surefire.version>2.17</maven-surefire.version>
54+
<maven-surefire.version>2.22.2</maven-surefire.version>
5555
<maven-antrun.version>1.0b3</maven-antrun.version>
5656
<rome.version>1.15.0</rome.version>
5757
<slf4j.version>1.7.30</slf4j.version>
58-
<spring.version>5.2.9.RELEASE</spring.version>
59-
<spring.security.version>5.4.0</spring.security.version>
60-
<struts.version>2.5.22</struts.version>
61-
<velocity.version>2.2</velocity.version>
58+
<spring.version>5.3.5</spring.version>
59+
<spring.security.version>5.4.5</spring.security.version>
60+
<struts.version>2.5.26</struts.version>
61+
<velocity.version>2.3</velocity.version>
6262
<webjars.version>1.5</webjars.version>
6363
<ws-commons-util.version>1.0.2</ws-commons-util.version>
6464
<xml-security.version>1.3.0</xml-security.version>
@@ -251,23 +251,24 @@ limitations under the License.
251251
<artifactId>struts2-tiles-plugin</artifactId>
252252
<version>${struts.version}</version>
253253
</dependency>
254-
254+
255+
<!-- note: update head.jsp on webjar version change -->
255256
<dependency>
256257
<groupId>org.webjars</groupId>
257258
<artifactId>bootstrap</artifactId>
258-
<version>3.3.7</version>
259+
<version>3.4.1</version>
259260
</dependency>
260261

261262
<dependency>
262263
<groupId>org.webjars</groupId>
263264
<artifactId>clipboard.js</artifactId>
264-
<version>2.0.0</version>
265+
<version>2.0.6</version>
265266
</dependency>
266267

267268
<dependency>
268269
<groupId>org.webjars</groupId>
269270
<artifactId>jquery</artifactId>
270-
<version>3.3.1</version>
271+
<version>3.6.0</version>
271272
</dependency>
272273

273274
<dependency>
@@ -279,13 +280,13 @@ limitations under the License.
279280
<dependency>
280281
<groupId>org.webjars.bower</groupId>
281282
<artifactId>summernote</artifactId>
282-
<version>0.8.11</version>
283+
<version>0.8.12</version>
283284
</dependency>
284285

285286
<dependency>
286287
<groupId>org.webjars</groupId>
287288
<artifactId>jquery-validation</artifactId>
288-
<version>1.19.0</version>
289+
<version>1.19.3</version>
289290
</dependency>
290291

291292
<dependency>
@@ -499,7 +500,6 @@ limitations under the License.
499500
<groupId>com.google.inject</groupId>
500501
<artifactId>guice</artifactId>
501502
<version>${guice.version}</version>
502-
<classifier>no_aop</classifier>
503503
<exclusions>
504504
<exclusion>
505505
<groupId>aopalliance</groupId>
@@ -744,7 +744,7 @@ limitations under the License.
744744

745745
<plugin>
746746
<artifactId>maven-surefire-plugin</artifactId>
747-
<version>2.22.0</version>
747+
<version>${maven-surefire.version}</version>
748748
<configuration>
749749
<systemProperties>
750750
<property>

app/src/main/java/org/apache/roller/weblogger/business/startup/DatabaseInstaller.java

+26-46
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,10 @@ public void upgradeDatabase(boolean runScripts) throws StartupException {
246246
upgradeTo520(con, runScripts);
247247
dbversion = 520;
248248
}
249+
if(dbversion < 610) {
250+
upgradeTo610(con, runScripts);
251+
dbversion = 610;
252+
}
249253

250254
// make sure the database version is the exact version
251255
// we are upgrading too.
@@ -709,80 +713,56 @@ private void upgradeTo400(Connection con, boolean runScripts) throws StartupExce
709713
* Upgrade database to Roller 5.0
710714
*/
711715
private void upgradeTo500(Connection con, boolean runScripts) throws StartupException {
712-
713-
// first we need to run upgrade scripts
714-
SQLScriptRunner runner = null;
715-
try {
716-
if (runScripts) {
717-
String handle = getDatabaseHandle(con);
718-
String scriptPath = handle + "/400-to-500-migration.sql";
719-
successMessage("Running database upgrade script: "+scriptPath);
720-
runner = new SQLScriptRunner(scripts.getDatabaseScript(scriptPath));
721-
runner.runScript(con, true);
722-
messages.addAll(runner.getMessages());
723-
}
724-
} catch(Exception ex) {
725-
log.error("ERROR running 500 database upgrade script", ex);
726-
if (runner != null) {
727-
messages.addAll(runner.getMessages());
728-
}
729-
730-
errorMessage("Problem upgrading database to version 500", ex);
731-
throw new StartupException("Problem upgrading database to version 500", ex);
732-
}
716+
simpleUpgrade(con, 400, 500, runScripts);
733717
}
734718

735719
/**
736720
* Upgrade database to Roller 5.1
737721
*/
738722
private void upgradeTo510(Connection con, boolean runScripts) throws StartupException {
739-
740-
// first we need to run upgrade scripts
741-
SQLScriptRunner runner = null;
742-
try {
743-
if (runScripts) {
744-
String handle = getDatabaseHandle(con);
745-
String scriptPath = handle + "/500-to-510-migration.sql";
746-
successMessage("Running database upgrade script: "+scriptPath);
747-
runner = new SQLScriptRunner(scripts.getDatabaseScript(scriptPath));
748-
runner.runScript(con, true);
749-
messages.addAll(runner.getMessages());
750-
}
751-
} catch(Exception ex) {
752-
log.error("ERROR running 510 database upgrade script", ex);
753-
if (runner != null) {
754-
messages.addAll(runner.getMessages());
755-
}
756-
757-
errorMessage("Problem upgrading database to version 510", ex);
758-
throw new StartupException("Problem upgrading database to version 510", ex);
759-
}
723+
simpleUpgrade(con, 500, 510, runScripts);
760724
}
761725

762726
/**
763727
* Upgrade database to Roller 5.2
764728
*/
765729
private void upgradeTo520(Connection con, boolean runScripts) throws StartupException {
730+
simpleUpgrade(con, 510, 520, runScripts);
731+
}
732+
733+
/**
734+
* Upgrade database to Roller 6.1
735+
*/
736+
private void upgradeTo610(Connection con, boolean runScripts) throws StartupException {
737+
simpleUpgrade(con, 520, 610, runScripts);
738+
}
739+
740+
/**
741+
* Simple upgrade using single SQL migration script.
742+
*/
743+
private void simpleUpgrade(Connection con, int fromVersion, int toVersion, boolean runScripts) throws StartupException {
766744

767745
// first we need to run upgrade scripts
768746
SQLScriptRunner runner = null;
769747
try {
770748
if (runScripts) {
771749
String handle = getDatabaseHandle(con);
772-
String scriptPath = handle + "/510-to-520-migration.sql";
750+
String scriptPath = handle + "/"+fromVersion+"-to-"+toVersion+"-migration.sql";
751+
773752
successMessage("Running database upgrade script: "+scriptPath);
753+
774754
runner = new SQLScriptRunner(scripts.getDatabaseScript(scriptPath));
775755
runner.runScript(con, true);
776756
messages.addAll(runner.getMessages());
777757
}
778758
} catch(Exception ex) {
779-
log.error("ERROR running 520 database upgrade script", ex);
759+
log.error("ERROR running "+fromVersion+"->"+toVersion+" database upgrade script", ex);
780760
if (runner != null) {
781761
messages.addAll(runner.getMessages());
782762
}
783763

784-
errorMessage("Problem upgrading database to version 520", ex);
785-
throw new StartupException("Problem upgrading database to version 520", ex);
764+
errorMessage("Problem upgrading database to version "+toVersion, ex);
765+
throw new StartupException("Problem upgrading database to version "+toVersion, ex);
786766
}
787767
}
788768

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#**
2+
520-to-610-migration.vm: Velocity template that generates vendor-specific database scripts
3+
4+
DON'T RUN THIS, IT'S NOT A DATABASE CREATION SCRIPT!!!
5+
**#
6+
7+
#alterColumnName('weblog' 'blacklist' 'bannedwordslist')

app/src/main/resources/sql/dbscripts.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ databases=db2 derby hsqldb mssql mysql oracle postgresql
66

77
# list all db templates to generate, separated by spaces
88
templates=createdb 310-to-400-migration 400-to-500-migration \
9-
500-to-510-migration 510-to-520-migration
9+
500-to-510-migration 510-to-520-migration 520-to-610-migration

app/src/main/resources/sql/macros.vm

+14
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,18 @@ alter table $tableName alter column $columnName $columnType;
160160
#else
161161
-- You should alter type of column $columnName of table $tableName to $columnType
162162
#end
163+
#end
164+
165+
#**
166+
Rename a table column.
167+
this is trivial generic SQL - this should work everywhere, right?
168+
**#
169+
#macro(alterColumnName $tableName $columnName $newColumnName)
170+
#if ($db.DBTYPE == "MSSQL")
171+
sp_rename '$tableName.$columnName', '$newColumnName', 'COLUMN';
172+
#elseif ($db.DBTYPE == "HSQLDB")
173+
alter table $tableName alter column $columnName rename to $newColumnName;
174+
#else
175+
alter table $tableName rename column $columnName to $newColumnName;
176+
#end
163177
#end

app/src/main/webapp/WEB-INF/jsps/tiles/head.jsp

+8-8
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ You can override it with your own file via WEB-INF/tiles-def.xml
55

66
<%@ include file="/WEB-INF/jsps/taglibs-struts2.jsp" %>
77

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

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

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

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

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

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

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

it-selenium/pom.xml

+8-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,14 @@
120120

121121
<build>
122122
<plugins>
123-
123+
124+
<!-- bump plugin version for JDK 16 compatibility (old guice version),
125+
can be removed once maven itself bumped the version -->
126+
<plugin>
127+
<artifactId>maven-war-plugin</artifactId>
128+
<version>3.3.1</version>
129+
</plugin>
130+
124131
<!-- Activates integration tests (by default, classes under tests that end with "IT") -->
125132
<plugin>
126133
<artifactId>maven-failsafe-plugin</artifactId>

pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ limitations under the License.
9292
<plugin>
9393
<groupId>org.codehaus.mojo</groupId>
9494
<artifactId>versions-maven-plugin</artifactId>
95-
<version>2.7</version>
95+
<version>2.8.1</version>
9696
<configuration>
9797
<rulesUri>file:version-rules.xml</rulesUri>
9898
</configuration>
@@ -106,7 +106,7 @@ limitations under the License.
106106
<dependency>
107107
<groupId>org.junit.jupiter</groupId>
108108
<artifactId>junit-jupiter-engine</artifactId>
109-
<version>5.6.2</version>
109+
<version>5.7.1</version>
110110
<scope>test</scope>
111111
</dependency>
112112
</dependencies>

0 commit comments

Comments
 (0)