This commit is contained in:
kunfei
2022-10-02 23:19:40 +08:00
parent ebdb304e91
commit f6ec7b95e7
6 changed files with 15 additions and 11 deletions
@@ -20,7 +20,7 @@ val appDb by lazy {
}
@Database(
version = 55,
version = 56,
exportSchema = true,
entities = [Book::class, BookGroup::class, BookSource::class, BookChapter::class,
ReplaceRule::class, SearchBook::class, SearchKeyword::class, Cookie::class,
@@ -39,7 +39,8 @@ val appDb by lazy {
AutoMigration(from = 51, to = 52),
AutoMigration(from = 52, to = 53),
AutoMigration(from = 53, to = 54),
AutoMigration(from = 54, to = 55, spec = DatabaseMigrations.Migration_44_45::class)
AutoMigration(from = 54, to = 55, spec = DatabaseMigrations.Migration_54_55::class),
AutoMigration(from = 55, to = 56),
]
)
abstract class AppDatabase : RoomDatabase() {
@@ -325,7 +325,7 @@ object DatabaseMigrations {
@Suppress("ClassName")
class Migration_44_45 : AutoMigrationSpec {
class Migration_54_55 : AutoMigrationSpec {
override fun onPostMigrate(db: SupportSQLiteDatabase) {
db.execSQL(
@@ -64,8 +64,8 @@ data class Book(
// 自定义字符集名称(仅适用于本地书籍)
var charset: String? = null,
// 类型,详见BookType
@ColumnInfo(defaultValue = "1")
var type: Int = 0,
@ColumnInfo(defaultValue = "0")
var type: Int = BookType.text,
// 自定义分组索引号
@ColumnInfo(defaultValue = "0")
var group: Long = 0,
@@ -18,6 +18,9 @@ val Book.isImage: Boolean
val Book.isLocal: Boolean
get() {
if (type == 0) {
return origin == BookType.localTag || origin.startsWith(BookType.webDavTag)
}
return type and BookType.local > 0
}