Upgrading Data Schemas in Development

As you develop modules, you might need to iterate through several database schema changes. Before you release new module versions with your finalized schema changes, you must create a formal data upgrade process. Until then, you can use the Build Auto Upgrade feature to test schema changes on the fly.

Follow these steps to use the Build Auto Upgrade feature to test schema changes in development:

  1. Create a portal-ext.properties file in your app server’s [Liferay_Home]/ folder if it doesn’t already exist.

  2. Enable Developer Mode in your app server by adding the following line to the properties file:


    The Build Auto Upgrade feature is a global property schema.module.build.auto.upgrade in the file [Liferay_Home]/portal-developer.properties, so enabling Developer Mode automatically enables this property as well.

    Alternatively, if you prefer not to enable all the other properties included in Developer Mode, you can just add the schema.module.build.auto.upgrade property to your portal-ext.properties file and set it to true:

    schema.module.build.auto.upgrade = true;

Setting the global property schema.module.build.auto.upgrade to true applies module schema changes for redeployed modules whose service build numbers have incremented. The build.number property in the module’s service.properties file indicates the service build number. Build Auto Upgrade executes schema changes without massaging existing data. It leaves data empty for created columns, drops data from deleted and renamed columns, and orphans data from deleted and renamed tables.

Although Build Auto Upgrade updates databases quickly and automatically, it doesn’t guarantee a proper data upgrade–you implement that via data upgrade processes. Build Auto Upgrade is for development purposes only.

By default, schema.module.build.auto.upgrade is set to false. On any module’s first deployment, the module’s tables are generated regardless of the schema.module.build.auto.upgrade value.

The table below summarizes Build Auto Upgrade’s handling of schema changes:

Schema ChangeResult
Add columnCreate a new empty column.
Rename columnDrop the existing column and delete all its data. Create a new empty column.
Delete columnDrop the existing column and delete all its data.
Create or rename a table in Liferay DXP’s built-in data source.Orphan the existing table and all its data. Create the new table.

Great! Now you know how to use the Build Auto Upgrade developer feature.

Creating Data Upgrade Process for Modules

« Upgrade Processes for Former Service Builder PluginsIntroduction to Managing User-Associated Data Stored by Custom Applications »
¿Fue útil este artículo?
Usuarios a los que les pareció útil: 0 de 0