A new topic, 'PostgreSQL and sequenceExists -- bug?', has been made on a board 
you are watching.

You can see it at
http://liquibase.org/forum/index.php?topic=32.new#new

The text of the topic is shown below:

So as part of my OpenNMS transition to Liquibase, I've got a set of changeSets 
which essentially does "create the schema if it doesn't exist; if it does, mark 
it as ran" so I can bootstrap from an existing database to one being tracked by 
liquibase.

One of the things I'm trying to create is a sequence, if it's not already there:

Code:
<changeSet runOnChange="false" author="rangerrick" id="opennmsnxtid">
        <preConditions onFail="MARK_RAN">
                <not><sequenceExists sequenceName="opennmsnxtid" /></not>
        </preConditions>
        <createSequence sequenceName="opennmsnxtid" />
</changeSet>

On a database that already has the sequence, it's failing:

Code:
Exception in thread "main" org.opennms.core.schema.MigrationException: unable
to update the database
        at org.opennms.core.schema.Migrator.migrate(Migrator.java:72)
        at org.opennms.install.Installer.install(Installer.java:284)
        at org.opennms.install.Installer.main(Installer.java:860)
Caused by: liquibase.exception.MigrationFailedException: Migration failed for
change set sequences.xml::opennmsnxtid::rangerrick:
     Reason: liquibase.exception.JDBCException: Error executing SQL CREATE
SEQUENCE opennmsnxtid:
          Caused By: Error executing SQL CREATE SEQUENCE opennmsnxtid:
          Caused By: ERROR: relation "opennmsnxtid" already exists
        at liquibase.ChangeSet.execute(ChangeSet.java:238)
        at liquibase.parser.visitor.UpdateVisitor.visit(UpdateVisitor.java:26)
        at liquibase.parser.ChangeLogIterator.run(ChangeLogIterator.java:41)
        at liquibase.Liquibase.update(Liquibase.java:112)
        at org.opennms.core.schema.Migrator.migrate(Migrator.java:69)
        ... 2 more
Caused by: liquibase.exception.JDBCException: Error executing SQL CREATE
SEQUENCE opennmsnxtid
        at
liquibase.database.template.JdbcTemplate.execute(JdbcTemplate.java:56)
        at
liquibase.database.template.JdbcTemplate.execute(JdbcTemplate.java:87)
        at liquibase.change.AbstractChange.execute(AbstractChange.java:251)
        at
liquibase.change.AbstractChange.executeStatements(AbstractChange.java:97)
        at liquibase.ChangeSet.execute(ChangeSet.java:214)
        ... 6 more
Caused by: org.postgresql.util.PSQLException: ERROR: relation "opennmsnxtid"
already exists
        at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1525)
        at
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1309)
        at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:188)
        at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452)
        at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:340)
        at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:332)
        at
liquibase.database.template.JdbcTemplate$1ExecuteStatementCallback.doInStatement(JdbcTemplate.java:79)
        at
liquibase.database.template.JdbcTemplate.execute(JdbcTemplate.java:49)
        ... 10 more

It's definitely preexisting in the database, it's in a pg_dump:

Code:
--
-- Name: opennmsnxtid; Type: SEQUENCE; Schema: public; Owner: opennms
--

CREATE SEQUENCE opennmsnxtid
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.opennmsnxtid OWNER TO opennms;

--
-- Name: opennmsnxtid; Type: SEQUENCE SET; Schema: public; Owner: opennms
--

SELECT pg_catalog.setval('opennmsnxtid', 1401, true);

Any ideas what's going wrong?

Unsubscribe to new topics from this board by clicking here: 
http://liquibase.org/forum/index.php?action=notifyboard;board=1.0

Regards,
The LiquiBase Community Forum Team.
------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Liquibase-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/liquibase-user

Reply via email to