DB v5->v6
This commit is contained in:
parent
391c5e19f7
commit
c3febbcaf6
File diff suppressed because it is too large
Load diff
|
@ -6,7 +6,7 @@ import androidx.room.TypeConverters
|
||||||
import info.nightscout.androidaps.database.daos.*
|
import info.nightscout.androidaps.database.daos.*
|
||||||
import info.nightscout.androidaps.database.entities.*
|
import info.nightscout.androidaps.database.entities.*
|
||||||
|
|
||||||
const val DATABASE_VERSION = 5
|
const val DATABASE_VERSION = 6
|
||||||
|
|
||||||
@Database(version = DATABASE_VERSION,
|
@Database(version = DATABASE_VERSION,
|
||||||
entities = [APSResult::class, Bolus::class, BolusCalculatorResult::class, Carbs::class,
|
entities = [APSResult::class, Bolus::class, BolusCalculatorResult::class, Carbs::class,
|
||||||
|
|
|
@ -21,21 +21,14 @@ open class DatabaseModule {
|
||||||
internal fun provideAppDatabase(context: Context, @DbFileName fileName: String) =
|
internal fun provideAppDatabase(context: Context, @DbFileName fileName: String) =
|
||||||
Room
|
Room
|
||||||
.databaseBuilder(context, AppDatabase::class.java, fileName)
|
.databaseBuilder(context, AppDatabase::class.java, fileName)
|
||||||
.addMigrations(migration1to2)
|
.addMigrations(migration5to6)
|
||||||
.addMigrations(migration3to4)
|
|
||||||
.fallbackToDestructiveMigration()
|
.fallbackToDestructiveMigration()
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
@Qualifier
|
@Qualifier
|
||||||
annotation class DbFileName
|
annotation class DbFileName
|
||||||
|
|
||||||
private val migration1to2 = object : Migration(1, 2) {
|
private val migration5to6 = object : Migration(5, 6) {
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
|
||||||
database.execSQL("CREATE TABLE IF NOT EXISTS userEntry (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `timestamp` INTEGER NOT NULL, `utcOffset` INTEGER NOT NULL, `action` TEXT NOT NULL, `s` TEXT NOT NULL, `d1` REAL NOT NULL, `d2` REAL NOT NULL, `i1` INTEGER NOT NULL, `i2` INTEGER NOT NULL)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private val migration3to4 = object : Migration(3, 4) {
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(database: SupportSQLiteDatabase) {
|
||||||
database.execSQL("DROP TABLE IF EXISTS userEntry")
|
database.execSQL("DROP TABLE IF EXISTS userEntry")
|
||||||
database.execSQL("CREATE TABLE userEntry (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `timestamp` INTEGER NOT NULL, `utcOffset` INTEGER NOT NULL, `action` TEXT NOT NULL, `s` TEXT NOT NULL, `values` TEXT NOT NULL)")
|
database.execSQL("CREATE TABLE userEntry (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `timestamp` INTEGER NOT NULL, `utcOffset` INTEGER NOT NULL, `action` TEXT NOT NULL, `s` TEXT NOT NULL, `values` TEXT NOT NULL)")
|
||||||
|
|
Loading…
Reference in a new issue