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:
		@@ -34,7 +34,8 @@ public class Schema_153 extends SchemaVersion {
 | 
				
			|||||||
      // whether change is currently WIP. No migration is needed in NoteDb,
 | 
					      // whether change is currently WIP. No migration is needed in NoteDb,
 | 
				
			||||||
      // where the value of review_started is always derived from the history
 | 
					      // where the value of review_started is always derived from the history
 | 
				
			||||||
      // of assignments to work_in_progress.
 | 
					      // 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'");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -49,12 +49,12 @@ public class Schema_159 extends SchemaVersion {
 | 
				
			|||||||
      // if they have any draft patch sets.
 | 
					      // if they have any draft patch sets.
 | 
				
			||||||
      e.execute(
 | 
					      e.execute(
 | 
				
			||||||
          String.format(
 | 
					          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 "
 | 
					                  + "EXISTS (SELECT * FROM patch_sets WHERE "
 | 
				
			||||||
                  + "patch_sets.change_id = changes.change_id AND patch_sets.draft = 'Y')",
 | 
					                  + "patch_sets.change_id = changes.change_id AND patch_sets.draft = 'Y')",
 | 
				
			||||||
              column));
 | 
					              column));
 | 
				
			||||||
      // Change change status from draft to new.
 | 
					      // 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");
 | 
					    ui.message("done");
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user