@Test public void rewritesCanonicalIds() { schema.runMigrations(0, 10); Query filteredQuery = query("colletion").filter(filter("foo", "==", "bar")); TargetData initialTargetData = new TargetData( filteredQuery.toTarget(), 2, 1, QueryPurpose.LISTEN); db.execSQL( "INSERT INTO targets (target_id, canonical_id, target_proto) VALUES (?,?, ?)", new Object[] { 2, "invalid_canonical_id", serializer.encodeTargetData(initialTargetData).toByteArray() }); schema.runMigrations(10, 11); new SQLitePersistence.Query(db, "SELECT canonical_id, target_proto, canonical_id FROM targets") .forEach( cursor -> { String actualCanonicalId = cursor.getString(0); byte[] targetProtoBytes = cursor.getBlob(1); try { Target targetProto = Target.parseFrom(targetProtoBytes); TargetData targetData = serializer.decodeTargetData(targetProto); String expectedCanonicalId = targetData.getTarget().getCanonicalId(); assertEquals(expectedCanonicalId, actualCanonicalId); } catch (InvalidProtocolBufferException e) { fail("Failed to decode Target data"); } }); }
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);   }