Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import liquibase.parser.ChangeLogParserFactory
import liquibase.servicelocator.ServiceLocator
import org.grails.plugins.databasemigration.liquibase.GormDatabase
import org.grails.plugins.databasemigration.liquibase.GrailsLiquibase
import org.grails.plugins.databasemigration.liquibase.GrailsLiquibaseFactory
import org.grails.plugins.databasemigration.liquibase.GroovyChangeLogParser
import org.springframework.context.ApplicationContext

Expand All @@ -47,7 +48,9 @@ class DatabaseMigrationGrailsPlugin extends Plugin {
@Override
Closure doWithSpring() {
configureLiquibase()
return { -> }
return { ->
grailsLiquibaseFactory(GrailsLiquibaseFactory, applicationContext)
}
}

@Override
Expand All @@ -73,7 +76,7 @@ class DatabaseMigrationGrailsPlugin extends Plugin {
}

new DatabaseMigrationTransactionManager(applicationContext, dataSourceName).withTransaction {
GrailsLiquibase gl = new GrailsLiquibase(applicationContext)
GrailsLiquibase gl = applicationContext.getBean('grailsLiquibaseFactory', GrailsLiquibase)
gl.dataSource = getDataSourceBean(applicationContext, dataSourceName)
gl.dropFirst = config.getProperty("${configPrefix}.dropOnStart", Boolean, false)
gl.changeLog = config.getProperty("${configPrefix}.updateOnStartFileName", String, isDefaultDataSource(dataSourceName) ? 'changelog.groovy' : "changelog-${dataSourceName}.groovy")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.grails.plugins.databasemigration.liquibase

import org.springframework.beans.factory.config.AbstractFactoryBean
import org.springframework.context.ApplicationContext

class GrailsLiquibaseFactory extends AbstractFactoryBean<GrailsLiquibase> {

private final ApplicationContext applicationContext

GrailsLiquibaseFactory(ApplicationContext applicationContext) {
setSingleton(false)
this.applicationContext = applicationContext
}

@Override
Class<?> getObjectType() {
return GrailsLiquibase
}

@Override
protected GrailsLiquibase createInstance() throws Exception {
return new GrailsLiquibase(applicationContext)
}
}