# Liquibase genschema fails with unique constraint when inserting into databasechangelog\_export

**URL:** <https://forum.liquibase.org/t/liquibase-genschema-fails-with-unique-constraint-when-inserting-into-databasechangelog-export/5437>\
**Category:** General Discussion\
**Created:** [May 7, 2021, 1:33pm UTC](https://forum.liquibase.org/t/liquibase-genschema-fails-with-unique-constraint-when-inserting-into-databasechangelog-export/5437 "2021-05-07T13:33:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![pwj21090](https://avatars.discourse-cdn.com/v4/letter/p/4491bb/32.png) [@pwj21090](https://forum.liquibase.org/u/pwj21090)\
**Post date:** [May 7, 2021, 1:33pm UTC](https://forum.liquibase.org/t/liquibase-genschema-fails-with-unique-constraint-when-inserting-into-databasechangelog-export/5437/1 "2021-05-07T13:33:51Z")

</div>

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
```

---

<div class="post-metadata">

**Author:** ![aditi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.liquibase.org/aditi/32/356_2.png) [@aditi](https://forum.liquibase.org/u/aditi)\
**Post date:** [May 7, 2021, 1:49pm UTC](https://forum.liquibase.org/t/liquibase-genschema-fails-with-unique-constraint-when-inserting-into-databasechangelog-export/5437/2 "2021-05-07T13:49:50Z")

</div>

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](https://docs.liquibase.com/commands/community/generatechangelog.html)

 ![image](https://us1.discourse-cdn.com/flex020/uploads/liquibase1/original/1X/66fcd4fe0fd7177c711a198afc39436961db681a.png)

---

<div class="post-metadata">

**Author:** ![tphbrok](https://avatars.discourse-cdn.com/v4/letter/t/ecb155/32.png) [@tphbrok](https://forum.liquibase.org/u/tphbrok)\
**Post date:** [October 4, 2021, 1:04pm UTC](https://forum.liquibase.org/t/liquibase-genschema-fails-with-unique-constraint-when-inserting-into-databasechangelog-export/5437/3 "2021-10-04T13:04:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![MikeOlivas](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.liquibase.org/mikeolivas/32/183_2.png) [@MikeOlivas](https://forum.liquibase.org/u/MikeOlivas)\
**Post date:** [December 30, 2021, 6:57pm UTC](https://forum.liquibase.org/t/liquibase-genschema-fails-with-unique-constraint-when-inserting-into-databasechangelog-export/5437/4 "2021-12-30T18:57:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![VS\_Mironov](https://avatars.discourse-cdn.com/v4/letter/v/df788c/32.png) [@VS\_Mironov](https://forum.liquibase.org/u/VS_Mironov)\
**Post date:** [February 17, 2022, 1:27pm UTC](https://forum.liquibase.org/t/liquibase-genschema-fails-with-unique-constraint-when-inserting-into-databasechangelog-export/5437/5 "2022-02-17T13:27:11Z")

</div>

Hi @MikeOlivas here is a more detailed description of the error [lb genschema leads to unique constraint error — oracle-tech](https://community.oracle.com/tech/developers/discussion/4490536/lb-genschema-leads-to-unique-constraint-error)

---

<div class="post-metadata">

**Author:** ![MikeOlivas](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.liquibase.org/mikeolivas/32/183_2.png) [@MikeOlivas](https://forum.liquibase.org/u/MikeOlivas)\
**Post date:** [February 17, 2022, 2:50pm UTC](https://forum.liquibase.org/t/liquibase-genschema-fails-with-unique-constraint-when-inserting-into-databasechangelog-export/5437/6 "2022-02-17T14:50:45Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![kirilb](https://avatars.discourse-cdn.com/v4/letter/k/a9adbd/32.png) [@kirilb](https://forum.liquibase.org/u/kirilb)\
**Post date:** [March 15, 2022, 12:13pm UTC](https://forum.liquibase.org/t/liquibase-genschema-fails-with-unique-constraint-when-inserting-into-databasechangelog-export/5437/7 "2022-03-15T12:13:49Z")

</div>

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