Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
BZ-1049238: Optimize DDL scripts for production use
Browse files Browse the repository at this point in the history
  • Loading branch information
dgutierr committed Sep 29, 2015
1 parent 5ab838c commit dac039a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Expand Up @@ -47,7 +47,7 @@ public class DatabaseAutoSynchronizer {
@Inject @Config("dashb_installed_module")
protected String installedModulesTable;

@Inject @Config("DELIMITER //,//,// DELIMITER ;,GO")
@Inject @Config("DELIMITER //,//,DELIMITER ;,GO")
protected String[] excludedScriptStatements;

@Inject @Config("-- CUSTOM_DELIMITER")
Expand Down Expand Up @@ -105,16 +105,17 @@ protected void runSQLFile(File f) throws Exception {
}

protected void runDDL(final String ddl) throws Exception {
String separator = ";";
if (ddl.startsWith(customDelimiterEnabler)) separator = customDelimiter;
String separator = ddl.startsWith(customDelimiterEnabler) ? customDelimiter : ";";
String[] statements = splitString(ddl, separator);
for (int i = 0; i < statements.length; i++) {
final String ddlStatement = removeComments(statements[i]).trim();
if (ddlStatement.length() == 0 || ArrayUtils.contains(excludedScriptStatements, ddlStatement)) {
continue;
}

if (log.isDebugEnabled()) log.debug("Running statement: " + ddlStatement);
if (log.isDebugEnabled()) {
log.debug("Running statement: " + ddlStatement);
}
new HibernateTxFragment() {
protected void txFragment(Session session) throws Exception {
Work w = new Work() {
Expand Down
Expand Up @@ -47,7 +47,10 @@ BEGIN
END
-- CUSTOM_DELIMITER

// DELIMITER ;
//
-- CUSTOM_DELIMITER

DELIMITER ;
-- CUSTOM_DELIMITER

CREATE TABLE dashb_data_source (
Expand Down

0 comments on commit dac039a

Please sign in to comment.