@@ -115,7 +115,7 @@ void runMigrations(int fromVersion, int toVersion) {
115
115
}
116
116
117
117
if (fromVersion < 8 && toVersion >= 8 ) {
118
- createV8CollectionParentIndex ();
118
+ createV8CollectionParentsIndex ();
119
119
}
120
120
121
121
/*
@@ -372,10 +372,14 @@ private void ensureSequenceNumbers() {
372
372
});
373
373
}
374
374
375
- private void createV8CollectionParentIndex () {
375
+ private void createV8CollectionParentsIndex () {
376
376
ifTablesDontExist (
377
377
new String [] {"collection_parents" },
378
378
() -> {
379
+ // A table storing associations between a Collection ID (e.g. 'messages') to a parent path
380
+ // (e.g. '/chats/123') that contains it as a (sub)collection. This is used to efficiently
381
+ // find all collections to query when performing a Collection Group query. Note that the
382
+ // parent path will be an empty path in the case of root-level collections.
379
383
db .execSQL (
380
384
"CREATE TABLE collection_parents ("
381
385
+ "collection_id TEXT, "
@@ -390,10 +394,10 @@ private void createV8CollectionParentIndex() {
390
394
db .compileStatement (
391
395
"INSERT OR REPLACE INTO collection_parents (collection_id, parent) VALUES (?, ?)" );
392
396
Consumer <ResourcePath > addEntry =
393
- path -> {
394
- if (cache .add (path )) {
395
- String collectionId = path .getLastSegment ();
396
- ResourcePath parentPath = path .popLast ();
397
+ collectionPath -> {
398
+ if (cache .add (collectionPath )) {
399
+ String collectionId = collectionPath .getLastSegment ();
400
+ ResourcePath parentPath = collectionPath .popLast ();
397
401
addIndexEntry .clearBindings ();
398
402
addIndexEntry .bindString (1 , collectionId );
399
403
addIndexEntry .bindString (2 , EncodedPath .encode (parentPath ));
0 commit comments