com.marringtons.object
Class Migration
java.lang.Object
com.marringtons.object.Migration
- public class Migration
- extends Object
This is the class that performs data migrations used as part of software
upgrades. If you have a DAO class that needs to change, you must ensure that
databases with instances of that object are correctly migrated. Each package
with DAO classes that require migration will have a class called Migrations.
This class will have an inner class with the same name as the DAO that needs
migrating. Each if these inner classes will have in turn one or more inner
classes that define the migration path - one for each change to the object.
Personally I name the individual classes after the date (v20050418), but
using the release number is equally valid as you will probably only need one
per release. This class is a copy of the target DAO before it is altered,
with the addition of a Migration.Interface interface. Inner classes can be
migrated by creating an inner class path in the Migration path that matches.
- Author:
- Paul Marrington
|
Nested Class Summary |
static interface |
Migration.Interface
Interface is used by inner classes of migration classes to define a
migrate method used to move to a more recent version of a DAO that has
been updated.
|
|
Method Summary |
static boolean |
database(String dataBaseName)
Look at all classes in a database and see which ones have a migration
path - then follow it. |
static boolean |
database(String dataBaseName,
String migrationClassName)
Look at all classes in a database and see which ones have a migration
path - then follow it. |
Migration
public Migration()
database
public static boolean database(String dataBaseName)
throws IOException
- Look at all classes in a database and see which ones have a migration
path - then follow it. The result is that all classes will be migrated to
the latest version. Run in maintenance mode - when the database has not
been used and is not accessable. Usually run by the upgrade installation
script for an application package.
- Parameters:
dataBaseName - Name of database to find and run through the
migration process. Database must be on the data path to be
found.
- Returns:
- true if the database was found.
- Throws:
IOException - on physycal disk error retrieving database.
database
public static boolean database(String dataBaseName,
String migrationClassName)
throws IOException
- Look at all classes in a database and see which ones have a migration
path - then follow it. The result is that all classes will be migrated to
the latest version. Run in maintenance mode - when the database has not
been used and is not accessable. Usually run by the upgrade installation
script for an application package.
- Parameters:
dataBaseName - Name of database to find and run through the
migration process. Database must be on the data path to be
found.migrationClassName - Normally a class of Migrations will be
looked for for each package that has a class in the database.
For junit - and for the odd case when you want a special
migration - you can specify the migration class.
- Returns:
- true if the database was found.
- Throws:
IOException - on physycal disk error retrieving database.
Copyright © 2005 Paul Marrington http://library.marringtons.com