forked from omni/OmniCards
fix: fixed wear database
This commit is contained in:
@@ -6,7 +6,7 @@ import android.database.sqlite.SQLiteDatabase
|
||||
import android.database.sqlite.SQLiteOpenHelper
|
||||
import com.google.zxing.BarcodeFormat
|
||||
|
||||
class DbHelper(val context: Context, val factory: SQLiteDatabase.CursorFactory?) : SQLiteOpenHelper(context, "omni_cards", factory, 2) {
|
||||
class DbHelper(val context: Context, val factory: SQLiteDatabase.CursorFactory?) : SQLiteOpenHelper(context, "omni_cards", factory, 4) {
|
||||
override fun onCreate(db: SQLiteDatabase?) {
|
||||
db!!.execSQL("CREATE TABLE IF NOT EXISTS cards (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, codeType TEXT, codeValue TEXT, color TEXT)")
|
||||
}
|
||||
@@ -19,6 +19,17 @@ class DbHelper(val context: Context, val factory: SQLiteDatabase.CursorFactory?)
|
||||
if (oldVersion < 2) {
|
||||
db!!.execSQL("ALTER TABLE cards ADD COLUMN color TEXT")
|
||||
}
|
||||
|
||||
if (oldVersion < 3) {
|
||||
db!!.execSQL("ALTER TABLE cards ADD COLUMN position INTEGER DEFAULT 0")
|
||||
db.execSQL("ALTER TABLE cards ADD COLUMN iconPath TEXT")
|
||||
db.execSQL("UPDATE cards SET position = id")
|
||||
}
|
||||
|
||||
if (oldVersion < 4) {
|
||||
db!!.execSQL("ALTER TABLE cards DROP COLUMN position")
|
||||
db.execSQL("ALTER TABLE cards DROP COLUMN iconPath")
|
||||
}
|
||||
}
|
||||
|
||||
fun clearDatabase() {
|
||||
|
||||
Reference in New Issue
Block a user