PatchSet: Correct misspelling and type of pushCertificate field

I519240547 extended the patch_sets table with a pushCertificate column
to store push the certificate that was used when pushing a signed
commit.

However, the column type VARCHAR(255) is too small for PGP certificate
descriptions. The column name was also misspelled as "pushCertficate"
(missing a 'i').

Extend the column from VARCHAR(255) to CLOB, as used in the account
table ssh key column. At the same time, correct the misspelling.

Reported-By: Henrik Laban Sköllermark <laban@kryo.se>
Change-Id: I3dff91041c00f619f06c0e64c5cb09e3987eac9a
This commit is contained in:
David Pursehouse
2016-01-20 13:44:29 +09:00
parent 42d658bcb8
commit 547886f396
3 changed files with 48 additions and 5 deletions

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);

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.
}
}
}