View Javadoc

1   package liquibase.sqlgenerator.core;
2   
3   import liquibase.database.Database;
4   import liquibase.exception.ValidationErrors;
5   import liquibase.sql.Sql;
6   import liquibase.sql.UnparsedSql;
7   import liquibase.sqlgenerator.SqlGenerator;
8   import liquibase.sqlgenerator.SqlGeneratorChain;
9   import liquibase.statement.core.ClearDatabaseChangeLogTableStatement;
10  
11  public class ClearDatabaseChangeLogTableGenerator extends AbstractSqlGenerator<ClearDatabaseChangeLogTableStatement> {
12  
13      public ValidationErrors validate(ClearDatabaseChangeLogTableStatement clearDatabaseChangeLogTableStatement,
14              Database database, SqlGeneratorChain sqlGeneratorChain) {
15          return new ValidationErrors();
16      }
17  
18      public Sql[] generateSql(ClearDatabaseChangeLogTableStatement statement, Database database,
19              SqlGeneratorChain sqlGeneratorChain) {
20          String schemaName = statement.getSchemaName();
21          if (schemaName == null) {
22              schemaName = database.getLiquibaseSchemaName();
23          }
24          return new Sql[] { new UnparsedSql("DELETE FROM "
25                  + database.escapeTableName(schemaName, database.getDatabaseChangeLogTableName())) };
26      }
27  }