Keep old timestamps during data migration

The changes table is migrated from draft to private/wip.
This causes "ON UPDATE CURRENT_TIMESTAMP" in at least MySQL
to replace all of the existing timestamps with the time of
the migration.

Amend the data migration to include created_on=created_on in
the update list so that anyone running the migration will not
lose their data.

This is similar to 5feaa2757a.

Bug: Issue 7397
Change-Id: I57b7f8cf72634f066bc20b9ea8fed496ecc9baa5
This commit is contained in:
Orgad Shaneh
2017-10-28 19:36:20 +03:00
parent fb013b405a
commit c2a41e1fad
2 changed files with 4 additions and 3 deletions

View File

@@ -34,7 +34,8 @@ public class Schema_153 extends SchemaVersion {
// whether change is currently WIP. No migration is needed in NoteDb,
// where the value of review_started is always derived from the history
// of assignments to work_in_progress.
e.execute("UPDATE changes SET review_started = 'Y' WHERE work_in_progress = 'N'");
e.execute(
"UPDATE changes SET review_started = 'Y', created_on = created_on WHERE work_in_progress = 'N'");
}
}
}

View File

@@ -49,12 +49,12 @@ public class Schema_159 extends SchemaVersion {
// if they have any draft patch sets.
e.execute(
String.format(
"UPDATE changes SET %s = 'Y' WHERE status = 'd' OR "
"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')",
column));
// Change change status from draft to new.
e.execute("UPDATE changes SET status = 'n' WHERE status = 'd'");
e.execute("UPDATE changes SET status = 'n', created_on = created_on WHERE status = 'd'");
}
ui.message("done");
}