Schema_159: Don't set closed changes as WIP/private
Although the data model allows it, it makes no sense to have a change that is both merged and WIP, and Gerrit's current behavior is to reject submitting a WIP change. It is cleanest to apply this logic even when migrating draft changes to private changes. This means that some previously-draft *patch sets* of merged/abandoned changes may become visible, even though the admin prefers the security of hiding draft *changes*. Bug: Issue 8346 Change-Id: I91cfce3a7db2e8759e9b5b9835baefdf0388e5dc
This commit is contained in:

committed by
David Ostrovsky

parent
aa8bea6d8d
commit
afcddf79c1
@@ -44,16 +44,23 @@ public class Schema_159 extends SchemaVersion {
|
||||
try (StatementExecutor e = newExecutor(db)) {
|
||||
String column =
|
||||
strategy == DraftWorkflowMigrationStrategy.PRIVATE ? "is_private" : "work_in_progress";
|
||||
// Mark changes private/wip if changes have status draft or
|
||||
// if they have any draft patch sets.
|
||||
// Mark changes private/WIP and NEW if either:
|
||||
// * they have status DRAFT
|
||||
// * they have status NEW and have any draft patch sets
|
||||
e.execute(
|
||||
String.format(
|
||||
"UPDATE changes SET %s = 'Y', created_on = created_on WHERE status = 'd' OR "
|
||||
+ "EXISTS (SELECT * FROM patch_sets WHERE "
|
||||
+ "patch_sets.change_id = changes.change_id AND patch_sets.draft = 'Y')",
|
||||
"UPDATE changes "
|
||||
+ "SET %s = 'Y', "
|
||||
+ " status = 'n', "
|
||||
+ " created_on = created_on "
|
||||
+ "WHERE status = 'd' "
|
||||
+ " OR (status = 'n' "
|
||||
+ " AND EXISTS "
|
||||
+ " (SELECT * "
|
||||
+ " FROM patch_sets "
|
||||
+ " WHERE patch_sets.change_id = changes.change_id "
|
||||
+ " AND patch_sets.draft = 'Y')) ",
|
||||
column));
|
||||
// Change change status from draft to new.
|
||||
e.execute("UPDATE changes SET status = 'n', created_on = created_on WHERE status = 'd'");
|
||||
}
|
||||
ui.message("done");
|
||||
}
|
||||
|
Reference in New Issue
Block a user