AccountAccess: Remove unused methods

The database indexes that were only needed to support these methods are
deleted.

Change-Id: Iefc47c2dbe404453636d347c4fc2f3bc9a5c1cd4
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2017-03-10 14:35:58 +01:00
parent f36b3d7a75
commit 7a8022c764
6 changed files with 45 additions and 27 deletions

View File

@@ -31,16 +31,6 @@ public interface AccountAccess extends Access<Account, Account.Id> {
@Query("WHERE preferredEmail = ? LIMIT 2")
ResultSet<Account> byPreferredEmail(String email) throws OrmException;
@Query("WHERE fullName = ? LIMIT 2")
ResultSet<Account> byFullName(String name) throws OrmException;
@Query("WHERE fullName >= ? AND fullName <= ? ORDER BY fullName LIMIT ?")
ResultSet<Account> suggestByFullName(String nameA, String nameB, int limit) throws OrmException;
@Query("WHERE preferredEmail >= ? AND preferredEmail <= ? ORDER BY preferredEmail LIMIT ?")
ResultSet<Account> suggestByPreferredEmail(String nameA, String nameB, int limit)
throws OrmException;
@Query("ORDER BY accountId")
ResultSet<Account> all() throws OrmException;
}

View File

@@ -6,14 +6,10 @@
-- *********************************************************************
-- AccountAccess
-- covers: byPreferredEmail, suggestByPreferredEmail
-- covers: byPreferredEmail
CREATE INDEX accounts_byPreferredEmail
ON accounts (preferred_email);
-- covers: suggestByFullName
CREATE INDEX accounts_byFullName
ON accounts (full_name);
-- *********************************************************************
-- AccountGroupMemberAccess

View File

@@ -7,16 +7,11 @@ delimiter #
-- *********************************************************************
-- AccountAccess
-- covers: byPreferredEmail, suggestByPreferredEmail
-- covers: byPreferredEmail
CREATE INDEX accounts_byPreferredEmail
ON accounts (preferred_email)
#
-- covers: suggestByFullName
CREATE INDEX accounts_byFullName
ON accounts (full_name)
#
-- *********************************************************************
-- AccountGroupMemberAccess

View File

@@ -53,14 +53,10 @@ delimiter ;
-- *********************************************************************
-- AccountAccess
-- covers: byPreferredEmail, suggestByPreferredEmail
-- covers: byPreferredEmail
CREATE INDEX accounts_byPreferredEmail
ON accounts (preferred_email);
-- covers: suggestByFullName
CREATE INDEX accounts_byFullName
ON accounts (full_name);
-- *********************************************************************
-- AccountGroupMemberAccess

View File

@@ -35,7 +35,7 @@ import java.util.concurrent.TimeUnit;
/** A version of the database schema. */
public abstract class SchemaVersion {
/** The current schema version. */
public static final Class<Schema_151> C = Schema_151.class;
public static final Class<Schema_152> C = Schema_152.class;
public static int getBinaryVersion() {
return guessVersion(C);

View File

@@ -0,0 +1,41 @@
// Copyright (C) 2017 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.schema.sql.SqlDialect;
import com.google.gwtorm.server.OrmException;
import com.google.gwtorm.server.StatementExecutor;
import com.google.inject.Inject;
import com.google.inject.Provider;
import java.sql.SQLException;
/** Drop unused indexes from accounts table. */
public class Schema_152 extends SchemaVersion {
@Inject
Schema_152(Provider<Schema_151> prior) {
super(prior);
}
@Override
protected void migrateData(ReviewDb db, UpdateUI ui) throws OrmException, SQLException {
JdbcSchema schema = (JdbcSchema) db;
SqlDialect dialect = schema.getDialect();
try (StatementExecutor e = newExecutor(db)) {
dialect.dropIndex(e, "accounts", "accounts_byFullName");
}
}
}