Fix fresh installs databases
This commit is contained in:
parent
b7a94a72fa
commit
d0f9ad9857
@ -25,7 +25,7 @@ class DbOpenCallback : SupportSQLiteOpenHelper.Callback(DATABASE_VERSION) {
|
||||
/**
|
||||
* Version of the database.
|
||||
*/
|
||||
const val DATABASE_VERSION = /* SY --> */ 11 /* SY <-- */
|
||||
const val DATABASE_VERSION = /* SY --> */ 12 /* SY <-- */
|
||||
}
|
||||
|
||||
override fun onCreate(db: SupportSQLiteDatabase) = with(db) {
|
||||
@ -40,6 +40,7 @@ class DbOpenCallback : SupportSQLiteOpenHelper.Callback(DATABASE_VERSION) {
|
||||
execSQL(SearchTagTable.createTableQuery)
|
||||
execSQL(SearchTitleTable.createTableQuery)
|
||||
execSQL(MergedTable.createTableQuery)
|
||||
execSQL(FavoriteEntryTable.createTableQuery)
|
||||
// SY <--
|
||||
|
||||
// DB indexes
|
||||
@ -97,6 +98,9 @@ class DbOpenCallback : SupportSQLiteOpenHelper.Callback(DATABASE_VERSION) {
|
||||
if (oldVersion < 11) {
|
||||
db.execSQL(FavoriteEntryTable.createTableQuery)
|
||||
}
|
||||
if (oldVersion < 12) {
|
||||
db.execSQL(FavoriteEntryTable.fixTableQuery)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onConfigure(db: SupportSQLiteDatabase) {
|
||||
|
@ -23,4 +23,10 @@ object FavoriteEntryTable {
|
||||
$COL_TOKEN TEXT NOT NULL,
|
||||
$COL_CATEGORY INTEGER NOT NULL
|
||||
)"""
|
||||
|
||||
val fixTableQuery: String
|
||||
get() = createTableQuery.replace(
|
||||
"CREATE TABLE",
|
||||
"CREATE TABLE IF NOT EXISTS"
|
||||
)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user