Migrate project watches to git (part 2)
This is the second part of migrating project watches from database to git. This change: * bumps the database schema version * migrates the project watches from database to git (for single instance Gerrit servers) * deletes the database table * deletes the user.readProjectWatchesFromGit config option Change-Id: I9dc99f5483fdd72cf6e237236ed0b23f14b60249 Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
@@ -42,9 +42,6 @@ import java.sql.Timestamp;
|
||||
* managed {@link AccountGroup}. Multiple records can exist when the user is a
|
||||
* member of more than one group.</li>
|
||||
*
|
||||
* <li>{@link AccountProjectWatch}: user's email settings related to a specific
|
||||
* {@link Project}. One record per project the user is interested in tracking.</li>
|
||||
*
|
||||
* <li>{@link AccountSshKey}: user's public SSH keys, for authentication through
|
||||
* the internal SSH daemon. One record per SSH key uploaded by the user, keys
|
||||
* are checked in random order until a match is found.</li>
|
||||
|
||||
@@ -1,202 +0,0 @@
|
||||
// Copyright (C) 2008 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.reviewdb.client;
|
||||
|
||||
import com.google.gwtorm.client.Column;
|
||||
import com.google.gwtorm.client.CompoundKey;
|
||||
import com.google.gwtorm.client.StringKey;
|
||||
|
||||
/** An {@link Account} interested in a {@link Project}. */
|
||||
public final class AccountProjectWatch {
|
||||
|
||||
public enum NotifyType {
|
||||
// sort by name, except 'ALL' which should stay last
|
||||
ABANDONED_CHANGES,
|
||||
ALL_COMMENTS,
|
||||
NEW_CHANGES,
|
||||
NEW_PATCHSETS,
|
||||
SUBMITTED_CHANGES,
|
||||
|
||||
ALL
|
||||
}
|
||||
|
||||
public static final String FILTER_ALL = "*";
|
||||
|
||||
public static class Key extends CompoundKey<Account.Id> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Column(id = 1)
|
||||
protected Account.Id accountId;
|
||||
|
||||
@Column(id = 2)
|
||||
protected Project.NameKey projectName;
|
||||
|
||||
@Column(id = 3)
|
||||
protected Filter filter;
|
||||
|
||||
protected Key() {
|
||||
accountId = new Account.Id();
|
||||
projectName = new Project.NameKey();
|
||||
filter = new Filter();
|
||||
}
|
||||
|
||||
public Key(Account.Id a, Project.NameKey g, String f) {
|
||||
accountId = a;
|
||||
projectName = g;
|
||||
filter = new Filter(f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Account.Id getParentKey() {
|
||||
return accountId;
|
||||
}
|
||||
|
||||
public Project.NameKey getProjectName() {
|
||||
return projectName;
|
||||
}
|
||||
|
||||
public Filter getFilter() {
|
||||
return filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.google.gwtorm.client.Key<?>[] members() {
|
||||
return new com.google.gwtorm.client.Key<?>[] {projectName, filter};
|
||||
}
|
||||
}
|
||||
|
||||
public static class Filter extends StringKey<com.google.gwtorm.client.Key<?>> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Column(id = 1)
|
||||
protected String filter;
|
||||
|
||||
protected Filter() {
|
||||
}
|
||||
|
||||
public Filter(String f) {
|
||||
filter = f != null && !f.isEmpty() ? f : FILTER_ALL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get() {
|
||||
return filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void set(String newValue) {
|
||||
filter = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Column(id = 1, name = Column.NONE)
|
||||
protected Key key;
|
||||
|
||||
/** Automatically send email notifications of new changes? */
|
||||
@Column(id = 2)
|
||||
protected boolean notifyNewChanges;
|
||||
|
||||
/** Automatically receive comments published to this project */
|
||||
@Column(id = 3)
|
||||
protected boolean notifyAllComments;
|
||||
|
||||
/** Automatically receive changes submitted to this project */
|
||||
@Column(id = 4)
|
||||
protected boolean notifySubmittedChanges;
|
||||
|
||||
@Column(id = 5)
|
||||
protected boolean notifyNewPatchSets;
|
||||
|
||||
@Column(id = 6)
|
||||
protected boolean notifyAbandonedChanges;
|
||||
|
||||
protected AccountProjectWatch() {
|
||||
}
|
||||
|
||||
public AccountProjectWatch(final AccountProjectWatch.Key k) {
|
||||
key = k;
|
||||
}
|
||||
|
||||
public AccountProjectWatch.Key getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public Account.Id getAccountId() {
|
||||
return key.accountId;
|
||||
}
|
||||
|
||||
public Project.NameKey getProjectNameKey() {
|
||||
return key.projectName;
|
||||
}
|
||||
|
||||
public String getFilter() {
|
||||
return FILTER_ALL.equals(key.filter.get()) ? null : key.filter.get();
|
||||
}
|
||||
|
||||
public boolean isNotify(final NotifyType type) {
|
||||
switch (type) {
|
||||
case NEW_CHANGES:
|
||||
return notifyNewChanges;
|
||||
|
||||
case NEW_PATCHSETS:
|
||||
return notifyNewPatchSets;
|
||||
|
||||
case ALL_COMMENTS:
|
||||
return notifyAllComments;
|
||||
|
||||
case SUBMITTED_CHANGES:
|
||||
return notifySubmittedChanges;
|
||||
|
||||
case ABANDONED_CHANGES:
|
||||
return notifyAbandonedChanges;
|
||||
|
||||
case ALL:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setNotify(final NotifyType type, final boolean v) {
|
||||
switch (type) {
|
||||
case NEW_CHANGES:
|
||||
notifyNewChanges = v;
|
||||
break;
|
||||
|
||||
case NEW_PATCHSETS:
|
||||
notifyNewPatchSets = v;
|
||||
break;
|
||||
|
||||
case ALL_COMMENTS:
|
||||
notifyAllComments = v;
|
||||
break;
|
||||
|
||||
case SUBMITTED_CHANGES:
|
||||
notifySubmittedChanges = v;
|
||||
break;
|
||||
|
||||
case ABANDONED_CHANGES:
|
||||
notifyAbandonedChanges = v;
|
||||
break;
|
||||
|
||||
case ALL:
|
||||
notifyNewChanges = v;
|
||||
notifyNewPatchSets = v;
|
||||
notifyAllComments = v;
|
||||
notifySubmittedChanges = v;
|
||||
notifyAbandonedChanges = v;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
// Copyright (C) 2008 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.reviewdb.server;
|
||||
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.AccountProjectWatch;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gwtorm.server.Access;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.gwtorm.server.PrimaryKey;
|
||||
import com.google.gwtorm.server.Query;
|
||||
import com.google.gwtorm.server.ResultSet;
|
||||
|
||||
public interface AccountProjectWatchAccess extends
|
||||
Access<AccountProjectWatch, AccountProjectWatch.Key> {
|
||||
@Override
|
||||
@PrimaryKey("key")
|
||||
AccountProjectWatch get(AccountProjectWatch.Key key) throws OrmException;
|
||||
|
||||
@Query("WHERE key.accountId = ?")
|
||||
ResultSet<AccountProjectWatch> byAccount(Account.Id id) throws OrmException;
|
||||
|
||||
@Query("WHERE key.projectName = ?")
|
||||
ResultSet<AccountProjectWatch> byProject(Project.NameKey name) throws OrmException;
|
||||
}
|
||||
@@ -71,8 +71,7 @@ public interface ReviewDb extends Schema {
|
||||
|
||||
// Deleted @Relation(id = 18)
|
||||
|
||||
@Relation(id = 19)
|
||||
AccountProjectWatchAccess accountProjectWatches();
|
||||
// Deleted @Relation(id = 19)
|
||||
|
||||
// Deleted @Relation(id = 20)
|
||||
|
||||
|
||||
@@ -108,11 +108,6 @@ public class ReviewDbWrapper implements ReviewDb {
|
||||
return delegate.accountGroupMembersAudit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccountProjectWatchAccess accountProjectWatches() {
|
||||
return delegate.accountProjectWatches();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChangeAccess changes() {
|
||||
return delegate.changes();
|
||||
|
||||
@@ -35,13 +35,6 @@ ON account_group_members (group_id);
|
||||
CREATE INDEX account_group_id_byInclude
|
||||
ON account_group_by_id (include_uuid);
|
||||
|
||||
-- *********************************************************************
|
||||
-- AccountProjectWatchAccess
|
||||
-- @PrimaryKey covers: byAccount
|
||||
-- covers: byProject
|
||||
CREATE INDEX account_project_watches_byP
|
||||
ON account_project_watches (project_name);
|
||||
|
||||
|
||||
-- *********************************************************************
|
||||
-- ApprovalCategoryAccess
|
||||
|
||||
@@ -41,14 +41,6 @@ ON account_group_by_id (include_uuid)
|
||||
#
|
||||
|
||||
|
||||
-- *********************************************************************
|
||||
-- AccountProjectWatchAccess
|
||||
-- @PrimaryKey covers: byAccount
|
||||
-- covers: byProject
|
||||
CREATE INDEX acc_project_watches_byProject
|
||||
ON account_project_watches (project_name)
|
||||
#
|
||||
|
||||
-- *********************************************************************
|
||||
-- ApprovalCategoryAccess
|
||||
-- too small to bother indexing
|
||||
|
||||
@@ -82,13 +82,6 @@ ON account_group_members (group_id);
|
||||
CREATE INDEX account_group_id_byInclude
|
||||
ON account_group_by_id (include_uuid);
|
||||
|
||||
-- *********************************************************************
|
||||
-- AccountProjectWatchAccess
|
||||
-- @PrimaryKey covers: byAccount
|
||||
-- covers: byProject
|
||||
CREATE INDEX account_project_watches_byP
|
||||
ON account_project_watches (project_name);
|
||||
|
||||
|
||||
-- *********************************************************************
|
||||
-- ApprovalCategoryAccess
|
||||
|
||||
Reference in New Issue
Block a user