Generator-jhipster: mvn liquibase:diff checksum validation problem after modifying entity

Created on 6 Apr 2018  路  6Comments  路  Source: jhipster/generator-jhipster

Overview of the issue

After regenerating an entity, I get this error :

 change sets check sum
          config/liquibase/changelog/20180403061345_added_entity_SpyEvent.xml::20180403061345-1::jhipster was: 7:66f49af3dc2a8a590be256531a90feef but is now: 7:0338777b2908da772f5167c024316c10


liquibase.exception.ValidationFailedException: Validation Failed:
     1 change sets check sum
          config/liquibase/changelog/20180403061345_added_entity_SpyEvent.xml::20180403061345-1::jhipster was: 7:66f49af3dc2a8a590be256531a90feef but is now: 7:0338777b2908da772f5167c024316c10

    at liquibase.changelog.DatabaseChangeLog.validate(DatabaseChangeLog.java:266)
##### **Related issues** https://github.com/jhipster/generator-jhipster/issues/6176 ##### **JHipster configuration** `##### **JHipster Version(s)**
[email protected] E:\RealmSpySandbox
`-- [email protected]

##### **JHipster configuration, a `.yo-rc.json` file generated in the root folder**
.yo-rc.json file
{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "com.realmspy.sandbox"
    },
    "jhipsterVersion": "4.14.1",
    "baseName": "RealmSpySandbox",
    "packageName": "com.realmspy.sandbox",
    "packageFolder": "com/realmspy/sandbox",
    "serverPort": "8080",
    "authenticationType": "jwt",
    "cacheProvider": "no",
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "prodDatabaseType": "mysql",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": false,
    "buildTool": "maven",
    "enableSocialSignIn": false,
    "enableSwaggerCodegen": false,
    "jwtSecretKey": "replaced-by-jhipster-info",
    "clientFramework": "angularX",
    "useSass": true,
    "clientPackageManager": "yarn",
    "applicationType": "monolith",
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "enableTranslation": false,
    "enableHibernateCache": false
  }
}

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


JDL entity definitions

entity SpyEvent (spy_event) {
  server Server required,
  map String,
  intCondition Integer
}

enum Server {
  USEast2,
   USEast,
   USSouthWest,
   AsiaSouthEast,
   USWest,
   USNorthWest
}

relationship ManyToOne {
  SpyEvent{user required} to User
}


Environment and Tools

java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)

git version 2.16.1.windows.1

node: v8.9.4

npm: 5.6.0

gulp:
[14:59:21] CLI version 2.0.1

yeoman: 2.0.1

yarn: 1.5.1

Docker version 18.03.0-ce, build 0520e24

docker-compose version 1.20.1, build 5d8c71b2

`

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

`{
"fluentMethods": true,
"relationships": [
{
"relationshipName": "user",
"otherEntityName": "user",
"relationshipType": "many-to-one",
"relationshipValidateRules": [],
"otherEntityField": "id"
}
],
"fields": [
{
"fieldName": "server",
"fieldType": "Server",
"fieldValues": "USEast2, USEast, USSouthWest, AsiaSouthEast, USWest, USNorthWest",
"fieldValidateRules": [
"required"
]
},
{
"fieldName": "map",
"fieldType": "String",
"fieldValidateRules": []
},
{
"fieldName": "intCondition",
"fieldType": "Integer",
"fieldValidateRules": []
}
],
"changelogDate": "20180403061345",
"dto": "no",
"service": "no",
"entityTableName": "spy_event",
"jpaMetamodelFiltering": false,
"pagination": "no"
}

`

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

Most helpful comment

When you update your entities, whatever the mean(by updating your jdl file or using the entity sub-generator directly), make sure to choose not to override your existing changelog files: as this will cause liquibase to fail as described.

Then, to inform liquibase what changes it needs to apply to your database , generate a changelog file resuming the changes you just did by using mvnw liquibase:diff . Rename that file as to remind you or your team your changes, add it to the master.xml file and re-run your app.

Everything should be OK.

Hope it helps someone.

All 6 comments

Yes if you re-generate an entity that's "normal", let me explain. Considering you modified something in your entity, of course (otherwise it doesn't make any sense):

  • If you do a jhispter entity Foo this is going to regenerate your Liquibase changelog. So it won't work on an existing database, unless you drop it of course. So it's easier, but this would mostly be used in development.
  • If you do a "mvn liquibase:diff" it will generate a new changelog. You will have more things to code, and you also need to add the changelog to the master.xml (as here it's a more manual work), but that would work on an existing database.

So it depends on your context: if you are in development you can drop your data and code quickly, and if you are in production you can't drop your data and you will have a bit more work.

Hi,
@jdubois when you said "You will have more things to code" in the second solution, what's mean?
I must code what?and where?
thanks

You will need to migrate your database schema, and more importantly your data, all by hand.
That's a complex and error-prone task.
Also, if you work in a team you will need to tell your coworkers to update their database manually when they pull your new code.
For all this, I feel it's easier to use Liquibase than doing stuff by hand, but then JHipster is just here to help by pushing a solution, and it's made to be disabled easily.

Thank you for your response;
I forgot to mention that I use this commande
jhipster import-jdl dataBase.jdl
to add a field.
So all data are correctly and automatically generated.
and after that i generated a changelog with mvnw liquibase:diff .
it's for that I don't see what i must do more ( i update my database(mysql))

When you update your entities, whatever the mean(by updating your jdl file or using the entity sub-generator directly), make sure to choose not to override your existing changelog files: as this will cause liquibase to fail as described.

Then, to inform liquibase what changes it needs to apply to your database , generate a changelog file resuming the changes you just did by using mvnw liquibase:diff . Rename that file as to remind you or your team your changes, add it to the master.xml file and re-run your app.

Everything should be OK.

Hope it helps someone.

Was this page helpful?
0 / 5 - 0 ratings