pull/1251/head
gedoor 3 years ago
parent d69e5e7bd6
commit e66e91406c
  1. 52
      app/src/main/java/io/legado/app/data/AppDatabase.kt

@ -28,6 +28,10 @@ val appDb by lazy {
RssStar::class, TxtTocRule::class, ReadRecord::class, HttpTTS::class, Cache::class,
RuleSub::class],
autoMigrations = [
AutoMigration(from = 1, to = 10),
AutoMigration(from = 12, to = 13),
AutoMigration(from = 19, to = 21),
AutoMigration(from = 27, to = 29),
AutoMigration(from = 33, to = 35),
]
)
@ -59,11 +63,13 @@ abstract class AppDatabase : RoomDatabase() {
Room.databaseBuilder(context, AppDatabase::class.java, DATABASE_NAME)
.fallbackToDestructiveMigration()
.addMigrations(
migration_10_11, migration_11_12, migration_12_13, migration_13_14,
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_10_11, migration_13_14,
migration_14_15, migration_15_17,
migration_17_18, migration_18_19,
migration_21_22, migration_22_23,
migration_23_24, migration_24_25,
migration_25_26, migration_26_27,
migration_29_30, migration_30_31,
migration_31_32, migration_32_33
)
.allowMainThreadQueries()
@ -114,18 +120,6 @@ abstract class AppDatabase : RoomDatabase() {
}
}
private val migration_11_12 = object : Migration(11, 12) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("ALTER TABLE rssSources ADD style TEXT ")
}
}
private val migration_12_13 = object : Migration(12, 13) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("ALTER TABLE rssSources ADD articleStyle INTEGER NOT NULL DEFAULT 0 ")
}
}
private val migration_13_14 = object : Migration(13, 14) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL(
@ -173,17 +167,6 @@ abstract class AppDatabase : RoomDatabase() {
database.execSQL("ALTER TABLE readRecordNew RENAME TO readRecord")
}
}
private val migration_19_20 = object : Migration(19, 20) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("ALTER TABLE book_sources ADD bookSourceComment TEXT")
}
}
private val migration_20_21 = object : Migration(20, 21) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("ALTER TABLE book_groups ADD show INTEGER NOT NULL DEFAULT 1")
}
}
private val migration_21_22 = object : Migration(21, 22) {
override fun migrate(database: SupportSQLiteDatabase) {
@ -262,19 +245,6 @@ abstract class AppDatabase : RoomDatabase() {
}
}
private val migration_27_28 = object : Migration(27, 28) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("ALTER TABLE rssArticles ADD variable TEXT")
database.execSQL("ALTER TABLE rssStars ADD variable TEXT")
}
}
private val migration_28_29 = object : Migration(28, 29) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("ALTER TABLE rssSources ADD sourceComment TEXT")
}
}
private val migration_29_30 = object : Migration(29, 30) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("ALTER TABLE chapters ADD `startFragmentId` TEXT")

Loading…
Cancel
Save