@@ -702,6 +702,27 @@ public void createsOverlaysAndMigrationTable() {
702702 assertEquals (Persistence .DATA_MIGRATION_BUILD_OVERLAYS , migrationName );
703703 }
704704
705+ @ Test
706+ public void existingDocumentsMatchAfterRemoteDocumentsDocumentTypeColumnAdded () {
707+ schema .runSchemaUpgrades (0 , 1 );
708+ for (int i = 0 ; i < 3 ; i ++) {
709+ db .execSQL (
710+ "INSERT INTO remote_documents (path, contents) VALUES (?, ?)" ,
711+ new Object [] {encode (path ("coll/doc" + i )), createDummyDocument ("coll/doc" + i )});
712+ }
713+
714+ // The migration of interest is 18, but go to the latest migration to ensure compatibility with
715+ // the SQLiteRemoteDocumentCache implementation.
716+ schema .runSchemaUpgrades (2 , VERSION );
717+
718+ SQLiteRemoteDocumentCache remoteDocumentCache = createRemoteDocumentCache ();
719+
720+ Map <DocumentKey , MutableDocument > results =
721+ remoteDocumentCache .getDocumentsMatchingQuery (
722+ query ("coll" ), IndexOffset .NONE , new HashSet <DocumentKey >());
723+ assertResultsContain (results , "coll/doc0" , "coll/doc1" , "coll/doc2" );
724+ }
725+
705726 private SQLiteRemoteDocumentCache createRemoteDocumentCache () {
706727 SQLitePersistence persistence =
707728 new SQLitePersistence (serializer , LruGarbageCollector .Params .Default (), opener );
0 commit comments