Project Wonder 5.0

er.extensions.migration
Class ERXMigration

java.lang.Object
  extended by er.extensions.migration.ERXMigration
All Implemented Interfaces:
IERXMigration

public abstract class ERXMigration
extends java.lang.Object
implements IERXMigration

Convenience superclass for Migration classes. Checks for corresponding sql files name "ClassnameX_Upgrade.migration" and "ClassnameX_Downgrade.migration" where "Classname" is the classname of the migration class. The files have to to be in a corresponding bundle. Implement "migrationBundleName" to return the correct name of the bundle.

This makes migrations easier as you only have to create a new Java class according to the migration naming conventions, inherit from this class and put your SQL in a properly named text file (or more than one file, if you use database specific migrations).

If you need database specific migrations use

er.extensions.migration.ERXMigration.useDatabaseSpecificMigrations=true

in your Properties. The default is not to use database specific migrations. A filename for a database specific migration is then for example

ClassnameX_FrontBase_Upgrade.migration or

ClassnameX_Postgresql_Upgrade.migration

For the database specific part of the filename, the databaseProductName as from the JDBC adaptor is used. So make sure, you're using the correct filename. The migration will throw an exception if the appropriate migration textfile can't be found.

Author:
cug

Constructor Summary
ERXMigration()
           
ERXMigration(boolean useDatabaseSpecificMigrations)
          Override the global application preference on per-database migrations.
 
Method Summary
 void downgrade(com.webobjects.eocontrol.EOEditingContext editingContext, com.webobjects.eoaccess.EOAdaptorChannel channel, com.webobjects.eoaccess.EOModel model)
          Checks for a corresponding downgrade file which is performed as a raw SQL action
protected  java.lang.String getSQLForMigration(java.lang.String migrationName)
          Checks in the current bundle for migration files corresponding to this classes name
protected  java.lang.String migrationBundleName()
          The name to create the NSBundle for the current bundle, defaults to the bundle that contains the migration class.
 com.webobjects.foundation.NSArray<ERXModelVersion> modelDependencies()
          No dependencies
 void upgrade(com.webobjects.eocontrol.EOEditingContext editingContext, com.webobjects.eoaccess.EOAdaptorChannel channel, com.webobjects.eoaccess.EOModel model)
          Checks for a corresponding upgrade file which is performed as a raw SQL action
protected  boolean useDatabaseSpecificMigrations()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ERXMigration

public ERXMigration(boolean useDatabaseSpecificMigrations)
Override the global application preference on per-database migrations.

Parameters:
useDatabaseSpecificMigrations - if true, database-specific migrations will be used

ERXMigration

public ERXMigration()
Method Detail

modelDependencies

public com.webobjects.foundation.NSArray<ERXModelVersion> modelDependencies()
No dependencies

Specified by:
modelDependencies in interface IERXMigration
Returns:
an array of model versions that this migration depends on

downgrade

public void downgrade(com.webobjects.eocontrol.EOEditingContext editingContext,
                      com.webobjects.eoaccess.EOAdaptorChannel channel,
                      com.webobjects.eoaccess.EOModel model)
               throws java.lang.Throwable
Checks for a corresponding downgrade file which is performed as a raw SQL action

Specified by:
downgrade in interface IERXMigration
Parameters:
editingContext - the editing context you can perform EO operations with.
channel - the channel to perform low level operations with
model - the model being downgraded
Throws:
java.lang.Throwable - if something fails

upgrade

public void upgrade(com.webobjects.eocontrol.EOEditingContext editingContext,
                    com.webobjects.eoaccess.EOAdaptorChannel channel,
                    com.webobjects.eoaccess.EOModel model)
             throws java.lang.Throwable
Checks for a corresponding upgrade file which is performed as a raw SQL action

Specified by:
upgrade in interface IERXMigration
Parameters:
editingContext - the editing context you can perform EO operations with.
channel - the channel to perform low level operations with
model - the model being upgraded
Throws:
java.lang.Throwable - if something fails

getSQLForMigration

protected java.lang.String getSQLForMigration(java.lang.String migrationName)
Checks in the current bundle for migration files corresponding to this classes name

Parameters:
migrationName -

migrationBundleName

protected java.lang.String migrationBundleName()
The name to create the NSBundle for the current bundle, defaults to the bundle that contains the migration class.


useDatabaseSpecificMigrations

protected boolean useDatabaseSpecificMigrations()

Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.