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?