grails / grails-database-migration

Grails® framework Database Migration Plugin
Apache License 2.0
98 stars 115 forks source link

MD5SUM the same for all Grails Changes #172

Open virtualdogbert opened 4 years ago

virtualdogbert commented 4 years ago

Task List

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

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

bobbywarner commented 4 years ago

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

virtualdogbert commented 4 years ago

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 commented 4 years ago

@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.