@Test public void canCreateCollectionParentsIndex() { List<String> writePaths = asList("cg1/x", "cg1/y", "cg1/x/cg1/x", "cg2/x", "cg1/x/cg2/x"); List<String> remoteDocPaths = asList("cg1/z", "cg1/y/cg1/x", "cg2/x/cg3/x", "blah/x/blah/x/cg3/x"); Map<String, List<String>> expectedParents = map( "cg1", asList("", "cg1/x", "cg1/y"), "cg2", asList("", "cg1/x"), "cg3", asList("blah/x/blah/x", "cg2/x")); schema.runMigrations(0, 7); int batchId = 1; for (String writePath : writePaths) { addMutationBatch(db, batchId++, "user", writePath); } for (String remoteDocPath : remoteDocPaths) { db.execSQL( "INSERT INTO remote_documents (path) VALUES (?)", new String[] {encode(path(remoteDocPath))}); } schema.runMigrations(7, 8); Map<String, List<String>> actualParents = new HashMap<>(); new SQLitePersistence.Query(db, "SELECT collection_id, parent FROM collection_parents") .forEach( row -> { String collectionId = row.getString(0); String parent = decodeResourcePath(row.getString(1)).toString(); List<String> parents = actualParents.get(collectionId); if (parents == null) { parents = new ArrayList<>(); actualParents.put(collectionId, parents); } parents.add(parent); }); for (List<String> parents : actualParents.values()) { parents.sort(String::compareTo); } assertEquals(expectedParents, actualParents); }
void runMigrations() { runMigrations(0, VERSION); }
SQLiteSchema { void runMigrations() { runMigrations(0, VERSION); } }
SQLiteSchema { void runMigrations() { runMigrations(0, VERSION); } SQLiteSchema(SQLiteDatabase db, LocalSerializer serializer); }
SQLiteSchema { void runMigrations() { runMigrations(0, VERSION); } SQLiteSchema(SQLiteDatabase db, LocalSerializer serializer);  }
SQLiteSchema { void runMigrations() { runMigrations(0, VERSION); } SQLiteSchema(SQLiteDatabase db, LocalSerializer serializer);   }