Cosmo Migration Information for Developers
This page contains information about the migration code included with the server bundle that allows users to migrate existing data from an older version of the server to the latest version.
The server bundle includes a migration component located in
, which consists of a self-contained jar, a
| File || purpose |
| migration.jar || self-containted jar containing all code and migration code and scripts |
| README.txt || instructions on how to perform migration |
| migration.properties || sample properties file that contains properties required for migration. |
In a nutshell, the migration component is a java program designed to migrate from any previous version the the server to the latest version. The component is updated for each release of the server that contains a schema change.
The source to the migration component is located in the
subdir of the root cosmo tree. See ChandlerServerSource?
for information on checking out the cosmo source.
src/main/java - java source files
src/main/resources resource files including spring configuration files, sql scripts
src/test - unit test source + resources
src/main/config - sample migration properties
src/docs - docs
Building Migration Component
To build the all-in-one jar:
This will result in a
located in the
Migration Manager Overview
class is the center of the migration component. It is responsible for managing many different
implementations and figuring out which
Migration=s to run. A =Migration
is an interface describing a database migration. There is a
instance for each supported database and schema version, and the
queries the current database schema to determine which
to run and in what order.
The migration manager is configured in
instances are configured in
reads properties from
and invokes the
Adding a new Migration
Adding new migrations can be done in a couple of ways.
Adding to Existing source
- Define new
Migration implementation(s) and add to source (if necessary, otherwise you may be able to re-use existing implementation like
- Configure new
Migration implementation(s) in
- rebuild migration all-in-one jar
Adding using separate Jar
The migration runner also supports loading migrations from separate jar files. It assumes the following:
- the jar file name contains the text
- the jar file is located in the current working directory
- the jar file contains a
migration-context.xml spring configuration file that defines one or more
So for example to create an extension jar to support a simple MyDB?
migration from schema ver 100 to 110:
- create migration scripts that
BasicSqlScriptMigration looks for:
- create migration-extention-MyDB-100-110.jar that looks like:
- ensure extension jar is in the working dir when running the migration jar
- 09 Jul 2008