# Why does Liquibase generate needless statements?

**URL:** <https://forum.liquibase.org/t/why-does-liquibase-generate-needless-statements/3643>\
**Category:** General Discussion\
**Created:** [July 3, 2018, 9:59pm UTC](https://forum.liquibase.org/t/why-does-liquibase-generate-needless-statements/3643 "2018-07-03T21:59:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alfredo](https://avatars.discourse-cdn.com/v4/letter/a/e495f1/32.png) [@Alfredo](https://forum.liquibase.org/u/Alfredo)\
**Post date:** [July 3, 2018, 9:59pm UTC](https://forum.liquibase.org/t/why-does-liquibase-generate-needless-statements/3643/1 "2018-07-03T21:59:00Z")

</div>

I am using liquibase 3.5.5 and have generated a changelog file from my oracle database but the changelogs are somehow strange since there are always two statements for creating an index and then adding a constraint primary key with the same name. The creating of an index before adding the primary key is not necessary I think and in the SQL files which I have used to generate my origin Oracle database it was not like that as well. Here is an example of the liquibase changelog:

When I generate a SQL file (for Microsoft SQL Server, but this happens for every other database as well, even Oracle itself) from this changelog it would look like this:

– Changeset C:/Users/Ferid/Downloads/liquibase-3.5.5-bin/sdk/workspace/changelog/com/example/newChangelog.xml::1528876614155-108::Ferid (generated)  
CREATE UNIQUE NONCLUSTERED INDEX BP\_PK ON BP\_RESULTS  
GO

ALTER TABLE [BP\_RESULTS] ADD CONSTRAINT [BP\_PK] PRIMARY KEY ([BP\_ID])  
GO

– Changeset C:/Users/Ferid/Downloads/liquibase-3.5.5-bin/sdk/workspace/changelog/com/example/newChangelog.xml::1528876614155-109::Ferid (generated)  
CREATE UNIQUE NONCLUSTERED INDEX CS\_PK ON CHECK\_STATUS  
GO

ALTER TABLE [CHECK\_STATUS] ADD CONSTRAINT [CS\_PK] PRIMARY KEY ([CS\_ID])  
GO

– Changeset C:/Users/Ferid/Downloads/liquibase-3.5.5-bin/sdk/workspace/changelog/com/example/newChangelog.xml::1528876614155-110::Ferid (generated)  
CREATE UNIQUE NONCLUSTERED INDEX CS\_SETS\_PK ON CONFIG\_SETS  
GO

ALTER TABLE [CONFIG\_SETS] ADD CONSTRAINT [CS\_SETS\_PK] PRIMARY KEY ([CONFIG\_ID])  
GO

In the origin oracle database these primary keys were added like this and there is no second statement that creates an index first:

ALTER TABLE BP\_RESULTS ADD (CONSTRAINT BP\_PK PRIMARY KEY(BP\_ID) ENABLE VALIDATE);  
ALTER TABLE CHECK\_STATUS ADD (CONSTRAINT CS\_PK PRIMARY KEY(CS\_ID) ENABLE VALIDATE);  
ALTER TABLE CONFIG\_SETS ADD (CONSTRAINT CS\_SETS\_PK PRIMARY KEY(CONFIG\_ID) ENABLE VALIDATE);

I generate the changelog file via command-line like this:

.\liquibase `--driver=oracle.jdbc.OracleDriver`  
–classpath=C:/svn\_planio/TST/resources/lib/ojdbc7.jar `--changeLogFile=C:\Users/Ferid/Downloads/liquibase-3.5.5-bin/sdk/workspace/changelog/com/example/newChangelog.xml`  
–url=“jdbc:oracle:thin:@localhost:1521:fer” `--username=username`  
–password=password `  
generateChangeLog

Is there any way to let liquibase generate the changelogs in an other way? Maybe adding something when generating the changelog file via command line? Or do I have to change something in my origin database?
