Change grade weightValue type to double (#285)
This commit is contained in:

committed by
Rafał Borcz

parent
4b0f0de52c
commit
040857ba20
@ -41,6 +41,7 @@ import io.github.wulkanowy.data.db.entities.Student
|
||||
import io.github.wulkanowy.data.db.entities.Subject
|
||||
import io.github.wulkanowy.data.db.entities.Timetable
|
||||
import io.github.wulkanowy.data.db.migrations.Migration10
|
||||
import io.github.wulkanowy.data.db.migrations.Migration11
|
||||
import io.github.wulkanowy.data.db.migrations.Migration2
|
||||
import io.github.wulkanowy.data.db.migrations.Migration3
|
||||
import io.github.wulkanowy.data.db.migrations.Migration4
|
||||
@ -79,7 +80,7 @@ import javax.inject.Singleton
|
||||
abstract class AppDatabase : RoomDatabase() {
|
||||
|
||||
companion object {
|
||||
const val VERSION_SCHEMA = 10
|
||||
const val VERSION_SCHEMA = 11
|
||||
|
||||
fun newInstance(context: Context): AppDatabase {
|
||||
return Room.databaseBuilder(context, AppDatabase::class.java, "wulkanowy_database")
|
||||
@ -95,7 +96,8 @@ abstract class AppDatabase : RoomDatabase() {
|
||||
Migration7(),
|
||||
Migration8(),
|
||||
Migration9(),
|
||||
Migration10()
|
||||
Migration10(),
|
||||
Migration11()
|
||||
)
|
||||
.build()
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ data class Grade(
|
||||
|
||||
val weight: String,
|
||||
|
||||
val weightValue: Int,
|
||||
val weightValue: Double,
|
||||
|
||||
val date: LocalDate,
|
||||
|
||||
|
@ -0,0 +1,34 @@
|
||||
package io.github.wulkanowy.data.db.migrations
|
||||
|
||||
import androidx.room.migration.Migration
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||
|
||||
class Migration11 : Migration(10, 11) {
|
||||
|
||||
override fun migrate(database: SupportSQLiteDatabase) {
|
||||
database.execSQL("""
|
||||
CREATE TABLE IF NOT EXISTS Grades_temp (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
is_read INTEGER NOT NULL,
|
||||
is_notified INTEGER NOT NULL,
|
||||
semester_id INTEGER NOT NULL,
|
||||
student_id INTEGER NOT NULL,
|
||||
subject TEXT NOT NULL,
|
||||
entry TEXT NOT NULL,
|
||||
value INTEGER NOT NULL,
|
||||
modifier REAL NOT NULL,
|
||||
comment TEXT NOT NULL,
|
||||
color TEXT NOT NULL,
|
||||
grade_symbol TEXT NOT NULL,
|
||||
description TEXT NOT NULL,
|
||||
weight TEXT NOT NULL,
|
||||
weightValue REAL NOT NULL,
|
||||
date INTEGER NOT NULL,
|
||||
teacher TEXT NOT NULL
|
||||
)
|
||||
""")
|
||||
database.execSQL("INSERT INTO Grades_temp SELECT * FROM Grades")
|
||||
database.execSQL("DROP TABLE Grades")
|
||||
database.execSQL("ALTER TABLE Grades_temp RENAME TO Grades")
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user