Migrate external IDs to NoteDb (part 3)
This is the third part of migrating external IDs from ReviewDb to NoteDb. This change: * changes the code to always read external IDs from NoteDb (the user.readExternalIdsFromGit configuration parameter is removed) * bumps the database schema version * deletes the database table for external IDs Pushing to the refs/meta/external-ids branch is still prevented by a commit validator. Since all external IDs are now in NoteDb only we could allow pushing to refs/meta/external-ids. However we would still like to do validation of the branch content and reject invalid content (e.g. invalid Git config files, usage of non-existing account IDs etc.) and such a validator is not implemented yet (but can be implemented in a follow-up change). Change-Id: Id9e5574a1d8d82f4f48fbb0b6dadc0e27d138a28 Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
@@ -19,13 +19,11 @@ import static com.google.gerrit.server.schema.DataSourceProvider.Context.MULTI_U
|
||||
|
||||
import com.google.gerrit.lifecycle.LifecycleManager;
|
||||
import com.google.gerrit.pgm.util.SiteProgram;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.account.externalids.DisabledExternalIdCache;
|
||||
import com.google.gerrit.server.account.externalids.ExternalId;
|
||||
import com.google.gerrit.server.account.externalids.ExternalIds;
|
||||
import com.google.gerrit.server.account.externalids.ExternalIdsBatchUpdate;
|
||||
import com.google.gerrit.server.schema.SchemaVersionCheck;
|
||||
import com.google.gwtorm.server.SchemaFactory;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Injector;
|
||||
@@ -38,8 +36,6 @@ public class LocalUsernamesToLowerCase extends SiteProgram {
|
||||
private final LifecycleManager manager = new LifecycleManager();
|
||||
private final TextProgressMonitor monitor = new TextProgressMonitor();
|
||||
|
||||
@Inject private SchemaFactory<ReviewDb> database;
|
||||
|
||||
@Inject private ExternalIds externalIds;
|
||||
|
||||
@Inject private ExternalIdsBatchUpdate externalIdsBatchUpdate;
|
||||
@@ -63,19 +59,17 @@ public class LocalUsernamesToLowerCase extends SiteProgram {
|
||||
})
|
||||
.injectMembers(this);
|
||||
|
||||
try (ReviewDb db = database.open()) {
|
||||
Collection<ExternalId> todo = externalIds.all(db);
|
||||
monitor.beginTask("Converting local usernames", todo.size());
|
||||
Collection<ExternalId> todo = externalIds.all();
|
||||
monitor.beginTask("Converting local usernames", todo.size());
|
||||
|
||||
for (ExternalId extId : todo) {
|
||||
convertLocalUserToLowerCase(extId);
|
||||
monitor.update(1);
|
||||
}
|
||||
|
||||
externalIdsBatchUpdate.commit(db, "Convert local usernames to lower case");
|
||||
monitor.endTask();
|
||||
manager.stop();
|
||||
for (ExternalId extId : todo) {
|
||||
convertLocalUserToLowerCase(extId);
|
||||
monitor.update(1);
|
||||
}
|
||||
|
||||
externalIdsBatchUpdate.commit("Convert local usernames to lower case");
|
||||
monitor.endTask();
|
||||
manager.stop();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,10 +14,7 @@
|
||||
|
||||
package com.google.gerrit.pgm.init;
|
||||
|
||||
import static com.google.gerrit.server.account.externalids.ExternalId.toAccountExternalIds;
|
||||
|
||||
import com.google.gerrit.pgm.init.api.InitFlags;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.GerritPersonIdentProvider;
|
||||
import com.google.gerrit.server.account.externalids.ExternalId;
|
||||
import com.google.gerrit.server.account.externalids.ExternalIdReader;
|
||||
@@ -52,9 +49,8 @@ public class ExternalIdsOnInit {
|
||||
this.allUsers = allUsers.get();
|
||||
}
|
||||
|
||||
public synchronized void insert(ReviewDb db, String commitMessage, Collection<ExternalId> extIds)
|
||||
public synchronized void insert(String commitMessage, Collection<ExternalId> extIds)
|
||||
throws OrmException, IOException, ConfigInvalidException {
|
||||
db.accountExternalIds().insert(toAccountExternalIds(extIds));
|
||||
|
||||
File path = getPath();
|
||||
if (path != null) {
|
||||
|
||||
@@ -104,7 +104,7 @@ public class InitAdminUser implements InitStep {
|
||||
if (email != null) {
|
||||
extIds.add(ExternalId.createEmail(id, email));
|
||||
}
|
||||
externalIds.insert(db, "Add external IDs for initial admin user", extIds);
|
||||
externalIds.insert("Add external IDs for initial admin user", extIds);
|
||||
|
||||
Account a = new Account(id, TimeUtil.nowTs());
|
||||
a.setFullName(name);
|
||||
|
||||
Reference in New Issue
Block a user