@Test public void upgradingV1ToLatest_nonEmptyDB_isLossless() { int oldVersion = 1; int newVersion = SCHEMA_VERSION; SchemaManager schemaManager = new SchemaManager(ApplicationProvider.getApplicationContext(), DB_NAME, oldVersion); SQLiteEventStore store = new SQLiteEventStore(clock, new UptimeClock(), CONFIG, schemaManager); PersistedEvent event1 = simulatedPersistOnV1Database(schemaManager, CONTEXT1, EVENT1); schemaManager.onUpgrade(schemaManager.getWritableDatabase(), oldVersion, newVersion); assertThat(store.loadBatch(CONTEXT1)).containsExactly(event1); }
@Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { ensureConfigured(db); upgrade(db, oldVersion, newVersion); }
SchemaManager extends SQLiteOpenHelper { @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { ensureConfigured(db); upgrade(db, oldVersion, newVersion); } }
SchemaManager extends SQLiteOpenHelper { @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { ensureConfigured(db); upgrade(db, oldVersion, newVersion); } @Inject  SchemaManager(
      Context context,
      @Named("SQLITE_DB_NAME") String dbName,
      @Named("SCHEMA_VERSION") int schemaVersion); }
SchemaManager extends SQLiteOpenHelper { @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { ensureConfigured(db); upgrade(db, oldVersion, newVersion); } @Inject  SchemaManager(
      Context context,
      @Named("SQLITE_DB_NAME") String dbName,
      @Named("SCHEMA_VERSION") int schemaVersion); @Override void onConfigure(SQLiteDatabase db); @Override void onCreate(SQLiteDatabase db); @Override void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion); @Override void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion); @Override void onOpen(SQLiteDatabase db); }
SchemaManager extends SQLiteOpenHelper { @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { ensureConfigured(db); upgrade(db, oldVersion, newVersion); } @Inject  SchemaManager(
      Context context,
      @Named("SQLITE_DB_NAME") String dbName,
      @Named("SCHEMA_VERSION") int schemaVersion); @Override void onConfigure(SQLiteDatabase db); @Override void onCreate(SQLiteDatabase db); @Override void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion); @Override void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion); @Override void onOpen(SQLiteDatabase db);  }