|
|
@ -7,6 +7,7 @@ import androidx.room.RoomDatabase |
|
|
|
import androidx.room.migration.Migration |
|
|
|
import androidx.room.migration.Migration |
|
|
|
import androidx.sqlite.db.SupportSQLiteDatabase |
|
|
|
import androidx.sqlite.db.SupportSQLiteDatabase |
|
|
|
import io.legado.app.App |
|
|
|
import io.legado.app.App |
|
|
|
|
|
|
|
import io.legado.app.constant.AppConst |
|
|
|
import io.legado.app.data.dao.* |
|
|
|
import io.legado.app.data.dao.* |
|
|
|
import io.legado.app.data.entities.* |
|
|
|
import io.legado.app.data.entities.* |
|
|
|
|
|
|
|
|
|
|
@ -47,26 +48,26 @@ abstract class AppDatabase: RoomDatabase() { |
|
|
|
override fun onOpen(db: SupportSQLiteDatabase) { |
|
|
|
override fun onOpen(db: SupportSQLiteDatabase) { |
|
|
|
db.execSQL( |
|
|
|
db.execSQL( |
|
|
|
""" |
|
|
|
""" |
|
|
|
insert into book_groups(groupId, groupName, 'order') select -1, '全部', -10 |
|
|
|
insert into book_groups(groupId, groupName, 'order') select ${AppConst.bookGroupAllId}, '全部', -10 |
|
|
|
where not exists (select * from book_groups where groupId = -1) |
|
|
|
where not exists (select * from book_groups where groupId = ${AppConst.bookGroupAllId}) |
|
|
|
""" |
|
|
|
""" |
|
|
|
) |
|
|
|
) |
|
|
|
db.execSQL( |
|
|
|
db.execSQL( |
|
|
|
""" |
|
|
|
""" |
|
|
|
insert into book_groups(groupId, groupName, 'order') select -2, '本地', -9 |
|
|
|
insert into book_groups(groupId, groupName, 'order') select ${AppConst.bookGroupLocalId}, '本地', -9 |
|
|
|
where not exists (select * from book_groups where groupId = -2) |
|
|
|
where not exists (select * from book_groups where groupId = ${AppConst.bookGroupLocalId}) |
|
|
|
""" |
|
|
|
""" |
|
|
|
) |
|
|
|
) |
|
|
|
db.execSQL( |
|
|
|
db.execSQL( |
|
|
|
""" |
|
|
|
""" |
|
|
|
insert into book_groups(groupId, groupName, 'order') select -3, '音频', -8 |
|
|
|
insert into book_groups(groupId, groupName, 'order') select ${AppConst.bookGroupAudioId}, '音频', -8 |
|
|
|
where not exists (select * from book_groups where groupId = -3) |
|
|
|
where not exists (select * from book_groups where groupId = ${AppConst.bookGroupAudioId}) |
|
|
|
""" |
|
|
|
""" |
|
|
|
) |
|
|
|
) |
|
|
|
db.execSQL( |
|
|
|
db.execSQL( |
|
|
|
""" |
|
|
|
""" |
|
|
|
insert into book_groups(groupId, groupName, 'order') select -4, '未分组', -7 |
|
|
|
insert into book_groups(groupId, groupName, 'order') select ${AppConst.bookGroupNoneId}, '未分组', -7 |
|
|
|
where not exists (select * from book_groups where groupId = -4) |
|
|
|
where not exists (select * from book_groups where groupId = ${AppConst.bookGroupNoneId}) |
|
|
|
""" |
|
|
|
""" |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|