diff --git a/app/src/main/java/io/legado/app/data/AppDatabase.kt b/app/src/main/java/io/legado/app/data/AppDatabase.kt index c48736382..70c05de42 100644 --- a/app/src/main/java/io/legado/app/data/AppDatabase.kt +++ b/app/src/main/java/io/legado/app/data/AppDatabase.kt @@ -22,8 +22,8 @@ val appDb by lazy { ReplaceRule::class, SearchBook::class, SearchKeyword::class, Cookie::class, RssSource::class, Bookmark::class, RssArticle::class, RssReadRecord::class, RssStar::class, TxtTocRule::class, ReadRecord::class, HttpTTS::class, Cache::class, - RuleSub::class, EpubChapter::class], - version = 31, + RuleSub::class], + version = 32, exportSchema = true ) abstract class AppDatabase : RoomDatabase() { @@ -45,7 +45,6 @@ abstract class AppDatabase : RoomDatabase() { abstract val httpTTSDao: HttpTTSDao abstract val cacheDao: CacheDao abstract val ruleSubDao: RuleSubDao - abstract val epubChapterDao: EpubChapterDao companion object { @@ -59,7 +58,8 @@ abstract class AppDatabase : RoomDatabase() { migration_14_15, migration_15_17, migration_17_18, migration_18_19, migration_19_20, migration_20_21, migration_21_22, migration_22_23, migration_23_24, migration_24_25, migration_25_26, migration_26_27, - migration_27_28, migration_28_29, migration_29_30, migration_30_31 + migration_27_28, migration_28_29, migration_29_30, migration_30_31, + migration_31_32 ) .allowMainThreadQueries() .addCallback(dbCallback) @@ -290,6 +290,12 @@ abstract class AppDatabase : RoomDatabase() { database.execSQL("insert into readRecord (deviceId, bookName, readTime) select androidId, bookName, readTime from readRecord1") } } + + private val migration_31_32 = object : Migration(31, 32) { + override fun migrate(database: SupportSQLiteDatabase) { + database.execSQL("DROP TABLE `epubChapters`") + } + } } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/data/dao/EpubChapterDao.kt b/app/src/main/java/io/legado/app/data/dao/EpubChapterDao.kt deleted file mode 100644 index cf2f66d2a..000000000 --- a/app/src/main/java/io/legado/app/data/dao/EpubChapterDao.kt +++ /dev/null @@ -1,32 +0,0 @@ -package io.legado.app.data.dao - -import androidx.room.* -import io.legado.app.data.entities.EpubChapter - -@Dao -interface EpubChapterDao { - @get:Query("select * from epubChapters") - val all: List - - @Query("select count(*) from epubChapters Where bookUrl = :bookUrl") - fun getCnt(bookUrl: String): Int - - @Query("select * from epubChapters Where bookUrl = :bookUrl and parentHref = :parentHref ") - fun get(bookUrl: String, parentHref: String): List - - @Insert(onConflict = OnConflictStrategy.REPLACE) - fun insert(vararg chapter: EpubChapter) - - @Query("delete from epubChapters") - fun clear() - - @Query("delete from epubChapters Where bookUrl = :bookUrl") - fun deleteByName(bookUrl: String) - - @Delete - fun delete(vararg chapter: EpubChapter) - - @Update - fun update(vararg chapter: EpubChapter) - -} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/data/entities/EpubChapter.kt b/app/src/main/java/io/legado/app/data/entities/EpubChapter.kt deleted file mode 100644 index 390b63a64..000000000 --- a/app/src/main/java/io/legado/app/data/entities/EpubChapter.kt +++ /dev/null @@ -1,23 +0,0 @@ -package io.legado.app.data.entities - -import androidx.room.Entity -import androidx.room.ForeignKey -import androidx.room.Index - -@Entity( - tableName = "epubChapters", - primaryKeys = ["bookUrl", "href"], - indices = [(Index(value = ["bookUrl"], unique = false)), - (Index(value = ["bookUrl", "href"], unique = true))], - foreignKeys = [(ForeignKey( - entity = Book::class, - parentColumns = ["bookUrl"], - childColumns = ["bookUrl"], - onDelete = ForeignKey.CASCADE - ))] -) -data class EpubChapter( - var bookUrl: String = "", - var href: String = "", - var parentHref: String? = null, -) \ No newline at end of file