Liquibase genschema fails with unique constraint when inserting into databasechangelog_export

I’m new to liquibase, and DB source control in general. I was trying to run the genschema command to generate the initial files for my base schema (never having run this tool before), and I’m getting a unique contraint when a liquibase procedure tries to insert into a liquibase table. Has anyone seen this before? I have a large schema, about 20 years old.

Connected to: Oracle Database 19c Standard Edition 2 Release 19.0.0.0.0 - Production Version 19.4.0.0.0

SQL> lb genschema
[Method loadCaptureTable]:
                 Executing
[Type - TYPE_SPEC]:                         1089 ms
[Type - TYPE_BODY]:                          203 ms
[Type - SEQUENCE]:                           336 ms
[Type - DIRECTORY]:                           36 ms
[Type - CLUSTER]:                           2187 ms
[Type - TABLE]:                            63056 ms
[Type - MATERIALIZED_VIEW_LOG]:               31 ms
[Type - MATERIALIZED_VIEW]:                   56 ms
[Type - VIEW]:                              2846 ms
[Type - REF_CONSTRAINT]:                   20798 ms
[Type - DIMENSION]:                           29 ms
[Type - FUNCTION]:                           430 ms
[Type - PROCEDURE]:                          124 ms
[Type - PACKAGE_SPEC]:                       639 ms
[Type - DB_LINK]:                             51 ms
[Type - SYNONYM]:                             55 ms
[Type - INDEX]:                             6052 ms
[Type - TRIGGER]:                          11961 ms
[Type - PACKAGE_BODY]:                      9851 ms
[Type - JOB]:                                 81 ms
                 End
[Method loadCaptureTable]:                119911 ms
[Method processCaptureTable]:            1351713 ms
[Method sortCaptureTable]:

Export Flags Used:

Export Grants           false
Export Synonyms         false
Processing has failed for your request.
ORA-00001: unique constraint (SCHEMAOWNER.DATABASECHANGELOG_EXPORT_PK) violated
ORA-06512: at "SCHEMAOWNER.SQLCL_LB_CAPTURE", line 205
1 Like

Hi @pwj21090 ,

You may want to use the following command to capture the current state of your database : generateChangeLog
You can find the detailed document here

Hi @aditi ,

I have ran into the same issue as @pwj21090 , which is not solvable by using generateChangeLog, because @pwj21090 and I use the built-in Liquibase client in SQLcl. The only option to generate a changelog for the schema with SQLcl is lb genschema.

Kind regards,

Thomas

Hi @tphbrok SQLcl has an embedded version of Liquibase that Oracle has added their own flavor on top of. I would go back to the Oracle team and ask them about lb genschema. It could also be a permissions issue as each schema is another user and you may not have access to the SCHEMAOWNER schema.

Hi @MikeOlivas here is a more detailed description of the error lb genschema leads to unique constraint error — oracle-tech

Hi @VS_Mironov Thanks for joining the community. We at Liquibase have no control over which version of Liquibase Oracle uses in their wrapper code for sqlcl. Thanks for the more detailed description error. It sounds like the sqlcl_lb_capture method in their code has a counter being set.
If you want to use Liquibase directly instead of sqlcl and show that it in the liquibase generateChangeLog code does exact the same thing, you could submit an issue in our github repository so that we can put it in the queue to get it fixed. I’m not sure that we set the variable counter on the number of objects to capture.
Can you please recreate the issue with liquibase directly?

does somebody know where this sqlcl_lb_capture is located, so that I can modify it and set the counter to 10000?