User's Manual

Chapter 8. WAF Application Development Tutorial 61
Creating A ccm Tool Upgrade Script in Java
1. Create arbitrary Java code that is accessible via a static main() method.
## file called com/arsdigita/cms/AnUpgrade.java
package com.arsdigita.cms;
public class AnUpgrade {
public static void main(String[] args) {
System.out.println("Sample upgrade running");
}
}
2. Create or edit the upgrade spec file at ${package_name}.upgrade on the classpath. The file
described looks like this:
## file called ccm-cms.upgrade
<upgrade>
<version from="6.0" to="6.1">
<script class="com.arsdigita.cms.RickshawPublishAPIUpgrade"/>
</version>
<version from="6.0" to="7.0">
<script class="com.arsdigita.cms.AnUpgrade"/>
<script sql="ccm-cms/upgrade/::database::-6.0-7.0.sql"/>
</version>
</upgrade>
Creating a SQL Upgrade Script
1. Create arbitrary SQL code to update the schema or data, and place the code in a file with the
.sql suffix. Group all related functional changes in a single file and assign the file a descriptive
functional name e.g., update-host-unique-index.sql.
2. Update the appropriate parent upgrade script to reference the created SQL script. Parent scripts are
stored in sql/ccm-core/upgrade. Each database has its own set of versioned upgrade scripts,
e.g., oracle-se-6.0.1-6.1.0.sql.
For Java upgrade scripts, the class for the given version-version pair will be invoked (via its
main() method) when the user runs, e.g., ccm upgrade ccm-cms --from-version 6.0
--to-version 7.0. For SQL scripts, the given SQL file will be loaded as a resource from the
classpath and run. The "::database::" placeholder will be substituted with a short string identifying
the current database, oracle-se or postgres, before the resource is loaded.
Note
Only exact matches on both the from and the to versions will trigger script execution.