使用 liquibase 在 postgres 中删除索引时出现问题
Problems dropping an index in postgres using liquibase
我在 liquibase 中遇到一个问题,我无法在我的 postgres 数据库中删除索引。 liquibase报的错误是
Unexpected error running Liquibase: ERROR: index "value_idx" does not exist [Failed SQL: DROP INDEX VALUE_IDX]
我已经使用 psql 连接到数据库并验证索引确实存在(如果变更集是 运行 没有删除索引节)
\d data
Table "someschema.data"
Column | Type | Modifiers
--------+-----------------------+-----------
value | character varying(36) | not null
Indexes:
"value_idx" UNIQUE, btree (value)
当 运行ning Liquibase updateSQL 时,它生成的 DROP INDEX
语句是:
DROP INDEX VALUE_IDX;
我的更新日志如下:
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<preConditions>
<dbms type="postgresql"/>
</preConditions>
<changeSet author="beresfordt" id="1">
<sql>
CREATE SCHEMA SomeSchema;
</sql>
<createTable tableName="data" schemaName="someschema">
<column name="value" type="varchar(36)">
<constraints nullable="false"/>
</column>
</createTable>
<createIndex indexName="VALUE_IDX" schemaName="someschema"
tableName="data" unique="true">
<column name="value" type="varchar(36)"/>
</createIndex>
<dropIndex catalogName="someschema"
schemaName="someschema"
tableName="data"
indexName="VALUE_IDX"/>
</changeSet>
</databaseChangeLog>
我还尝试了以下 dropindex 节:
<dropIndex catalogName="someschema"
schemaName="someschema"
tableName="data"
indexName="someschema.VALUE_IDX"/>
但是我得到了类似的错误:
Unexpected error running Liquibase: ERROR: index "someschema.VALUE_IDX" does not exist [Failed SQL: DROP INDEX "someschema.VALUE_IDX"]
我正在使用 Liquibase:3.4.2 和 Postgres:9.5.1
编辑:
在 3.3.0 上试过并且有效。
liquibase 的 jira 中出现的错误:https://liquibase.jira.com/browse/CORE-2677
这是由在编写 Liquibase 的 3.4.1 和 3.4.2 时存在的错误引起的。
这已在 Liquibase jira 上提出:https://liquibase.jira.com/browse/CORE-2677
编辑:
这似乎已在当前 head 中解决:'03b020ab895eb02c0e0aba90461cb7c628fa033f'
编辑 2:
来自 Liquibase 的更新:
The fix should be out with 3.5
我在 liquibase 中遇到一个问题,我无法在我的 postgres 数据库中删除索引。 liquibase报的错误是
Unexpected error running Liquibase: ERROR: index "value_idx" does not exist [Failed SQL: DROP INDEX VALUE_IDX]
我已经使用 psql 连接到数据库并验证索引确实存在(如果变更集是 运行 没有删除索引节)
\d data
Table "someschema.data"
Column | Type | Modifiers
--------+-----------------------+-----------
value | character varying(36) | not null
Indexes:
"value_idx" UNIQUE, btree (value)
当 运行ning Liquibase updateSQL 时,它生成的 DROP INDEX
语句是:
DROP INDEX VALUE_IDX;
我的更新日志如下:
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<preConditions>
<dbms type="postgresql"/>
</preConditions>
<changeSet author="beresfordt" id="1">
<sql>
CREATE SCHEMA SomeSchema;
</sql>
<createTable tableName="data" schemaName="someschema">
<column name="value" type="varchar(36)">
<constraints nullable="false"/>
</column>
</createTable>
<createIndex indexName="VALUE_IDX" schemaName="someschema"
tableName="data" unique="true">
<column name="value" type="varchar(36)"/>
</createIndex>
<dropIndex catalogName="someschema"
schemaName="someschema"
tableName="data"
indexName="VALUE_IDX"/>
</changeSet>
</databaseChangeLog>
我还尝试了以下 dropindex 节:
<dropIndex catalogName="someschema"
schemaName="someschema"
tableName="data"
indexName="someschema.VALUE_IDX"/>
但是我得到了类似的错误:
Unexpected error running Liquibase: ERROR: index "someschema.VALUE_IDX" does not exist [Failed SQL: DROP INDEX "someschema.VALUE_IDX"]
我正在使用 Liquibase:3.4.2 和 Postgres:9.5.1
编辑:
在 3.3.0 上试过并且有效。
liquibase 的 jira 中出现的错误:https://liquibase.jira.com/browse/CORE-2677
这是由在编写 Liquibase 的 3.4.1 和 3.4.2 时存在的错误引起的。
这已在 Liquibase jira 上提出:https://liquibase.jira.com/browse/CORE-2677
编辑:
这似乎已在当前 head 中解决:'03b020ab895eb02c0e0aba90461cb7c628fa033f'
编辑 2:
来自 Liquibase 的更新:
The fix should be out with 3.5