GrailsOnStart Database Migration Module Update Does Not Work

I need help here. I configured the database migration plugin as the documentation says:

grails.plugin.databasemigration.updateOnStart = true
grails.plugin.databasemigration.updateOnStartFileNames = ['changelog.groovy']

This works fine when running the 'grails run-app'. My database is migrated as expected, but how do I get this behavior when deploying the grails war artifact?

I tested it on tomcat, manually copying the artifact to the tomcat / webapps folder, but during deployment hibernate complains about the lack of columns (the one that was supposed to be created by the database migration plugin).

Any ideas?

Thank!

+4
source share
3 answers

Are you sure these two lines of code are also available in the production environment?

, :

environments {
    development {
        grails.plugin.databasemigration.updateOnStart = true
        grails.plugin.databasemigration.updateOnStartFileNames = ['changelog.groovy']
        // ... other useful development settings
    }
    test {
        grails.plugin.databasemigration.updateOnStart = true
        grails.plugin.databasemigration.autoMigrateScripts = ['RunApp','TestApp']
        grails.plugin.databasemigration.forceAutoMigrate = true
        grails.plugin.databasemigration.dropOnStart = true
        if (loadTestData) {
            grails.plugin.databasemigration.updateOnStartFileNames = ['testchangelog.groovy', 'testdata.groovy']
        } else {
            grails.plugin.databasemigration.updateOnStartFileNames = ['testchangelog.groovy']
        // ... something test-related
        }
    }
    production {
        grails.plugin.databasemigration.updateOnStart = true
        grails.plugin.databasemigration.updateOnStartFileNames = ['changelog.groovy']
        // ... production config settings
    }
}

, dbCreate DataSource.groovy, .

+3

. fooobar.com/questions/1535291/...

I believe that the default value for grails.plugin.databasemigration.changelogLocationat compile time is correct so that your change logs are included in the production war. That is, I do not set / do not change this property at Config.groovycompile time.

But in the deployment I installed grails.plugin.databasemigration.changelogLocation = 'migrations', since the change logs end in WEB-INF/classes/migrations/(as groovy scripts, not compiled classes).

0
source

Source: https://habr.com/ru/post/1535289/


All Articles