Merge changes I3dff9104,Icffbbcce

* changes:
  PatchSet: Correct misspelling and type of pushCertificate field
  SchemaVersion: Fix renameColumn method
This commit is contained in:
Dave Borowitz
2016-01-20 14:09:22 +00:00
committed by Gerrit Code Review
3 changed files with 49 additions and 6 deletions

View File

@@ -187,9 +187,11 @@ public final class PatchSet {
@Column(id = 6, notNull = false)
protected String groups;
//DELETED id = 7 (pushCertficate)
/** Certificate sent with a push that created this patch set. */
@Column(id = 7, notNull = false)
protected String pushCertficate;
@Column(id = 8, notNull = false, length = Integer.MAX_VALUE)
protected String pushCertificate;
protected PatchSet() {
}
@@ -251,11 +253,11 @@ public final class PatchSet {
}
public String getPushCertificate() {
return pushCertficate;
return pushCertificate;
}
public void setPushCertificate(String cert) {
pushCertficate = cert;
pushCertificate = cert;
}
@Override

View File

@@ -32,7 +32,7 @@ import java.util.List;
/** A version of the database schema. */
public abstract class SchemaVersion {
/** The current schema version. */
public static final Class<Schema_116> C = Schema_116.class;
public static final Class<Schema_117> C = Schema_117.class;
public static int getBinaryVersion() {
return guessVersion(C);
@@ -176,7 +176,7 @@ public abstract class SchemaVersion {
throws OrmException {
JdbcSchema s = (JdbcSchema) db;
try (JdbcExecutor e = new JdbcExecutor(s)) {
s.renameField(e, table, from, to);
s.renameColumn(e, table, from, to);
}
}

View File

@@ -0,0 +1,41 @@
// 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.SQLException;
import java.sql.Statement;
public class Schema_117 extends SchemaVersion {
@Inject
Schema_117(Provider<Schema_116> prior) {
super(prior);
}
@Override
protected void preUpdateSchema(ReviewDb db) throws OrmException {
renameColumn(db, "patch_sets", "push_certficate", "push_certificate");
try (Statement stmt = ((JdbcSchema) db).getConnection().createStatement()) {
stmt.execute("ALTER TABLE patch_sets MODIFY push_certificate clob");
} catch (SQLException e) {
// Ignore. Type may have already been modified manually.
}
}
}