Search in sources :

Example 6 with StatementExecutor

use of com.google.gwtorm.server.StatementExecutor in project gerrit by GerritCodeReview.

the class SchemaVersion method upgradeFrom.

/** Runs check on the prior schema version, and then upgrades. */
private void upgradeFrom(UpdateUI ui, CurrentSchemaVersion curr, ReviewDb db) throws OrmException, SQLException {
    List<SchemaVersion> pending = pending(curr.versionNbr);
    updateSchema(pending, ui, db);
    migrateData(pending, ui, curr, db);
    JdbcSchema s = (JdbcSchema) db;
    final List<String> pruneList = new ArrayList<>();
    s.pruneSchema(new StatementExecutor() {

        @Override
        public void execute(String sql) {
            pruneList.add(sql);
        }

        @Override
        public void close() {
        // Do nothing.
        }
    });
    try (JdbcExecutor e = new JdbcExecutor(s)) {
        if (!pruneList.isEmpty()) {
            ui.pruneSchema(e, pruneList);
        }
    }
}
Also used : CurrentSchemaVersion(com.google.gerrit.reviewdb.client.CurrentSchemaVersion) JdbcSchema(com.google.gwtorm.jdbc.JdbcSchema) ArrayList(java.util.ArrayList) JdbcExecutor(com.google.gwtorm.jdbc.JdbcExecutor) StatementExecutor(com.google.gwtorm.server.StatementExecutor)

Aggregations

StatementExecutor (com.google.gwtorm.server.StatementExecutor)6 JdbcSchema (com.google.gwtorm.jdbc.JdbcSchema)5 SqlDialect (com.google.gwtorm.schema.sql.SqlDialect)4 OrmException (com.google.gwtorm.server.OrmException)3 FactoryModule (com.google.gerrit.extensions.config.FactoryModule)1 CurrentSchemaVersion (com.google.gerrit.reviewdb.client.CurrentSchemaVersion)1 SystemConfig (com.google.gerrit.reviewdb.client.SystemConfig)1 ReviewDb (com.google.gerrit.reviewdb.server.ReviewDb)1 GerritPersonIdent (com.google.gerrit.server.GerritPersonIdent)1 AllProjectsName (com.google.gerrit.server.config.AllProjectsName)1 AllUsersName (com.google.gerrit.server.config.AllUsersName)1 AnonymousCowardName (com.google.gerrit.server.config.AnonymousCowardName)1 GerritServerConfig (com.google.gerrit.server.config.GerritServerConfig)1 SitePaths (com.google.gerrit.server.config.SitePaths)1 GitRepositoryManager (com.google.gerrit.server.git.GitRepositoryManager)1 ConfigNotesMigration (com.google.gerrit.server.notedb.ConfigNotesMigration)1 InMemoryRepositoryManager (com.google.gerrit.testutil.InMemoryRepositoryManager)1 JdbcExecutor (com.google.gwtorm.jdbc.JdbcExecutor)1 DialectPostgreSQL (com.google.gwtorm.schema.sql.DialectPostgreSQL)1 SchemaFactory (com.google.gwtorm.server.SchemaFactory)1