Search in sources :

Example 1 with CreateDatabase

use of org.platformlayer.ops.postgres.CreateDatabase in project platformlayer by platformlayer.

the class GerritDatabaseController method addChildren.

@Override
protected void addChildren() throws OpsException {
    GerritDatabaseTemplate template = injected(GerritDatabaseTemplate.class);
    DatabaseConnection dbConnection;
    {
        dbConnection = addChild(DatabaseConnection.build(template.getDatabaseServerKey()));
        dbConnection.databaseName = template.getDatabaseName();
    }
    {
        CreateDatabase db = dbConnection.addChild(CreateDatabase.class);
        db.databaseName = template.getDatabaseName();
    }
    {
        CreateUser db = dbConnection.addChild(CreateUser.class);
        db.grantDatabaseName = template.getDatabaseName();
        db.databaseUser = template.getDatabaseUsername();
        db.databasePassword = template.getDatabasePassword();
    }
    {
        RunScript script = dbConnection.addChild(RunScript.class);
        try {
            script.sql = ResourceUtils.get(getClass(), "schema.sql");
        } catch (IOException e) {
            throw new OpsException("Error loading SQL script resource", e);
        }
    }
}
Also used : OpsException(org.platformlayer.ops.OpsException) CreateUser(org.platformlayer.ops.postgres.CreateUser) DatabaseConnection(org.platformlayer.ops.postgres.DatabaseConnection) CreateDatabase(org.platformlayer.ops.postgres.CreateDatabase) RunScript(org.platformlayer.ops.postgres.RunScript) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 OpsException (org.platformlayer.ops.OpsException)1 CreateDatabase (org.platformlayer.ops.postgres.CreateDatabase)1 CreateUser (org.platformlayer.ops.postgres.CreateUser)1 DatabaseConnection (org.platformlayer.ops.postgres.DatabaseConnection)1 RunScript (org.platformlayer.ops.postgres.RunScript)1