From 45f28f8cead180d2fedcf61612822b1991a952f2 Mon Sep 17 00:00:00 2001 From: Athou Date: Wed, 17 Jul 2013 06:13:31 +0200 Subject: [PATCH] workaround not needed anymore with liquibase 3.0.2 --- pom.xml | 2 +- .../core/IndexExistsPrecondition.java | 119 ------------------ 2 files changed, 1 insertion(+), 120 deletions(-) delete mode 100644 src/main/java/liquibase/precondition/core/IndexExistsPrecondition.java diff --git a/pom.xml b/pom.xml index 55590f3b..bcd1179f 100644 --- a/pom.xml +++ b/pom.xml @@ -192,7 +192,7 @@ org.liquibase liquibase-core - 3.0.1 + 3.0.2 diff --git a/src/main/java/liquibase/precondition/core/IndexExistsPrecondition.java b/src/main/java/liquibase/precondition/core/IndexExistsPrecondition.java deleted file mode 100644 index 7a08acc1..00000000 --- a/src/main/java/liquibase/precondition/core/IndexExistsPrecondition.java +++ /dev/null @@ -1,119 +0,0 @@ -package liquibase.precondition.core; - -import liquibase.changelog.DatabaseChangeLog; -import liquibase.changelog.ChangeSet; -import liquibase.database.Database; -import liquibase.snapshot.SnapshotGeneratorFactory; -import liquibase.structure.core.Column; -import liquibase.structure.core.Index; -import liquibase.structure.core.Schema; -import liquibase.exception.*; -import liquibase.precondition.Precondition; -import liquibase.structure.core.Table; -import liquibase.util.StringUtils; - -/** - * fix for https://github.com/liquibase/liquibase/commit/30934beeb45fd50a1c33bb0cacc089157936ec95#commitcomment-3519020 - */ -public class IndexExistsPrecondition implements Precondition { - private String catalogName; - private String schemaName; - private String tableName; - private String columnNames; - private String indexName; - - public String getCatalogName() { - return catalogName; - } - - public void setCatalogName(String catalogName) { - this.catalogName = catalogName; - } - - public String getSchemaName() { - return schemaName; - } - - public void setSchemaName(String schemaName) { - this.schemaName = schemaName; - } - - public String getTableName() { - return tableName; - } - - public void setTableName(String tableName) { - this.tableName = tableName; - } - - public String getIndexName() { - return indexName; - } - - public void setIndexName(String indexName) { - this.indexName = indexName; - } - - public String getColumnNames() { - return columnNames; - } - - public void setColumnNames(String columnNames) { - this.columnNames = columnNames; - } - - public Warnings warn(Database database) { - return new Warnings(); - } - - public ValidationErrors validate(Database database) { - ValidationErrors validationErrors = new ValidationErrors(); - if (getIndexName() == null && getTableName() == null && getColumnNames() == null) { - validationErrors.addError("indexName OR tableName and columnNames is required"); - } - return validationErrors; - } - - public void check(Database database, DatabaseChangeLog changeLog, ChangeSet changeSet) throws PreconditionFailedException, PreconditionErrorException { - try { - Schema schema = new Schema(getCatalogName(), getSchemaName()); - Index example = new Index(); - example.setTable(new Table()); - if (StringUtils.trimToNull(getTableName()) != null) { - example.getTable().setName(database.correctObjectName(getTableName(), Table.class)); - } - example.getTable().setSchema(schema); - example.setName(database.correctObjectName(getIndexName(), Index.class)); - if (StringUtils.trimToNull(getColumnNames()) != null) { - for (String column : getColumnNames().split("\\s*,\\s*")) { - example.getColumns().add(database.correctObjectName(column, Column.class)); - } - } - if (!SnapshotGeneratorFactory.getInstance().has(example, database)) { - String name = ""; - - if (getIndexName() != null) { - name += database.escapeStringForDatabase(getIndexName()); - } - - if (StringUtils.trimToNull(getTableName()) != null) { - name += " on "+database.escapeStringForDatabase(getTableName()); - - if (StringUtils.trimToNull(getColumnNames()) != null) { - name += " columns "+getColumnNames(); - } - } - throw new PreconditionFailedException("Index "+ name +" does not exist", changeLog, this); - } - } catch (PreconditionFailedException e) { - throw e; - } catch (Exception e) { - e.printStackTrace(); - throw new PreconditionErrorException(e, changeLog, this); - } - } - - public String getName() { - return "indexExists"; - } -} \ No newline at end of file