|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.agimatec.dbmigrate.BaseMigrationTool
com.agimatec.dbmigrate.AutoMigrationTool
public class AutoMigrationTool
Automatical database migration program for Agimatec GmbH
Features:
01- detect from-version from database or config-file
02- execute sql-scripts or commands from a config file for
all files that belong to versions later than "from-version".
03- automatic script detection and sorting.
04- can stop execution at "to-version", if set in config-file.
05- supports conditional execution in sql-scripts (-- #if #endif syntax)
06- support conditional execution in config-files (list-tags)
07- supports enviroment variables in sql-scripts ( ${variable} syntax )
08- supports connect commands in SQL-scripts
09- a) supports local-enviroment variables per config-file of each migration version,
b) environment variables per migration config,
c) all JVM System-Properties are accessible as environment variable default
10- supports Simulation-mode "with jvm parameter -Dsim=true" to check
behavior before affecting the system.
11- supports subscripts (@scriptname.sql; syntax)
12 - supports db_version upgrade with setVersion(dbversion)-method
or -- @version(dbversion) script-directive
13 - runs all scripts as files or as classpath resource
14 - (optional) automatically create db_version table
15 - (optional) automatically set version in db_version table after script execution
16 - can be integrated into grails project (see plugin viaboxx-dbmigrate)
17 - runs sql, xml or groovy script (auto-detect by file suffix)
Author: Roman Stumm
Date: 2007, 2008, 2009, 2010, 2011
final String sim = System.getProperty(SYSTEM_PROPERTY_SIM); sim = "true"|"yes" :: simulation, echo execution sequence into log, but do not invoke any script otherwise (=default) :: execute scripts/java in sequence
| Field Summary |
|---|
| Fields inherited from class com.agimatec.dbmigrate.BaseMigrationTool |
|---|
dbVersionMeta, log, migrateConfigFileName, targetDatabase |
| Constructor Summary | |
|---|---|
AutoMigrationTool()
|
|
| Method Summary | |
|---|---|
void |
addActionsAfterAll(String dir,
List<MigrateAction> actions)
|
List<MigrateAction> |
createUpgradeActions(String scriptDir,
boolean enableAutoVersion)
create some up- actions of a custom script dir dependent on current version |
void |
doXmlScript(String filePath)
|
List<MigrateAction> |
getActionOverride()
|
String |
getAfterAllScriptsDir()
|
String |
getBeforeAllScriptsDir()
|
Map |
getEnvironment()
a map for environment properties (JVM System-Properties overwrite these properties) (to be used to conditional execution of statements in SQL scripts) |
DBVersionString |
getFromVersion()
|
Map<Object,Object> |
getLocalEnv()
|
protected Map<?,?> |
getMigrateEnvironment()
|
String |
getScriptPrefix()
|
DBVersionString |
getToVersion()
|
boolean |
isSim()
|
static void |
main(String[] args)
run the tool and exit the JVM afterwards. |
void |
performActions(List<MigrateAction> actionOverride)
|
protected void |
prepareLocalEnvironment(Config cfg)
|
DBVersionString |
readVersion()
read the version from the database |
void |
setActionOverride(List<MigrateAction> actionOverride)
|
void |
setLocalEnv(Map<Object,Object> localEnv)
|
void |
setSim(boolean sim)
|
void |
startAutomaticMigration()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AutoMigrationTool()
| Method Detail |
|---|
public static void main(String[] args)
Exception - exit(0) = successful
exit(1) = in case of an exceptionpublic boolean isSim()
public Map getEnvironment()
BaseMigrationTool
getEnvironment in interface MigrationToolgetEnvironment in class BaseMigrationToolprotected Map<?,?> getMigrateEnvironment()
public void startAutomaticMigration()
throws Exception
Exception
public void performActions(List<MigrateAction> actionOverride)
throws Exception
Exceptionprotected void prepareLocalEnvironment(Config cfg)
public void doXmlScript(String filePath)
throws Exception
Exceptionpublic DBVersionString getToVersion()
public DBVersionString getFromVersion()
throws SQLException
SQLException
public DBVersionString readVersion()
throws SQLException
SQLException - - in case of database error
public void addActionsAfterAll(String dir,
List<MigrateAction> actions)
throws IOException
IOException
public List<MigrateAction> createUpgradeActions(String scriptDir,
boolean enableAutoVersion)
throws SQLException,
IOException
scriptDir - enableAutoVersion -
SQLException
IOExceptionpublic String getScriptPrefix()
public String getBeforeAllScriptsDir()
public String getAfterAllScriptsDir()
public Map<Object,Object> getLocalEnv()
public List<MigrateAction> getActionOverride()
public void setActionOverride(List<MigrateAction> actionOverride)
public void setSim(boolean sim)
public void setLocalEnv(Map<Object,Object> localEnv)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||