コード例 #1
0
  private EmbeddedMysql addSchema(final SchemaConfig schema) {
    Charset effectiveCharset = schema.getCharset().or(config.getCharset());

    getClient(SystemDefaults.SCHEMA)
        .executeCommands(
            format(
                "CREATE DATABASE %s CHARACTER SET = %s COLLATE = %s;",
                schema.getName(), effectiveCharset.getCharset(), effectiveCharset.getCollate()),
            format("GRANT ALL ON %s.* TO '%s'@'%%';", schema.getName(), config.getUsername()));

    getClient(schema.getName()).executeScripts(schema.getScripts());

    return this;
  }
コード例 #2
0
 public void reloadSchema(final String schemaName, final List<File> scripts) {
   reloadSchema(SchemaConfig.aSchemaConfig(schemaName).withScripts(scripts).build());
 }
コード例 #3
0
 public void reloadSchema(final SchemaConfig config) {
   getClient(SystemDefaults.SCHEMA).executeCommands(format("DROP DATABASE %s", config.getName()));
   addSchema(config);
 }
コード例 #4
0
 public Builder addSchema(final String name, final List<File> scripts) {
   this.schemas.add(SchemaConfig.aSchemaConfig(name).withScripts(scripts).build());
   return this;
 }