Created
July 23, 2015 14:03
-
-
Save dreab8/a288187ec99163514215 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void doCreation(Metadata metadata, boolean createNamespaces, Dialect dialect, Target... targets) | |
throws SchemaManagementException { | |
boolean tryToCreateCatalogs = false; | |
boolean tryToCreateSchemas = false; | |
if ( createNamespaces ) { | |
if ( dialect.canCreateSchema() ) { | |
tryToCreateSchemas = true; | |
} | |
if(dialect.canCreateCatalog()){ | |
tryToCreateCatalogs = true; | |
} | |
} | |
....... | |
// first, create each schema | |
if ( tryToCreateSchemas ) { | |
Set<Identifier> exportedCatalogs = new HashSet<Identifier>(); | |
for ( Schema schema : database.getSchemas() ) { | |
if ( schema.getName().getSchema() == null ) { | |
continue; | |
} | |
if ( tryToCreateCatalogs ) { | |
final Identifier catalog = schema.getName().getCatalog(); | |
if ( catalog != null && !exportedCatalogs.contains( catalog ) ) { | |
applySqlStrings( | |
targets, dialect.getCreateCatalogCommand( | |
catalog.render( | |
dialect | |
) | |
) | |
); | |
exportedCatalogs.add( catalog ); | |
} | |
} | |
applySqlStrings( | |
targets, dialect.getCreateSchemaCommand( | |
schema.getName() | |
.getSchema() | |
.render( dialect ) | |
) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment