Jhipster entity sub generator: How to create liquibase DELTA changelogs in Prod using gradle?

Viewed 619

I have created a project using Jhipster 6.10. Then, I've generated the entities and checked that everything was working fine. I added a new field into one of the entities using jhipster entity EntityName command. When I reload the project, Liquibase was giving me an error:

liquibase.exception.ValidationFailedException: Validation Failed:
     2 change sets check sum
          config/liquibase/changelog/20200718175552_added_entity_ChatRoom.xml::20200718175552-1::jhipster was: 8:38306369febaf4b6a6b6ba7a88f73330 but is now: 8:412ef0706ed57049a9803f912e238bbb
          config/liquibase/changelog/20200718175552_added_entity_ChatRoom.xml::20200718175552-1-data::jhipster was: 8:57a6e15b897abad245853f04c91b731e but is now: 8:5c0cf1cea40b2c47cddc2c1173a81567

So I went and cleaned the H2 dev database with gradlew clean, relaunch the project and everthing was working fine.

My question is how should I proceed in PRODUCTION. This question:

Jhipster entity sub generator: How to create liquibase DELTA changelogs?

gives the anwser for maven, but I'm using gradle.

PS: I followed Gael answer on a new dev project in Postgres and run:

D:\JHipster\liquipostgres>gradlew compile liquiposrgres:diff

FAILURE: Build failed with an exception.

  • What went wrong: Task 'compile' is ambiguous in root project 'liquipostgres'. Candidates are: 'compileJava', 'compileTestJava'.

  • Try: Run gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 1s

FAILURE: Build failed with an exception.

Evaluating settingsITIALIZING [18ms]

  • What went wrong: Task 'compile' is ambiguous in root project 'liquipostgres'. Candidates are: 'compileJava', 'compileTestJava'.

  • Try: Run gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org BUILD FAILED in 1s

When I do a: gradlew liquibaseDiffChangelog -PrunList=diffLog I get this error even when liquibase has connected and created the tables using the postgres datasource:

19:22:47.959 DEBUG [liquibase.servicelocator.ServiceLocator]: liquibase.ext.hibernate.database.HibernateSpringBeanDatabase matches liquibase.database.Database 19:22:47.987 DEBUG [liquibase.database.DatabaseFactory]: Properties: 19:22:47.987 DEBUG [liquibase.database.DatabaseFactory]: Key:'password' Value:'**********' 19:22:47.987 DEBUG [liquibase.database.DatabaseFactory]: Key:'user' Value:'liquipostgres' 19:22:47.987 DEBUG [liquibase.database.DatabaseFactory]: Connecting to the URL:'jdbc:postgresql://localhost:5432/liquipostgres' using driver:'org.postgresql.Driver' 19:22:48.102 ERROR [liquibase.integration.commandline.Main]: Unexpected error running Liquibase: org.postgresql.util.PSQLException: FATAL: la autentificaci¾n password fall¾ para el usuario ½liquipostgres╗ (pgjdbc: autodetected server-encoding to be ISO-8859-1, if the message is not readable, please check database logs and/or host, port, dbname, user, password, pg_hba.conf) liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: org.postgresql.util.PSQLException: FATAL: la autentificaci¾n password fall¾ para el usuario ½liquipostgres╗ (pgjdbc: autodetected server-encoding to be ISO-8859-1, if the message is not readable, please check database logs and/or host, port, dbname, user, password, pg_hba.conf) at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:132) at liquibase.integration.commandline.Main.doMigration(Main.java:1339) at liquibase.integration.commandline.Main.run(Main.java:302) at liquibase.integration.commandline.Main.main(Main.java:159) Caused by: liquibase.exception.DatabaseException: org.postgresql.util.PSQLException: FATAL: la autentificaci¾n password fall¾ para el usuario ½liquipostgres╗ (pgjdbc: autodetected server-encoding to be ISO-8859-1, if the message is not readable, please check database logs and/or host, port, dbname, user, password, pg_hba.conf) at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:263) at liquibase.database.DatabaseFactory.openDatabase(DatabaseFactory.java:149) at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:97) ... 3 common frames omitted Caused by: org.postgresql.util.PSQLException: FATAL: la autentificaci¾n password fall¾ para el usuario ½liquipostgres╗ (pgjdbc: autodetected server-encoding to be ISO-8859-1, if the message is not readable, please check database logs and/or host, port, dbname, user, password, pg_hba.conf) at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:525) at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:146) at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:197) at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49) at org.postgresql.jdbc.PgConnection.(PgConnection.java:211) at org.postgresql.Driver.makeConnection(Driver.java:459) at org.postgresql.Driver.connect(Driver.java:261) at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:255) ... 5 common frames omitted

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':liquibaseDiffChangeLog'.

Process 'command 'C:\Program Files\Java\jdk-11.0.5\bin\java.exe'' finished with non-zero exit value -1

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 2s 1 actionable task: 1 executed

Thanks for your help.

1 Answers

In production if your table have no data:

  1. delete from databasechangelog where id = 'create-table-changeset-id';
  2. drop table table_name;

That's all, in next deployment, new table will be created.

In production if your table have data:

  1. Create a new ChangeSet that includes your new changes

for example:

    <changeSet id="20200721000000" author="manual">
        <addColumn tableName="payment">
            <column name="paid" type="bit" />
...
  1. Include your ChangeSet(-file-name) in master.xml

  2. Test your changes in a local database(ideally exported production db) (optional but recommended)

Related