Remove ApprovalCategory and ApprovalCategoryValue

These can be completely specified in the project config hierarchy and
the database tables are no longer required. Also remove the size limit
on patch_set_approvals.category_id, so new PatchSetApprovals can refer
to label names rather than IDs.

Migrate existing labels into project.config in All-Projects. When
migrating, also convert existing PatchSetApprovals to refer to label
names rather than IDs.

Label IDs are still written to PatchSetApprovals and still supported
in project.config. As of this change, update all code to match
PatchSetApproval's categoryId on either label ID or name.  This allows
for the possibility of database migration without downtime (e.g. for
gerrit-review.googlesource.com). The default schema migration code,
however, does not include label IDs in project.config, since this
schema migration is only intended to run offline.

Change-Id: I5df6f0c5665d0ae4ee6b5e2944f5954fa2f96b5c
This commit is contained in:
Dave Borowitz
2013-02-18 14:53:57 -08:00
parent 6445559a45
commit 8e5de82e56
42 changed files with 566 additions and 795 deletions

View File

@@ -59,7 +59,7 @@ class PRED__load_commit_labels_1 extends Predicate.P1 {
continue;
}
LabelType t = types.byId(a.getCategoryId().get());
LabelType t = types.byLabel(a.getLabelId());
if (t == null) {
continue;
}

View File

@@ -35,11 +35,10 @@ import java.util.List;
/**
* Obtain a list of label types from the server configuration.
* <p>
* Unifies to a Prolog list of: {@code label_type(Label, Id, Fun, Min, Max)}
* Unifies to a Prolog list of: {@code label_type(Label, Fun, Min, Max)}
* where:
* <ul>
* <li>{@code Label} - the newer style label name</li>
* <li>{@code Id} - the legacy LabelCategory.Id from the database</li>
* <li>{@code Fun} - legacy function name</li>
* <li>{@code Min, Max} - the smallest and largest configured values.</li>
* </ul>
@@ -74,12 +73,11 @@ class PRED_get_legacy_label_types_1 extends Predicate.P1 {
}
static final SymbolTerm symLabelType = SymbolTerm.intern(
"label_type", 5);
"label_type", 4);
static Term export(LabelType type) {
return new StructureTerm(symLabelType,
SymbolTerm.intern(type.getName()),
SymbolTerm.intern(type.getId()),
SymbolTerm.intern(type.getFunctionName()),
new IntegerTerm(type.getMin().getValue()),
new IntegerTerm(type.getMax().getValue()));