Error validating jhipster fluids after object modification

I was trying to add a field to my object as a CLOB. When using the JHipster CLI, it wasn't hard to add it.

Now when I try to start my application, I get the following validation error from Liquibase:

liquibase.exception.ValidationFailedException: Validation Failed:
     1 change sets check sum
          config/liquibase/changelog/20170221193921_xxxxxxxx.xml::20170221193921-1::jhipster was: 7:d8b3f42d8d4d523c7b14f93b4c7657c7 but is now: 7:a2a365179a0d231c2771ebd79f51b1fc

      

I've also tried the following:

./mvnw liquibase:clearCheckSums

      

As a result it turned out BUILD SUCCESS

.

I also tried it. / mvnw liquidibase: update and updateSQL, same result.

Can anyone tell me what my problem is with JHipster?

+5


source to share


3 answers


When we use liquibase, all entity changes that occur later should be logged as separate change logs (for example, to change the table, for example, add a new column). The jhipster cli seems to always overwrite the entities (whichever has changed) into the appropriate fluid based files (usually a template 'config/liquibase/changelog/20180607110114_added_entity_Employee.xml'

). Therefore, the checksum of the entity liquibase file changes as it now has new content. And your database has a table named DATABASECHANGELOG

that stores all applied changes and they have checksum data.

Now when you run your application, you will get an error because your last modified entity changelog in liquibase is different from the last time (the database will have a checksum for this liquibase file for the previous version) that you ran.

mvn liquibase:clearCheckSums

is not the correct approach in most cases if it is not necessary. This actually clears all checksums in the database. You lose track of changes that have occurred that are not normally intended. These liquibase properties make sense, for example, when you want to rollback new changes that you applied. If you clear the checksums and run the application, it will calculate new checksums, you will lose track and could get in trouble if you don't pay enough attention.

Correct solution:



  1. Make changes to your objects using jhipster entity sub-generator

    or jdl import

    or manual changes to your entities directly

    .
  2. Now check if the object corresponding to the liquidase file has been modified or not. Usually the name contains '.._added_entity_...'

    . Eg 'config/liquibase/changelog/20180607110114_added_entity_Employee.xml'

    .
  3. Revert this file back to what it was in case it was overwritten. Git is useful for returning.
  4. If you run the application now, you will not get a validation checksum error because the checksum of the file matches.
  5. But the change we have made to the entity is not reflected in the fluid. To do this, you need to run mvn liquibase:diff

    . This will generate a changeLog file. Check it once by hand and add to liquibase master.xml

    . Adding to the main file is required as liquibase refers to this file for all changeLogs.
  6. If you run the application now and the changeLogs have not been applied, liquibase will try to apply these new changes to the database.

To summarize, jhipster cli overwrites liquibase entity files. Deselect them and run them mvn liquibase:diff

to commit the new objects to a new changeLog instead of overwriting the previously generated liquibase. We can see that the checksum error has been fixed, and the database changes are recorded in liquibase as well.

Links:
 - How to work with liquibase and Jhipster database updates. Check the course withDatabase updates

+10


source


Try the following query on your DB: UPDATE DATABASECHANGELOG SET MD5SUM = null WHERE ID = 'YOUR TABLE ID';



YOUR TABLE ID In this case, it looks like = 20170221193921-1.

+3


source


When we add a column to Jhipster using the command jhpster entity xxxx

, it is not added as a separate changeset , instead the column is added to the existing changeset for the create table, and since there is a change in the file, a new checksum is generated and included. startup is different from DB, so check failed

<changeSet id="20181209164925-1" author="jhipster" >    
    <createTable tableName="xxxxxx">
        <column name="id" type="bigint" autoIncrement="${autoIncrement}">
            <constraints primaryKey="true" nullable="false"/>
        </column>
        <column name="xxxxx" type="integer">

            <constraints nullable="true" />
        </column>
        <column name="xxxxx" type="integer">
            <constraints nullable="true" />
        </column>
        <column name="xxxxxx" type="varchar(140)">
            <constraints nullable="true" />
        </column> 
        <column name="xxxx" type="bigint">
            <constraints nullable="true" />
        </column>
        <!-- jhipster-needle-liquibase-add-column - JHipster will add columns here, do not remove-->
    </createTable>

      

To fix this issue, add a new changeset with adding column as tag ... shown below

<changeSet id="20181209164925-2" author="jhipster" runOnChange="true">      
    <addColumn tableName="xxxxxx">
         <column name="xxxxxx" type="date"></column>
    </addColumn>

      

see https://www.liquibase.org/documentation/changes/add_column.html

0


source







All Articles