01: package liquibase.change.custom;
02:
03: import liquibase.database.Database;
04: import liquibase.database.sql.SqlStatement;
05: import liquibase.exception.CustomChangeException;
06: import liquibase.exception.UnsupportedChangeException;
07:
08: /**
09: * Interface to implement when creating a custom change that generates SQL. When updating a database,
10: * implementing this interface is preferred over CustomTaskChange because the SQL can either be executed
11: * directly or saved to a text file for later use depending on the migration mode used. To allow
12: * the change to be rolled back, also implement the CustomSqlRollback interface. If your change requires sql-based
13: * logic and non-sql-based logic, it is best to create a change set that contains a mix of CustomSqlChange and CustomTaskChange calls.
14: *
15: * @see liquibase.change.custom.CustomSqlRollback
16: * @see liquibase.change.custom.CustomTaskChange
17: */
18: public interface CustomSqlChange extends CustomChange {
19: /**
20: * Generates the SQL statements required to run the change
21: *
22: * @param database the target {@link liquibase.database.Database} associated to this change's statements
23: * @return an array of {@link SqlStatement}s with the statements
24: * @throws liquibase.exception.CustomChangeException if an exception occurs while processing this change
25: * @throws liquibase.exception.UnsupportedChangeException if this change is not supported by the {@link liquibase.database.Database} passed as argument
26: */
27: public SqlStatement[] generateStatements(Database database)
28: throws UnsupportedChangeException, CustomChangeException;
29:
30: }
|