Examples of DbScript


Examples of com.opengamma.util.db.script.DbScript

    }
    try (SqlScriptWriter writer = createSqlScriptWriter()) {
      Set<String> schemaNames = getDbToolContext().getSchemaNames() != null ? getDbToolContext().getSchemaNames() : getAllSchemaNames();
      for (String schema : schemaNames) {
        s_logger.info("Processing schema " + schema);
        DbScript script = getCreationScript(schema);
        s_logger.debug("Using script: " + script);
        writer.write(schema, script);
      }
      s_logger.info("Scripts processed successfully");
    } catch (IOException e) {
View Full Code Here

Examples of com.opengamma.util.db.script.DbScript

          continue;
        }
        upgradeRequired = true;
        s_logger.info(schema + " is behind by " + scripts.size() + " versions");
        for (int i = 0; i < scripts.size(); i++) {
          DbScript script = scripts.get(i);
          s_logger.debug("Using schema migration file: " + script);
          writer.write(schema + " - " + (i + 1) + " of " + scripts.size(), script);
        }
      }
    } catch (IOException e) {
View Full Code Here

Examples of com.opengamma.util.db.script.DbScript

  }

  public void createTables(DbSchemaGroupMetadata schemaGroupMetadata, String catalog, String schema, int targetVersion, int migrateFromVersion, final TableCreationCallback callback) {
    // create
    String dbVendorName = _dialect.getDatabaseName();
    DbScript createScript = schemaGroupMetadata.getCreateScript(dbVendorName, migrateFromVersion);
    if (createScript == null) {
      throw new OpenGammaRuntimeException("Missing create script for V" + migrateFromVersion + ", database " + dbVendorName + ", schema group " + schemaGroupMetadata.getSchemaGroupName());
    }
    s_logger.debug("Creating {} DB version {}", schemaGroupMetadata.getSchemaGroupName(), migrateFromVersion);
    s_logger.debug("Executing create script {}", createScript.getName());
    executeSQLScript(catalog, schema, createScript);
    if (callback != null) {
      callback.tablesCreatedOrUpgraded(migrateFromVersion, schemaGroupMetadata);
    }
    // migrates
    for (int v = migrateFromVersion; v < targetVersion; v++) {
      DbScript migrateScript = schemaGroupMetadata.getMigrateScript(dbVendorName, v);
      if (migrateScript == null) {
        throw new OpenGammaRuntimeException("The " + v + " migrate script is missing for " + dbVendorName + " and schema group " + schemaGroupMetadata.getSchemaGroupName());
      }
      s_logger.debug("Migrating DB from version {} to {}", v, v + 1);
      s_logger.debug("Executing migrate script {}", migrateScript.getName());
      executeSQLScript(catalog, schema, migrateScript);
      if (callback != null) {
        callback.tablesCreatedOrUpgraded(v + 1, schemaGroupMetadata);
      }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.