Search code examples
jhipsterliquibasejhipster-gateway

New authority Jhipster


I followed those instructions from the article https://www.jhipster.tech/tips/025_tip_create_new_authority.html and I added a new authority "ROLE_CLIENT" After that, I restarted my project, An error has appeared :

2021-07-13 00:22:46.592  WARN 3596 --- [  restartedMain] iguration$LoadBalancerCaffeineWarnLogger : Spring Cloud LoadBalancer is currently working with the default cache. You can switch to using Caffeine cache, by adding it and org.springframework.cache.caffeine.CaffeineCacheManager to the classpath.
2021-07-13 00:22:46.806 ERROR 3596 --- [ gateway-task-1] t.j.c.liquibase.AsyncSpringLiquibase     : Liquibase could not start correctly, your database is NOT ready: Validation Failed:
     1 change sets check sum
          config/liquibase/changelog/00000000000000_initial_schema.xml::00000000000001::jhipster was: 8:06225dfc05215e6b13d8a4febd3fd90f but is now: 8:2272077bd3e9baf389312f0e018e5795


liquibase.exception.ValidationFailedException: Validation Failed:
     1 change sets check sum
          config/liquibase/changelog/00000000000000_initial_schema.xml::00000000000001::jhipster was: 8:06225dfc05215e6b13d8a4febd3fd90f but is now: 8:2272077bd3e9baf389312f0e018e5795

        at liquibase.changelog.DatabaseChangeLog.validate(DatabaseChangeLog.java:299)
        at liquibase.Liquibase.lambda$update$1(Liquibase.java:237)
        at liquibase.Scope.lambda$child$0(Scope.java:160)
        at liquibase.Scope.child(Scope.java:169)
        at liquibase.Scope.child(Scope.java:159)
        at liquibase.Scope.child(Scope.java:138)
        at liquibase.Liquibase.runInScope(Liquibase.java:2370)
        at liquibase.Liquibase.update(Liquibase.java:217)
        at liquibase.Liquibase.update(Liquibase.java:203)
        at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:321)
        at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:275)
        at org.springframework.boot.autoconfigure.liquibase.DataSourceClosingSpringLiquibase.afterPropertiesSet(DataSourceClosingSpringLiquibase.java:46)
        at tech.jhipster.config.liquibase.AsyncSpringLiquibase.initDb(AsyncSpringLiquibase.java:118)
        at tech.jhipster.config.liquibase.AsyncSpringLiquibase.lambda$afterPropertiesSet$0(AsyncSpringLiquibase.java:93)
        at tech.jhipster.async.ExceptionHandlingAsyncTaskExecutor.lambda$createWrappedRunnable$1(ExceptionHandlingAsyncTaskExecutor.java:78)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)

By the way, I am using microservices architecture and JWT authentication.


Solution

  • This is normal: a Liquibase changeset is supposed to be immutable.

    This is why Liquibase records md5 checksum with each changeset entry in the database changelog table to detect differences between what is currently in the changelog and what was actually ran against the database.

    When you modified authority.csv, the checksum of the changeset changed and Liquibase rightly complained.

    So, you have 3 alternative solutions:

    1. Create a separate changeset to insert only your new authority (preferred way in production)
    2. Clear the checksum column of your changeset in your use a db client like DBeaver to connect to your db and delete the MD5SUM column for your changelog row in DATABASECHANGELOG table. Look at https://docs.liquibase.com/concepts/basic/databasechangelog-table.html
    3. Drop your database to restart from scratch, this could work for a dev database if you don't care about yourdata

    Final advice: learn more about Liquibase from official docs also from JHipster doc