Permalink
Browse files

GRAILS-7051 added --datasource option to export ddl for a particular …

…datasource
  • Loading branch information...
1 parent 78892f5 commit 55b34b5138089aea4b4688ed82da158f8909da2f @burtbeckwith burtbeckwith committed Jul 3, 2011
Showing with 6 additions and 3 deletions.
  1. +6 −3 scripts/SchemaExport.groovy
@@ -25,7 +25,7 @@ includeTargets << grailsScript('_GrailsBootstrap')
*/
target(schemaExport: 'Run Hibernate SchemaExport') {
- depends checkVersion, configureProxy, bootstrap
+ depends checkVersion, configureProxy, enableExpandoMetaClass, bootstrap
String filename = "${grailsSettings.projectTargetDir}/ddl.sql"
boolean export = false
@@ -40,18 +40,21 @@ target(schemaExport: 'Run Hibernate SchemaExport') {
}
}
+ String datasourceSuffix = argsMap.datasource ? '_' + argsMap.datasource : ''
+
def file = new File(filename)
ant.mkdir dir: file.parentFile
- // TODO need to support specifying datasource name
- def configuration = appCtx.getBean('&sessionFactory').configuration
+ def configuration = appCtx.getBean('&sessionFactory' + datasourceSuffix).configuration
def schemaExport = new HibernateSchemaExport(configuration)
.setHaltOnError(true)
.setOutputFile(file.path)
.setDelimiter(';')
String action = export ? "Exporting" : "Generating script to ${file.path}"
+ String ds = argsMap.datasource ? "for DataSource '$argsMap.datasource'" : "for the default DataSource"
+ println "$action in environment '$grailsEnv' $ds"
if (export) {
// 1st drop, warning exceptions

0 comments on commit 55b34b5

Please sign in to comment.