From 5feaa2757a4841b73de7604fc10c7414f85781d0 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Thu, 1 May 2014 16:34:08 -0700 Subject: [PATCH] Keep old timestamps during data migration As part of the update to patch_set_approavals, the category names are changed. Doing so causes "ON UPDATE CURRENT_TIMESTAMP" in at least MySQL to replace all of the existing timestamps with the time of the migration. Since the purpose of CURRENT_TIMESTAMP here is to track when the approval vote happened, this is a loss of data. Amend the data migration to include granted=granted in the update list so that anyone running the migration will not lose their data. Change-Id: If80891018eae0fab75770a5aea5a382200e9112f --- .../main/java/com/google/gerrit/server/schema/Schema_77.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_77.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_77.java index 80639d6b33..facfb75312 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_77.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_77.java @@ -138,7 +138,8 @@ public class Schema_77 extends SchemaVersion { private void migratePatchSetApprovals(ReviewDb db, LegacyLabelTypes labelTypes) throws SQLException { PreparedStatement stmt = ((JdbcSchema) db).getConnection().prepareStatement( - "UPDATE patch_set_approvals SET category_id = ? WHERE category_id = ?"); + "UPDATE patch_set_approvals SET category_id = ?, granted=granted" + + " WHERE category_id = ?"); try { for (LegacyLabelType type : labelTypes.getLegacyLabelTypes()) { stmt.setString(1, type.getName());