@Override public ValidationErrors validate(final Database database) { final ValidationErrors validationErrors; if ((database instanceof DerbyDatabase || database instanceof H2Database) && getTableName() == null) { validationErrors = new ValidationErrors(); validationErrors.addError("tableName is required for " + database.getDatabaseProductName()); } else { final IndexExistsPrecondition precondition = new IndexExistsPrecondition(); precondition.setCatalogName(getCatalogName()); precondition.setSchemaName(getSchemaName()); precondition.setTableName(getTableName()); precondition.setIndexName(getIndexName()); precondition.setColumnNames(getColumnNames()); validationErrors = precondition.validate(database); } return validationErrors; }
@Override public void check( final Database database, final DatabaseChangeLog changeLog, final ChangeSet changeSet) throws PreconditionFailedException, PreconditionErrorException { Precondition delegatedPrecondition; if (database instanceof DerbyDatabase || database instanceof H2Database) { final TableExistsPrecondition precondition = new TableExistsPrecondition(); precondition.setCatalogName(getCatalogName()); precondition.setSchemaName(getSchemaName()); final String tableName = getHatboxTableName(); precondition.setTableName(tableName); delegatedPrecondition = precondition; } else { final IndexExistsPrecondition precondition = new IndexExistsPrecondition(); precondition.setCatalogName(getCatalogName()); precondition.setSchemaName(getSchemaName()); precondition.setTableName(getTableName()); precondition.setIndexName(getIndexName()); precondition.setColumnNames(getColumnNames()); delegatedPrecondition = precondition; } delegatedPrecondition.check(database, changeLog, changeSet); }