generator-jhipster: New project (6.5.1) w/ postgresql, liquibase:diff won't find FixedPostgreSQL95Dialect and liquibase:diff changelog output fails to execute

Overview of the issue

In a clean, new, project, using postgresql, liquibase won’t find the custom jhipster postgresql driver dialect, and switching that driver results in a liquibase:diff output that fails to run.

This is partially similar to #10885, created earlier today.

Motivation for or Use Case

I expect a newly created project to output no changes with liquibase:diff, and also expect the custom jhipster postgresql dialect driver to be found.

Reproduce the error

I created a repository each step in a commit: https://github.com/nuba/bug-report-jhipster-liquibase

Error messages are

[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.6.3:diff (default-cli) on project jhipster: Error setting up or running Liquibase: liquibase.exception.UnexpectedLiquibaseException: liquibase.exception.DatabaseException: java.lang.ClassNotFoundException: io.github.jhipster.domain.util.FixedPostgreSQL95Dialect -> [Help 1]

And

[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.6.3:update (default-cli) on project jhipster: Error setting up or running Liquibase: Migration failed for change set config/liquibase/changelog/20191205215152_changelog.xml::1575582718315-1::nuba (generated):
[ERROR]      Reason: liquibase.exception.DatabaseException: ERROR: constraint "uc_jhi_useremail_col" of relation "jhi_user" does not exist [Failed SQL: ALTER TABLE jhi_user DROP CONSTRAINT UC_JHI_USEREMAIL_COL]
[ERROR] -> [Help 1]

Here is the table definition in postgres

bugreport=# \d jhi_user;
                              Table "public.jhi_user"
       Column       |            Type             | Collation | Nullable | Default 
--------------------+-----------------------------+-----------+----------+---------
 id                 | bigint                      |           | not null | 
 login              | character varying(50)       |           | not null | 
 password_hash      | character varying(60)       |           | not null | 
 first_name         | character varying(50)       |           |          | 
 last_name          | character varying(50)       |           |          | 
 email              | character varying(191)      |           |          | 
 image_url          | character varying(256)      |           |          | 
 activated          | boolean                     |           | not null | 
 lang_key           | character varying(10)       |           |          | 
 activation_key     | character varying(20)       |           |          | 
 reset_key          | character varying(20)       |           |          | 
 created_by         | character varying(50)       |           | not null | 
 created_date       | timestamp without time zone |           |          | 
 reset_date         | timestamp without time zone |           |          | 
 last_modified_by   | character varying(50)       |           |          | 
 last_modified_date | timestamp without time zone |           |          | 
Indexes:
    "jhi_user_pkey" PRIMARY KEY, btree (id)
    "ux_user_email" UNIQUE CONSTRAINT, btree (email)
    "ux_user_login" UNIQUE CONSTRAINT, btree (login)
Referenced by:
    TABLE "jhi_user_authority" CONSTRAINT "fk_user_id" FOREIGN KEY (user_id) REFERENCES jhi_user(id)
Related issues

Yes, #10885 mentions the diff output, but not the driver issue.

JHipster Version(s)

6.5.1

JHipster configuration

INFO! Using JHipster version installed locally in current project’s node_modules INFO! Executing jhipster:info INFO! Options: from-cli: true

JHipster Version(s)
jhipster@0.0.0 /home/nuba/IdeaProjects/bug-reports/jhipster-liquibase
└── generator-jhipster@6.5.1 

JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "bug.report"
    },
    "jhipsterVersion": "6.5.1",
    "applicationType": "monolith",
    "baseName": "jhipster",
    "packageName": "bug.report",
    "packageFolder": "bug/report",
    "serverPort": "8080",
    "authenticationType": "jwt",
    "cacheProvider": "no",
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "postgresql",
    "prodDatabaseType": "postgresql",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": false,
    "buildTool": "maven",
    "enableSwaggerCodegen": false,
    "jwtSecretKey": "bXktc2VjcmV0LXRva2VuLXRvLWNoYW5nZS1pbi1wcm9kdWN0aW9uLWFuZC10by1rZWVwLWluLWEtc2VjdXJlLXBsYWNl",
    "embeddableLaunchScript": false,
    "useSass": true,
    "clientPackageManager": "npm",
    "skipClient": true,
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "otherModules": [],
    "enableTranslation": false,
    "blueprints": []
  }
}
JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions

Environment and Tools

openjdk version “11.0.5-ea” 2019-10-15 OpenJDK Runtime Environment (build 11.0.5-ea+10-post-Ubuntu-0ubuntu1) OpenJDK 64-Bit Server VM (build 11.0.5-ea+10-post-Ubuntu-0ubuntu1, mixed mode, sharing)

git version 2.20.1

node: v12.13.1

npm: 6.13.1

yeoman: 3.1.1

Docker version 19.03.2, build 6a30dfca03

INFO! Congratulations, JHipster execution is complete!

Entity configuration(s) entityName.json files generated in the .jhipster directory

No entity has been created. The app had just been generated.

Browsers and Operating System

Ubuntu 19.10

  • Checking this box is mandatory (this is just to show you read everything)

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 18 (17 by maintainers)

Most upvoted comments

Adding a bounty on this, as it requires some time and analyze to find a good solution

I am not in favor of generating definition files from DB as

  • It involves many steps including some manual, as you have outlined
  • We can not have separate files for each entity which is easier to check and see
  • We want to know in-prior what is going to be updated in the production database ( of course we can use dev db to check but above points still remain to consider)

I can confirm the driver’s issue. This is a regression coming after #10736 where default PG dialect was replaced with custom dialect hence needing to import <artifactId>jhipster-framework</artifactId> in plugin dependencies to load the related class file.

@nuba Can you do a PR as you have mentioned in https://github.com/jhipster/generator-jhipster/issues/10887#issuecomment-562383926?

Hi @nuba , Would it be possible for you to follow this issue? We also have a bug bounty on this issue 😄

Solved the driver issue by adding io.github.jhipster as a dependency for liquibase inside the appropriate pom.xml section, under project > build > pluginManagement > plugins > plugin

                        <dependency>
                            <groupId>io.github.jhipster</groupId>
                            <artifactId>jhipster-framework</artifactId>
                            <version>${jhipster-dependencies.version}</version>
                        </dependency>