Fix issues during schema_120 migration
While schema migration to 120 was performed the following issues were found: - submodule branch name is taken from column that doesn't exist - as a result migration stops (at 119) and the following error is being thrown: "The column index is out of range" - submodule project name is taken from branch name - author and committer for meta data update are missing Change-Id: Ifaffb7e29fb58abe8450c9ea29998e7b59580d15 Signed-off-by: Jacek Centkowski <geminica.programs@gmail.com>
This commit is contained in:
@@ -18,6 +18,7 @@ import com.google.gerrit.common.data.SubscribeSection;
|
|||||||
import com.google.gerrit.reviewdb.client.Branch;
|
import com.google.gerrit.reviewdb.client.Branch;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||||
|
import com.google.gerrit.server.GerritPersonIdent;
|
||||||
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
|
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
|
||||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||||
import com.google.gerrit.server.git.MetaDataUpdate;
|
import com.google.gerrit.server.git.MetaDataUpdate;
|
||||||
@@ -30,6 +31,7 @@ import com.google.inject.Provider;
|
|||||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||||
import org.eclipse.jgit.lib.BatchRefUpdate;
|
import org.eclipse.jgit.lib.BatchRefUpdate;
|
||||||
import org.eclipse.jgit.lib.NullProgressMonitor;
|
import org.eclipse.jgit.lib.NullProgressMonitor;
|
||||||
|
import org.eclipse.jgit.lib.PersonIdent;
|
||||||
import org.eclipse.jgit.lib.Repository;
|
import org.eclipse.jgit.lib.Repository;
|
||||||
import org.eclipse.jgit.revwalk.RevWalk;
|
import org.eclipse.jgit.revwalk.RevWalk;
|
||||||
import org.eclipse.jgit.transport.RefSpec;
|
import org.eclipse.jgit.transport.RefSpec;
|
||||||
@@ -42,12 +44,15 @@ import java.sql.Statement;
|
|||||||
public class Schema_120 extends SchemaVersion {
|
public class Schema_120 extends SchemaVersion {
|
||||||
|
|
||||||
private final GitRepositoryManager mgr;
|
private final GitRepositoryManager mgr;
|
||||||
|
private final PersonIdent serverUser;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
Schema_120(Provider<Schema_119> prior,
|
Schema_120(Provider<Schema_119> prior,
|
||||||
GitRepositoryManager mgr) {
|
GitRepositoryManager mgr,
|
||||||
|
@GerritPersonIdent PersonIdent serverUser) {
|
||||||
super(prior);
|
super(prior);
|
||||||
this.mgr = mgr;
|
this.mgr = mgr;
|
||||||
|
this.serverUser = serverUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void allowSubmoduleSubscription(Branch.NameKey subbranch,
|
private void allowSubmoduleSubscription(Branch.NameKey subbranch,
|
||||||
@@ -57,6 +62,8 @@ public class Schema_120 extends SchemaVersion {
|
|||||||
BatchRefUpdate bru = git.getRefDatabase().newBatchUpdate();
|
BatchRefUpdate bru = git.getRefDatabase().newBatchUpdate();
|
||||||
try (MetaDataUpdate md = new MetaDataUpdate(GitReferenceUpdated.DISABLED,
|
try (MetaDataUpdate md = new MetaDataUpdate(GitReferenceUpdated.DISABLED,
|
||||||
subbranch.getParentKey(), git, bru)) {
|
subbranch.getParentKey(), git, bru)) {
|
||||||
|
md.getCommitBuilder().setAuthor(serverUser);
|
||||||
|
md.getCommitBuilder().setCommitter(serverUser);
|
||||||
md.setMessage("Added superproject subscription during upgrade");
|
md.setMessage("Added superproject subscription during upgrade");
|
||||||
ProjectConfig pc = ProjectConfig.read(md);
|
ProjectConfig pc = ProjectConfig.read(md);
|
||||||
|
|
||||||
@@ -103,9 +110,9 @@ public class Schema_120 extends SchemaVersion {
|
|||||||
Branch.NameKey superbranch = new Branch.NameKey(superproject,
|
Branch.NameKey superbranch = new Branch.NameKey(superproject,
|
||||||
rs.getString(2));
|
rs.getString(2));
|
||||||
|
|
||||||
Project.NameKey submodule = new Project.NameKey(rs.getString(4));
|
Project.NameKey submodule = new Project.NameKey(rs.getString(3));
|
||||||
Branch.NameKey subbranch = new Branch.NameKey(submodule,
|
Branch.NameKey subbranch = new Branch.NameKey(submodule,
|
||||||
rs.getString(5));
|
rs.getString(4));
|
||||||
|
|
||||||
allowSubmoduleSubscription(subbranch, superbranch);
|
allowSubmoduleSubscription(subbranch, superbranch);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user