diff --git a/app/src/main/kotlin/io/github/landwarderer/futon/alternatives/domain/MigrateUseCase.kt b/app/src/main/kotlin/io/github/landwarderer/futon/alternatives/domain/MigrateUseCase.kt index 996d7fb391..8d02523f1e 100644 --- a/app/src/main/kotlin/io/github/landwarderer/futon/alternatives/domain/MigrateUseCase.kt +++ b/app/src/main/kotlin/io/github/landwarderer/futon/alternatives/domain/MigrateUseCase.kt @@ -67,6 +67,7 @@ constructor( val newHistory = makeNewHistory(oldDetails, newDetails, oldHistory) historyDao.delete(oldDetails.id) historyDao.upsert(newHistory) + database.getStatsDao().move(oldDetails.id, newDetails.id) newHistory } else { null diff --git a/app/src/main/kotlin/io/github/landwarderer/futon/stats/data/StatsDao.kt b/app/src/main/kotlin/io/github/landwarderer/futon/stats/data/StatsDao.kt index ce5afed87c..bfc87cf4c5 100644 --- a/app/src/main/kotlin/io/github/landwarderer/futon/stats/data/StatsDao.kt +++ b/app/src/main/kotlin/io/github/landwarderer/futon/stats/data/StatsDao.kt @@ -34,6 +34,9 @@ abstract class StatsDao { @Query("SELECT COUNT(*) FROM stats WHERE manga_id = :mangaId") abstract fun observeRowCount(mangaId: Long): Flow + @Query("UPDATE OR IGNORE stats SET manga_id = :newMangaId WHERE manga_id = :oldMangaId") + abstract suspend fun move(oldMangaId: Long, newMangaId: Long) + @Upsert abstract suspend fun upsert(entity: StatsEntity)