JHipster 9 migration: liquibase:diff generates PK/UK constraint drop+recreate due to implicit naming strategy change
Author: shivam-lal-maerskCreated May 21, 2026Updated May 21, 2026
Labelsarea: triagetheme: undefined
##### **Overview of the issue**
After upgrading from JHipster 8.7 to 9.0, running `mvn liquibase:diff` against an existing database continuously generates a changelog that drops and recreates every primary key and unique constraint in the schema. The generated changelog uses `dropPrimaryKey` / `addPrimaryKey` pairs, renaming constraints from the PostgreSQL default naming convention (e.g. `dest_permissions_pkey`) to Hibernate 7's implicit naming convention (e.g. `dest_permissionsPK`).
Attempting to apply this generated changelog fails with:
```
Caused by: org.postgresql.util.PSQLException: ERROR: cannot drop constraint dest_permissions_pkey on table dest_permissions because other objects depend on it
Detail: constraint fk_rel_dest_permissions__username__dest_permissions_id on table rel_dest_permissions__username depends on index dest_permissions_pkey
Hint: Use DROP ... CASCADE to drop the dependent objects too.
Where: SQL statement "alter table public.dest_permissions drop constraint "dest_permissions_pkey""
PL/pgSQL function inline_code_block line 7 at EXECUTE
```
##### **Motivation for or Use Case**
This is a blocker for any existing JHipster project migrating from JHipster 8.x to JHipster 9. The liquibase:diff goal is used as part of the development workflow to detect real schema changes. With this bug, it permanently generates noise for every table's primary key and unique constraint, making the diff output unreliable and the generated changelogs unapplicable without risking FK constraint violations.
##### **Reproduce the error**
1. Generate a JHipster application (v8.x) with PostgreSQL and Liquibase.
2. Run the application once to let Liquibase create the schema — PostgreSQL assigns default PK names like _pkey.
3. Upgrade to JHipster v9.
4. Run mvn liquibase:diff against the existing database.
5. Observe that a changelog is generated with dropPrimaryKey / addPrimaryKey for every table, renaming constraints from _pkey → PK.
6. Attempt to apply the changelog — it fails with PSQLException: cannot drop constraint ... because other objects depend on it for any table that has a FK referencing its PK.
##### **Related issues**
##### **Suggest a Fix**
Two potential fixes:
1. In the JHipster generator: when generating the referenceUrl for the liquibase-maven-plugin, explicitly configure hibernate.implicit_naming_strategy to a strategy that does not emit explicit PK constraint names (or preserves the legacy behaviour from Hibernate 6), so that liquibase:diff does not flag constraint name mismatches caused purely by the Hibernate 7 upgrade.
2. In the JHipster generator: add configuration to the liquibase-maven-plugin that excludes primaryKeys and uniqueConstraints from diff output, since JHipster manages these explicitly in its generated changelogs and does not need them to be detected via diff:
`tables,columns,views,indexes,foreignKeys,sequences,data`
##### **JHipster Version(s)**
JHipster 9.0.0
##### **Browsers and Operating System**
MacOS
- [x] Tickets opened without reproduction steps or that don't follow the template recommendation will be **closed**.
- [ ] This issue is prompt-related or an error that prevents JHipster from generating an application.
- [ ] I don't have a JDL otherwise I should open an [JDL Issue](https://github.com/jhipster/generator-jhipster/issues/new?template=BUG_REPORT_JDL.md)
- [ ] The application is not successfully generated otherwise, I should open an [Issue with jhipster info](https://github.com/jhipster/generator-jhipster/issues/new?template=BUG_REPORT.md)
- [x] Checking this box is mandatory (this is just to show you read everything)
Source: jhipster/generator-jhipster