// Copyright (C) 2016 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.gerrit.server.schema;

import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gwtorm.jdbc.JdbcSchema;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.Provider;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Set;

public class Schema_117 extends ReviewDbSchemaVersion {
  @Inject
  Schema_117(Provider<Schema_116> prior) {
    super(prior);
  }

  @Override
  protected void preUpdateSchema(ReviewDb db) throws OrmException, SQLException {
    JdbcSchema schema = (JdbcSchema) db;
    Connection connection = schema.getConnection();
    String tableName = "patch_sets";
    String oldColumnName = "push_certficate";
    String newColumnName = "push_certificate";
    Set<String> columns = schema.getDialect().listColumns(connection, tableName);
    if (columns.contains(oldColumnName)) {
      renameColumn(db, tableName, oldColumnName, newColumnName);
    }
    try (Statement stmt = schema.getConnection().createStatement()) {
      stmt.execute("ALTER TABLE " + tableName + " MODIFY " + newColumnName + " clob");
    } catch (SQLException e) {
      // Ignore.  Type may have already been modified manually.
    }
  }
}
