Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

…datasource
  • Loading branch information...
commit 55b34b5138089aea4b4688ed82da158f8909da2f 1 parent 78892f5
@burtbeckwith burtbeckwith authored
Showing with 6 additions and 3 deletions.
  1. +6 −3 scripts/SchemaExport.groovy
View
9 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,11 +40,12 @@ 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)
@@ -52,6 +53,8 @@ target(schemaExport: 'Run Hibernate SchemaExport') {
.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
Please sign in to comment.
Something went wrong with that request. Please try again.