Skip to content

Commit b1c2aa6

Browse files
committed
Feedback.
1 parent 14f26b8 commit b1c2aa6

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

firebase-firestore/CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ Android changes are not released automatically. Ensure that changes are released
22
by opting into a release at
33
[go/firebase-android-release](http:go/firebase-android-release) (Googlers only).
44

5-
# Unreleased
5+
# 24.1.2
66
- [fixed] Fixed an issue where patching multiple fields shadows each other (#3528).
7+
- [feature] Added customization support for `FirebaseFirestore.runTransaction`.
78

89
# 24.1.1
910
- [fixed] Fixed an issue in the experimental index engine that might have
@@ -17,7 +18,6 @@ by opting into a release at
1718
JSON index definition exported by the Firestore CLI. Queries against the
1819
cache are executed using an index once the asynchronous operation to generate
1920
the index entries completes.
20-
- [fixed] Fixed missing document fields issue with offline overlays (#3528)
2121

2222
# 24.0.2
2323
- [fixed] Fixed an issue of long grpc reconnection period, when App moves to

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ private void buildOverlays() {
4646
db.runTransaction(
4747
"build overlays",
4848
() -> {
49+
if (!hasPendingOverlayMigration()) {
50+
return;
51+
}
52+
4953
Set<String> userIds = getAllUserIds();
5054
RemoteDocumentCache remoteDocumentCache = db.getRemoteDocumentCache();
5155
for (String uid : userIds) {

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import static java.util.Arrays.asList;
2626
import static org.junit.Assert.assertEquals;
2727
import static org.junit.Assert.assertFalse;
28+
import static org.junit.Assert.assertNull;
2829

2930
import com.google.firebase.firestore.FieldValue;
3031
import com.google.firebase.firestore.auth.User;
@@ -110,6 +111,46 @@ public void testCreateOverlayFromSet() {
110111
assertFalse(migrationManager.hasPendingOverlayMigration());
111112
}
112113

114+
@Test
115+
public void testSkipsIfAlreadyMigrated() {
116+
writeRemoteDocument(doc("foo/bar", 2, map("it", "original")));
117+
writeMutation(setMutation("foo/bar", map("foo", "bar")));
118+
119+
// Switch to new persistence and run migrations
120+
this.persistence.shutdown();
121+
persistence = PersistenceTestHelpers.createSQLitePersistence("test-data-migration");
122+
IndexBackfiller indexBackfiller = new IndexBackfiller(persistence, new AsyncQueue());
123+
localStore =
124+
new LocalStore(persistence, indexBackfiller, new QueryEngine(), User.UNAUTHENTICATED);
125+
localStore.start();
126+
127+
assertEquals(
128+
setMutation("foo/bar", map("foo", "bar")),
129+
persistence
130+
.getDocumentOverlayCache(User.UNAUTHENTICATED)
131+
.getOverlay(key("foo/bar"))
132+
.getMutation());
133+
134+
// Delete the overlay to verify migration is skipped the second time.
135+
persistence.getDocumentOverlayCache(User.UNAUTHENTICATED).removeOverlaysForBatchId(1);
136+
137+
// Switch to new persistence and run migrations which should be a no-op.
138+
this.persistence.shutdown();
139+
persistence = PersistenceTestHelpers.createSQLitePersistence("test-data-migration");
140+
indexBackfiller = new IndexBackfiller(persistence, new AsyncQueue());
141+
localStore =
142+
new LocalStore(persistence, indexBackfiller, new QueryEngine(), User.UNAUTHENTICATED);
143+
localStore.start();
144+
145+
SQLiteOverlayMigrationManager migrationManager =
146+
(SQLiteOverlayMigrationManager) persistence.getOverlayMigrationManager();
147+
assertFalse(migrationManager.hasPendingOverlayMigration());
148+
149+
// We deleted the overlay earlier and the migration is not run again, so we get a null.
150+
assertNull(
151+
persistence.getDocumentOverlayCache(User.UNAUTHENTICATED).getOverlay(key("foo/bar")));
152+
}
153+
113154
@Test
114155
public void testCreateOverlayFromDelete() {
115156
writeRemoteDocument(doc("foo/bar", 2, map("it", "original")));

0 commit comments

Comments
 (0)