mirror of
https://github.com/PranshulGG/WeatherMaster.git
synced 2026-10-22 11:02:53 -05:00
add database schemas for versions 40, 41, and 42 and add dawn and dusk fields to weather_daily table
This commit is contained in:
1 parent
cc76e55ce4
commit
ec2a7571bc
1 file changed
+20
-5
+20
-5
@@ -70,11 +70,26 @@ abstract class WeatherMasterDatabase : RoomDatabase() {
|
||||
|
||||
val MIGRATION_40_41 = object : Migration(40, 41) {
|
||||
override fun migrate(db: SupportSQLiteDatabase) {
|
||||
db.execSQL(
|
||||
"""
|
||||
ALTER TABLE weather_hourly ADD COLUMN dewPoint REAL
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
val all = db.query("PRAGMA table_info(weather_hourly)")
|
||||
var exists = false
|
||||
|
||||
while (all.moveToNext()) {
|
||||
val columnName = all.getString(
|
||||
all.getColumnIndexOrThrow("name")
|
||||
)
|
||||
|
||||
if (columnName == "dewPoint") {
|
||||
exists = true
|
||||
break
|
||||
}
|
||||
}
|
||||
all.close()
|
||||
if (!exists) {
|
||||
db.execSQL(
|
||||
"ALTER TABLE weather_hourly ADD COLUMN dewPoint REAL"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user