grails-database-migration icon indicating copy to clipboard operation
grails-database-migration copied to clipboard

MD5SUM the same for all Grails Changes

Open virtualdogbert opened this issue 5 years ago • 3 comments

Task List

  • [ x ] Steps to reproduce provided
  • [ x ] Stacktrace (if present) provided
  • [ x ] Full description of the issue provided (see below)
  • [ x ] Link to the code that is causing this

Steps to Reproduce

  1. Run a migration script with multiple grails changes
  2. Look at the DB change log: SELECT * FROM tdstm.DATABASECHANGELOG where DESCRIPTION='Grails Change' order by ORDEREXECUTED desc
  3. Note the MD5SUM values are all the same

Expected Behaviour

All the MD5SUM values should be different even for grails changes and should be based off the content of the change script.

Actual Behaviour

All the MD5SUM values are the same for grails changes.

Environment Information

  • Operating System: MAC
  • Grails Version: 2.5.5, 3.3.10, 4.0.1
  • Plugin Version: any including the latest
  • Database: MYSQL
  • JDK Version: 1.8

The line of code responsible for this is: https://github.com/grails-plugins/grails-database-migration/blob/master/src/main/groovy/org/grails/plugins/databasemigration/liquibase/GroovyChange.groovy#L179

virtualdogbert avatar May 07 '20 20:05 virtualdogbert

@virtualdogbert I am not able to replicate this. All the md5sum values are different as expected for me.

bobbywarner avatar Jul 14 '20 15:07 bobbywarner

Are those md5sums for SQL change or Grails changes, because the md5 for all the grails changes I have are all the same... Actually, if I go back in time some of the MD5SUMs for grails changes are null. Screen Shot 2020-07-14 at 2 12 07 PM

virtualdogbert avatar Jul 14 '20 18:07 virtualdogbert

@bobbywarner just coming back to this wondering are you setting the checksum in all of your migrations? in the docs it says:

checkSum

The checksum for the change will be generated automatically, but if you want to override the value that gets hashed you can specify it with the checkSum(String value) method.

But the code does this

 @Override
    CheckSum generateCheckSum() {
        CheckSum.compute checksumString ?: 'Grails Change'
    }

So if you're not setting it manually, the check some become "Grails Change" for all Grails migrations, rendering the checksum essential useless for Grails changes.

virtualdogbert avatar Nov 09 '20 19:11 virtualdogbert