Skip to content

Commit

Permalink
grails#152 call Callback methods only on pending migrations (as in 1.x)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertoschwald committed Dec 19, 2020
1 parent 2e5fca6 commit 84e5ba0
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
package org.grails.plugins.databasemigration.liquibase

import groovy.transform.CompileStatic
import liquibase.Contexts
import liquibase.LabelExpression
import liquibase.Liquibase
import liquibase.database.Database
import liquibase.exception.DatabaseException
Expand Down Expand Up @@ -87,9 +89,18 @@ class GrailsLiquibase extends SpringLiquibase {
def database = liquibase.database
def migrationCallbacks = applicationContext.getBean('migrationCallbacks')


if (!liquibase.listUnrunChangeSets(new Contexts(getContexts()), new LabelExpression(getLabels()))) {
log.info("No migrations to run for ${liquibase.database.connection.catalog}")
return
}

log.info("Migrations detected for ${liquibase.database.connection.catalog}")

if (migrationCallbacks.metaClass.respondsTo(migrationCallbacks, 'beforeStartMigration')) {
migrationCallbacks.invokeMethod('beforeStartMigration', [database] as Object[])
}

if (migrationCallbacks.metaClass.respondsTo(migrationCallbacks, 'onStartMigration')) {
migrationCallbacks.invokeMethod('onStartMigration', [database, liquibase, changeLog] as Object[])
}
Expand Down

0 comments on commit 84e5ba0

Please sign in to comment.