@Test
public void onUpgradeFromV12() {

    final int oldVersion = 12;
    final int newVersion = DatabaseHelper.DATABASE_VERSION;
    final TableDefaultsCustomizer customizer = mock(TableDefaultsCustomizer.class);
    mDistanceTable.onUpgrade(mSQLiteDatabase, oldVersion, newVersion, customizer);
    verify(mSQLiteDatabase, atLeastOnce()).execSQL(mSqlCaptor.capture());
    verifyZeroInteractions(customizer);
    assertTrue(mSqlCaptor.getAllValues().get(0).contains("distance")); // Table name
    assertTrue(mSqlCaptor.getAllValues().get(0).contains("id"));
    assertTrue(mSqlCaptor.getAllValues().get(0).contains("parent"));
    assertTrue(mSqlCaptor.getAllValues().get(0).contains("distance"));
    assertTrue(mSqlCaptor.getAllValues().get(0).contains("location"));
    assertTrue(mSqlCaptor.getAllValues().get(0).contains("date"));
    assertTrue(mSqlCaptor.getAllValues().get(0).contains("timezone"));
    assertTrue(mSqlCaptor.getAllValues().get(0).contains("comment"));
    assertTrue(mSqlCaptor.getAllValues().get(0).contains("rate"));
    assertTrue(mSqlCaptor.getAllValues().get(0).contains("rate_currency"));
    // Create
    assertEquals(mSqlCaptor.getAllValues().get(0), "CREATE TABLE distance (id INTEGER PRIMARY KEY AUTOINCREMENT,parent TEXT REFERENCES name ON DELETE CASCADE,distance DECIMAL(10, 2) DEFAULT 0.00,location TEXT,date DATE,timezone TEXT,comment TEXT,rate_currency TEXT NOT NULL, rate DECIMAL(10, 2) DEFAULT 0.00);");
    // Migrate Trip Distances to Distance WHERE the Trip Currency != NULL
    assertEquals(mSqlCaptor.getAllValues().get(1), "INSERT INTO distance(parent, distance, location, date, timezone, comment, rate_currency) SELECT name, miles_new , \"\" as location, from_date, from_timezone , \"\" as comment, trips_default_currency FROM trips WHERE trips_default_currency IS NOT NULL AND miles_new > 0;");
    // Migrate Trip Distances to Distance WHERE the Trip Currency == NULL
    assertEquals(mSqlCaptor.getAllValues().get(2), "INSERT INTO distance(parent, distance, location, date, timezone, comment, rate_currency) SELECT name, miles_new , \"\" as location, from_date, from_timezone , \"\" as comment, \"USD\" as rate_currency FROM trips WHERE trips_default_currency IS NULL AND miles_new > 0;");
    assertEquals(mSqlCaptor.getAllValues().get(3), "ALTER TABLE " + mDistanceTable.getTableName() + " ADD drive_sync_id TEXT");
    assertEquals(mSqlCaptor.getAllValues().get(4), "ALTER TABLE " + mDistanceTable.getTableName() + " ADD drive_is_synced BOOLEAN DEFAULT 0");
    assertEquals(mSqlCaptor.getAllValues().get(5), "ALTER TABLE " + mDistanceTable.getTableName() + " ADD drive_marked_for_deletion BOOLEAN DEFAULT 0");
    assertEquals(mSqlCaptor.getAllValues().get(6), "ALTER TABLE " + mDistanceTable.getTableName() + " ADD last_local_modification_time DATE");
}