« Zurück zu Upgrade Instructions

Writing Custom Upgrade Processes


By following a few, simple rules we can guarantee that Liferay can upgrade from any previous version to any newer version.

(See http://issues.liferay.com/browse/LPS-4583 )

Steps #

1. Create Table.java classes for any tables that you modify

Here's an example taken from the BookmarksEntry table for version 5.2.3:

package com.liferay.portal.upgrade.v5_2_3.util;

import java.sql.Types;

 * <a href="BookmarksEntryTable.java.html"><b><i>View Source</i></b></a>
 * @author Brian Wing Shun Chan
public class BookmarksEntryTable {

	public static final String TABLE_NAME = "BookmarksEntry";

	public static final Object[][] TABLE_COLUMNS = {
		{"uuid_", new Integer(Types.VARCHAR)},
		{"entryId", new Integer(Types.BIGINT)},
		{"groupId", new Integer(Types.BIGINT)},
		{"companyId", new Integer(Types.BIGINT)},
		{"userId", new Integer(Types.BIGINT)},
		{"createDate", new Integer(Types.TIMESTAMP)},
		{"modifiedDate", new Integer(Types.TIMESTAMP)},
		{"folderId", new Integer(Types.BIGINT)},
		{"name", new Integer(Types.VARCHAR)},
		{"url", new Integer(Types.VARCHAR)},
		{"comments", new Integer(Types.VARCHAR)},
		{"visits", new Integer(Types.INTEGER)},
		{"priority", new Integer(Types.INTEGER)}

	public static final String TABLE_SQL_CREATE = "create table BookmarksEntry (uuid_ VARCHAR(75) null,entryId...)";

	public static final String TABLE_SQL_DROP = "drop table BookmarksEntry";


This can now be auto-generated for you.

  • All you need to do is create a directory that contains X number of src zip files.
  • Point that directory in build.xxx.properties
    • upgrade.table.path=K:/upgrade-table
  • Run "ant build-upgrade-table" in portal-impl, and it'll automatically set everything now.
  • http://issues.liferay.com/browse/LPS-4817

2. Use JDBC instead of ServiceImpl.java classes. Liferay services are usually tied to a specific version and may not work the same from one major revision to the next whereas JDBC will always work.

So use this:

		Connection con = null;
		PreparedStatement ps = null;
		ResultSet rs = null;

		try {
			con = DataAccess.getConnection();

			ps = con.prepareStatement(
				"select folderId, groupId from BookmarksFolder");

instead of this:

		List<BookmarksFolder> bookmarksFolders =

Final Notes #

That's it! You've now version proofed your upgrade process so that it will work no matter what version you're upgrading to.

You may want to use ps.executeUpdate() instead of runSQL() when updating content that may contain apostrophes or other special characters as updating content with special characters may cause issues.

Update #

This is also possible to be launched:

ant build-upgrade-table -Dupgrade.table.dir=src/com/liferay/portlet/dynamicdatamapping/model/impl

being -Dupgrade.table.dir the address where ModelImpl.java is

0 Anhänge
37376 Angesehen
Durchschnitt (0 Stimmen)
Die durchschnittliche Bewertung ist 0.0 von max. 5 Sternen.
Antworten im Thread Autor Datum
Xlent work... This reduces upgrade process... zaheer mohammed saddapalli 7. Oktober 2009 05:17

Xlent work...

This reduces upgrade process work.

I would like to ask one more question

Why should i migrate to higher version?
Why don't you provide all updates for irrespective of versions?

With regards,
Saddapalli Mohammed Zaheer
Gepostet am 07.10.09 05:17.