Search code examples
javapostgresqlliquibase

liquibase with postgres throws ERROR: column am.amcanorder on index exists precondition


liquibase : 4.9.0 postgres driver: 42.3.4, 42.3.3 postgres server: 13, 14

liquibase precondition:
    <changeSet id="metrics_indexes_v1" author="jim.hunter" dbms="postgresql">
        **<preConditions onFail="MARK_RAN">
            <not>
                <indexExists indexName="metrics_instance_id_index" tableName="metrics"/>
            </not>
        </preConditions>**
        <createIndex indexName="metrics_instance_id_index" tableName="metrics">
            <column name="instance_id"/>
        </createIndex>
        <modifySql context="ENABLE-PARTITIONING">
            <append value=" INCLUDE (metric_time, metric_value)"/>
        </modifySql>
    </changeSet>

Throws exception:

Caused by: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: org.postgresql.util.PSQLException: ERROR: column am.amcanorder does not exist
  Position: 427

I read that table pg_am is not available anymore after postgres 9.5 but looks like liquibase is still looking for it. Is this a liquibase problem? What should be the recommended way to check for index exists condition?


Solution

  • This appears to have been answered previously in PostgreSQL Error: column am.amcanorder doesn't exist

    According to the top answer upvoted there, the fix is to update your JDBC driver.