|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Change
Interface all changes (refactorings) implement.
How changes are constructed and run when reading changelogs:
To implement a new change:
Implementing automatic rollback support
The easiest way to allow automatic rollback support is by overriding the createInverses() method.
If there are no corresponding inverse changes, you can override the generateRollbackStatements(*) and canRollBack() methods.
Notes for generated SQL:
Because migration and rollback scripts can be generated for execution at a different time, or against a different database,
changes you implement cannot directly reference data in the database. For example, you cannot implement a change that selects
all rows from a database and modifies them based on the primary keys you find because when the SQL is actually run, those rows may not longer
exist and/or new rows may have been added.
We chose the name "change" over "refactoring" because changes will sometimes change functionality whereas true refactoring will not.
ChangeFactory,
Database| Method Summary | |
|---|---|
boolean |
canRollBack()
Can this change be rolled back |
org.w3c.dom.Node |
createNode(org.w3c.dom.Document currentChangeLogDOM)
Creates an XML element (of type Node) of the change object, and adds it
to the Document object passed as argument |
void |
executeRollbackStatements(Database database,
java.util.List<SqlVisitor> sqlVisitors)
Rolls back the statements in this change against the Database passed as argument |
void |
executeStatements(Database database,
java.util.List<SqlVisitor> sqlVisitors)
Executes the statements in this change against the database passed in the argument |
SqlStatement[] |
generateRollbackStatements(Database database)
Generates the SQL statements required to roll back the change |
SqlStatement[] |
generateStatements(Database database)
Generates the SQL statements required to run the change |
java.util.Set<DatabaseObject> |
getAffectedDatabaseObjects()
|
java.lang.String |
getChangeName()
Returns the name of this change |
ChangeSet |
getChangeSet()
|
java.lang.String |
getConfirmationMessage()
Confirmation message to be displayed after the change is executed |
java.lang.String |
getMD5Sum()
Calculates the MD5 hash for the string representation of the XML element of this change |
java.lang.String |
getTagName()
Returns the tag name of this change |
void |
saveRollbackStatement(Database database,
java.util.List<SqlVisitor> sqlVisitors,
java.io.Writer writer)
Outputs the statements necessary to roll back this change |
void |
saveStatements(Database database,
java.util.List<SqlVisitor> sqlVisitors,
java.io.Writer writer)
Outputs the SQL statements generated by this change |
void |
setChangeSet(ChangeSet changeSet)
|
void |
setFileOpener(FileOpener fileOpener)
Sets the fileOpener that should be used for any file loading and resource finding for files that are provided by the user. |
void |
setUp()
This method will be called after the no arg constructor and all of the properties have been set to allow the task to do any heavy tasks or more importantly generate any exceptions to report to the user about the settings provided. |
void |
validate(Database database)
|
| Method Detail |
|---|
java.lang.String getChangeName()
java.lang.String getTagName()
void executeStatements(Database database,
java.util.List<SqlVisitor> sqlVisitors)
throws JDBCException,
UnsupportedChangeException
database - the reference to the target Database
to which the statements are executed
JDBCException - if there were problems executing the statements
UnsupportedChangeException - if this change is not supported by the Database passed as argument
void saveStatements(Database database,
java.util.List<SqlVisitor> sqlVisitors,
java.io.Writer writer)
throws java.io.IOException,
UnsupportedChangeException,
StatementNotSupportedOnDatabaseException
database - the target Database associated to this change's statementswriter - the target Writer to which the statements are appended
java.io.IOException - if there were problems appending the statements to the writer
UnsupportedChangeException - if this change is not supported by the Database passed as argument
StatementNotSupportedOnDatabaseException
void executeRollbackStatements(Database database,
java.util.List<SqlVisitor> sqlVisitors)
throws JDBCException,
UnsupportedChangeException,
RollbackImpossibleException
Database passed as argument
database - the target Database associated to this change's rollback statements
JDBCException - if there were problems executing the rollback statements
UnsupportedChangeException - if this change is not supported by the Database passed as argument
RollbackImpossibleException - if rollback is not supported for this change
void saveRollbackStatement(Database database,
java.util.List<SqlVisitor> sqlVisitors,
java.io.Writer writer)
throws java.io.IOException,
UnsupportedChangeException,
RollbackImpossibleException,
StatementNotSupportedOnDatabaseException
database - the target Database associated to this change's rollback statementswriter - writer the target Writer to which the rollback statements are appended
java.io.IOException - if there were problems appending the rollback statements to the writer
UnsupportedChangeException - if this change is not supported by the Database passed as argument
RollbackImpossibleException - if rollback is not supported for this change
StatementNotSupportedOnDatabaseException
SqlStatement[] generateStatements(Database database)
throws UnsupportedChangeException
database - databasethe target Database associated to this change's statements
Strings with the statements
UnsupportedChangeException - if this change is not supported by the Database passed as argument
SqlStatement[] generateRollbackStatements(Database database)
throws UnsupportedChangeException,
RollbackImpossibleException
database - database databasethe target Database associated to this change's rollback statements
Strings with the rollback statements
UnsupportedChangeException - if this change is not supported by the Database passed as argument
RollbackImpossibleException - if rollback is not supported for this changeboolean canRollBack()
java.lang.String getConfirmationMessage()
String containing the message after the change is executedorg.w3c.dom.Node createNode(org.w3c.dom.Document currentChangeLogDOM)
Node) of the change object, and adds it
to the Document object passed as argument
currentChangeLogDOM - the current Document where this element is being added
Node object createdjava.lang.String getMD5Sum()
void setFileOpener(FileOpener fileOpener)
void setUp()
throws SetupException
SetupExceptionjava.util.Set<DatabaseObject> getAffectedDatabaseObjects()
ChangeSet getChangeSet()
void setChangeSet(ChangeSet changeSet)
void validate(Database database)
throws InvalidChangeDefinitionException
InvalidChangeDefinitionException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||