public abstract class ERXMigration extends 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.
Constructor and Description |
---|
ERXMigration() |
ERXMigration(boolean useDatabaseSpecificMigrations)
Override the global application preference on per-database migrations.
|
Modifier and Type | Method and Description |
---|---|
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 String |
getSQLForMigration(String migrationName)
Checks in the current bundle for migration files corresponding to this classes name
|
protected String |
migrationBundleName()
The name to create the NSBundle for the current bundle, defaults to the
bundle that contains the migration class.
|
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() |
public ERXMigration(boolean useDatabaseSpecificMigrations)
useDatabaseSpecificMigrations
- if true, database-specific migrations will be usedpublic ERXMigration()
public NSArray<ERXModelVersion> modelDependencies()
modelDependencies
in interface IERXMigration
public void downgrade(com.webobjects.eocontrol.EOEditingContext editingContext, com.webobjects.eoaccess.EOAdaptorChannel channel, com.webobjects.eoaccess.EOModel model) throws Throwable
downgrade
in interface IERXMigration
editingContext
- the editing context you can perform EO operations with.channel
- the channel to perform low level operations withmodel
- the model being downgradedThrowable
- if something failspublic void upgrade(com.webobjects.eocontrol.EOEditingContext editingContext, com.webobjects.eoaccess.EOAdaptorChannel channel, com.webobjects.eoaccess.EOModel model) throws Throwable
upgrade
in interface IERXMigration
editingContext
- the editing context you can perform EO operations with.channel
- the channel to perform low level operations withmodel
- the model being upgradedThrowable
- if something failsprotected String getSQLForMigration(String migrationName)
migrationName
- protected String migrationBundleName()
null
protected boolean useDatabaseSpecificMigrations()
Copyright © 2002 – 2020 Project Wonder.