Skip to content

Commit c4963a3

Browse files
Fill read_time
1 parent acc43e9 commit c4963a3

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

firebase-firestore/src/main/java/com/google/firebase/firestore/local/SQLiteSchema.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class SQLiteSchema {
4949
* The version of the schema. Increase this by one for each migration added to runMigrations
5050
* below.
5151
*/
52-
static final int VERSION = 13;
52+
static final int VERSION = 14;
5353

5454
static final int OVERLAY_SUPPORT_VERSION = VERSION + 1;
5555

@@ -178,6 +178,10 @@ void runSchemaUpgrades(int fromVersion, int toVersion) {
178178
ensurePathLength();
179179
}
180180

181+
if (fromVersion < 14 && toVersion >= 14) {
182+
ensureReadTime();
183+
}
184+
181185
/*
182186
* Adding a new migration? READ THIS FIRST!
183187
*
@@ -658,6 +662,12 @@ private void ensurePathLength() {
658662
} while (resultsRemaining[0]);
659663
}
660664

665+
/** Initialize the remote_document's read_time column with 0 values if they are not set. */
666+
private void ensureReadTime() {
667+
db.execSQL(
668+
"UPDATE remote_documents SET read_time_seconds = 0, read_time_nanos = 0 WHERE read_time_seconds IS NULL");
669+
}
670+
661671
private void createBundleCache() {
662672
ifTablesDontExist(
663673
new String[] {"bundles", "named_queries"},

firebase-firestore/src/test/java/com/google/firebase/firestore/local/SQLiteSchemaTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ public void existingDocumentsRemainReadableAfterIndexFreeMigration() {
426426
new Object[] {encode(path("coll/existing")), createDummyDocument("coll/existing")});
427427

428428
// Run the index-free migration.
429-
schema.runSchemaUpgrades(8, 10);
429+
schema.runSchemaUpgrades(8, 14);
430430
db.execSQL(
431431
"INSERT INTO remote_documents (path, read_time_seconds, read_time_nanos, contents) VALUES (?, ?, ?, ?)",
432432
new Object[] {encode(path("coll/old")), 0, 1000, createDummyDocument("coll/old")});

0 commit comments

Comments
 (0)