Merge "Drop ReviewDb group tables"

This commit is contained in:
Edwin Kempin 2018-03-28 13:41:17 +00:00 committed by Gerrit Code Review
commit f4c0f17c1e
11 changed files with 125 additions and 124 deletions

View File

@ -53,17 +53,13 @@ public interface ReviewDb extends Schema {
// Deleted @Relation(id = 8)
@Relation(id = 10)
AccountGroupAccess accountGroups();
// Deleted @Relation(id = 10)
@Relation(id = 11)
AccountGroupNameAccess accountGroupNames();
// Deleted @Relation(id = 11)
@Relation(id = 12)
AccountGroupMemberAccess accountGroupMembers();
// Deleted @Relation(id = 12)
@Relation(id = 13)
AccountGroupMemberAuditAccess accountGroupMembersAudit();
// Deleted @Relation(id = 13)
// Deleted @Relation(id = 17)
@ -92,11 +88,9 @@ public interface ReviewDb extends Schema {
// Deleted @Relation(id = 28)
@Relation(id = 29)
AccountGroupByIdAccess accountGroupById();
// Deleted @Relation(id = 29)
@Relation(id = 30)
AccountGroupByIdAudAccess accountGroupByIdAud();
// Deleted @Relation(id = 30)
int FIRST_ACCOUNT_ID = 1000000;

View File

@ -114,26 +114,6 @@ public class ReviewDbWrapper implements ReviewDb {
return delegate.systemConfig();
}
@Override
public AccountGroupAccess accountGroups() {
return delegate.accountGroups();
}
@Override
public AccountGroupNameAccess accountGroupNames() {
return delegate.accountGroupNames();
}
@Override
public AccountGroupMemberAccess accountGroupMembers() {
return delegate.accountGroupMembers();
}
@Override
public AccountGroupMemberAuditAccess accountGroupMembersAudit() {
return delegate.accountGroupMembersAudit();
}
@Override
public ChangeAccess changes() {
return delegate.changes();
@ -159,16 +139,6 @@ public class ReviewDbWrapper implements ReviewDb {
return delegate.patchComments();
}
@Override
public AccountGroupByIdAccess accountGroupById() {
return delegate.accountGroupById();
}
@Override
public AccountGroupByIdAudAccess accountGroupByIdAud() {
return delegate.accountGroupByIdAud();
}
@Override
@SuppressWarnings("deprecation")
public int nextAccountId() throws OrmException {

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_167> C = Schema_167.class;
public static final Class<Schema_168> C = Schema_168.class;
public static int getBinaryVersion() {
return guessVersion(C);

View File

@ -0,0 +1,26 @@
// Copyright (C) 2018 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.inject.Inject;
import com.google.inject.Provider;
/** Drop group tables. */
public class Schema_168 extends SchemaVersion {
@Inject
Schema_168(Provider<Schema_167> prior) {
super(prior);
}
}

View File

@ -14,12 +14,6 @@
package com.google.gerrit.testing;
import com.google.gerrit.reviewdb.server.AccountGroupAccess;
import com.google.gerrit.reviewdb.server.AccountGroupByIdAccess;
import com.google.gerrit.reviewdb.server.AccountGroupByIdAudAccess;
import com.google.gerrit.reviewdb.server.AccountGroupMemberAccess;
import com.google.gerrit.reviewdb.server.AccountGroupMemberAuditAccess;
import com.google.gerrit.reviewdb.server.AccountGroupNameAccess;
import com.google.gerrit.reviewdb.server.ChangeAccess;
import com.google.gerrit.reviewdb.server.ChangeMessageAccess;
import com.google.gerrit.reviewdb.server.PatchLineCommentAccess;
@ -81,26 +75,6 @@ public class DisabledReviewDb implements ReviewDb {
throw new Disabled();
}
@Override
public AccountGroupAccess accountGroups() {
throw new Disabled();
}
@Override
public AccountGroupNameAccess accountGroupNames() {
throw new Disabled();
}
@Override
public AccountGroupMemberAccess accountGroupMembers() {
throw new Disabled();
}
@Override
public AccountGroupMemberAuditAccess accountGroupMembersAudit() {
throw new Disabled();
}
@Override
public ChangeAccess changes() {
throw new Disabled();
@ -126,16 +100,6 @@ public class DisabledReviewDb implements ReviewDb {
throw new Disabled();
}
@Override
public AccountGroupByIdAccess accountGroupById() {
throw new Disabled();
}
@Override
public AccountGroupByIdAudAccess accountGroupByIdAud() {
throw new Disabled();
}
@Override
public int nextAccountId() {
throw new Disabled();

View File

@ -35,6 +35,7 @@ import com.google.inject.Provider;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.Timestamp;
import java.time.Instant;
import java.time.LocalDateTime;
@ -72,6 +73,36 @@ public class Schema_150_to_151_Test {
assume().that(db instanceof JdbcSchema).isTrue();
connection = ((JdbcSchema) db).getConnection();
try (Statement stmt = connection.createStatement()) {
stmt.execute(
"CREATE TABLE account_groups ("
+ " group_uuid varchar(255) DEFAULT '' NOT NULL,"
+ " group_id INTEGER DEFAULT 0 NOT NULL,"
+ " name varchar(255) DEFAULT '' NOT NULL,"
+ " created_on TIMESTAMP,"
+ " description CLOB,"
+ " owner_group_uuid varchar(255) DEFAULT '' NOT NULL,"
+ " visible_to_all CHAR(1) DEFAULT 'N' NOT NULL"
+ ")");
stmt.execute(
"CREATE TABLE account_group_members ("
+ " group_id INTEGER DEFAULT 0 NOT NULL,"
+ " account_id INTEGER DEFAULT 0 NOT NULL"
+ ")");
stmt.execute(
"CREATE TABLE account_group_members_audit ("
+ " group_id INTEGER DEFAULT 0 NOT NULL,"
+ " account_id INTEGER DEFAULT 0 NOT NULL,"
+ " added_by INTEGER DEFAULT 0 NOT NULL,"
+ " added_on TIMESTAMP,"
+ " removed_by INTEGER,"
+ " removed_on TIMESTAMP"
+ ")");
}
createdOnRetrieval =
connection.prepareStatement("SELECT created_on FROM account_groups WHERE group_id = ?");
createdOnUpdate =

View File

@ -43,6 +43,7 @@ import com.google.gwtorm.jdbc.JdbcSchema;
import com.google.inject.Inject;
import java.io.IOException;
import java.sql.PreparedStatement;
import java.sql.Statement;
import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.lib.Config;
import org.eclipse.jgit.lib.ObjectId;
@ -77,8 +78,21 @@ public class Schema_166_to_167_WithGroupsInNoteDbTest {
private JdbcSchema jdbcSchema;
@Before
public void unwrapDb() {
public void initDb() throws Exception {
jdbcSchema = ReviewDbWrapper.unwrapJbdcSchema(db);
try (Statement stmt = jdbcSchema.getConnection().createStatement()) {
stmt.execute(
"CREATE TABLE account_groups ("
+ " group_uuid varchar(255) DEFAULT '' NOT NULL,"
+ " group_id INTEGER DEFAULT 0 NOT NULL,"
+ " name varchar(255) DEFAULT '' NOT NULL,"
+ " created_on TIMESTAMP,"
+ " description CLOB,"
+ " owner_group_uuid varchar(255) DEFAULT '' NOT NULL,"
+ " visible_to_all CHAR(1) DEFAULT 'N' NOT NULL"
+ ")");
}
}
@Test

View File

@ -135,8 +135,53 @@ public class Schema_166_to_167_WithGroupsInReviewDbTest {
private JdbcSchema jdbcSchema;
@Before
public void unwrapDb() {
public void initDb() throws Exception {
jdbcSchema = ReviewDbWrapper.unwrapJbdcSchema(db);
try (Statement stmt = jdbcSchema.getConnection().createStatement()) {
stmt.execute(
"CREATE TABLE account_groups ("
+ " group_uuid varchar(255) DEFAULT '' NOT NULL,"
+ " group_id INTEGER DEFAULT 0 NOT NULL,"
+ " name varchar(255) DEFAULT '' NOT NULL,"
+ " created_on TIMESTAMP,"
+ " description CLOB,"
+ " owner_group_uuid varchar(255) DEFAULT '' NOT NULL,"
+ " visible_to_all CHAR(1) DEFAULT 'N' NOT NULL"
+ ")");
stmt.execute(
"CREATE TABLE account_group_members ("
+ " group_id INTEGER DEFAULT 0 NOT NULL,"
+ " account_id INTEGER DEFAULT 0 NOT NULL"
+ ")");
stmt.execute(
"CREATE TABLE account_group_members_audit ("
+ " group_id INTEGER DEFAULT 0 NOT NULL,"
+ " account_id INTEGER DEFAULT 0 NOT NULL,"
+ " added_by INTEGER DEFAULT 0 NOT NULL,"
+ " added_on TIMESTAMP,"
+ " removed_by INTEGER,"
+ " removed_on TIMESTAMP"
+ ")");
stmt.execute(
"CREATE TABLE account_group_by_id ("
+ " group_id INTEGER DEFAULT 0 NOT NULL,"
+ " include_uuid VARCHAR(255) DEFAULT '' NOT NULL"
+ ")");
stmt.execute(
"CREATE TABLE account_group_by_id_aud ("
+ " group_id INTEGER DEFAULT 0 NOT NULL,"
+ " include_uuid VARCHAR(255) DEFAULT '' NOT NULL,"
+ " added_by INTEGER DEFAULT 0 NOT NULL,"
+ " added_on TIMESTAMP,"
+ " removed_by INTEGER,"
+ " removed_on TIMESTAMP"
+ ")");
}
}
@Before

View File

@ -4,20 +4,6 @@
-- Indexes to support @Query
--
-- *********************************************************************
-- AccountGroupMemberAccess
-- @PrimaryKey covers: byAccount
CREATE INDEX account_group_members_byGroup
ON account_group_members (group_id);
-- *********************************************************************
-- AccountGroupByIdAccess
-- @PrimaryKey covers: byGroup
CREATE INDEX account_group_id_byInclude
ON account_group_by_id (include_uuid);
-- *********************************************************************
-- ApprovalCategoryAccess
-- too small to bother indexing

View File

@ -5,21 +5,6 @@ delimiter #
-- Indexes to support @Query
--
-- *********************************************************************
-- AccountGroupMemberAccess
-- @PrimaryKey covers: byAccount
CREATE INDEX account_group_members_byGroup
ON account_group_members (group_id)
#
-- *********************************************************************
-- AccountGroupIncludeByUuidAccess
-- @PrimaryKey covers: byGroup
CREATE INDEX acc_gr_incl_by_uuid_byInclude
ON account_group_by_id (include_uuid)
#
-- *********************************************************************
-- ApprovalCategoryAccess
-- too small to bother indexing

View File

@ -51,20 +51,6 @@ delimiter ;
-- Indexes to support @Query
--
-- *********************************************************************
-- AccountGroupMemberAccess
-- @PrimaryKey covers: byAccount
CREATE INDEX account_group_members_byGroup
ON account_group_members (group_id);
-- *********************************************************************
-- AccountGroupByIdAccess
-- @PrimaryKey covers: byGroup
CREATE INDEX account_group_id_byInclude
ON account_group_by_id (include_uuid);
-- *********************************************************************
-- ApprovalCategoryAccess
-- too small to bother indexing