Archived
Adapter now accepts "type" strings from database and can display information accordingly; app bar title font enlargened
This commit is contained in:
@@ -9,7 +9,7 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
||||
import com.denizd.substitutionplan.models.Food
|
||||
import com.denizd.substitutionplan.models.Subst
|
||||
|
||||
@Database(entities = [Subst::class, Food::class], version = 6, exportSchema = false)
|
||||
@Database(entities = [Subst::class, Food::class], version = 7, exportSchema = false)
|
||||
internal abstract class SubstDatabase : RoomDatabase() {
|
||||
|
||||
abstract fun substDao(): SubstDao
|
||||
@@ -22,6 +22,11 @@ internal abstract class SubstDatabase : RoomDatabase() {
|
||||
database.execSQL("ALTER TABLE subst_table ADD COLUMN teacher TEXT NOT NULL DEFAULT ''")
|
||||
}
|
||||
}
|
||||
private val addTypeColumn = object : Migration(6, 7) {
|
||||
override fun migrate(database: SupportSQLiteDatabase) {
|
||||
database.execSQL("ALTER TABLE subst_table ADD COLUMN type TEXT NOT NULL DEFAULT ''")
|
||||
}
|
||||
}
|
||||
|
||||
fun getInstance(context: Context): SubstDatabase? {
|
||||
if (instance == null) {
|
||||
@@ -29,7 +34,7 @@ internal abstract class SubstDatabase : RoomDatabase() {
|
||||
instance = Room.databaseBuilder(context.applicationContext,
|
||||
SubstDatabase::class.java,
|
||||
"subst_database")
|
||||
.addMigrations(addTeacherColumn)
|
||||
.addMigrations(addTeacherColumn, addTypeColumn)
|
||||
.fallbackToDestructiveMigration()
|
||||
.build()
|
||||
}
|
||||
@@ -45,6 +50,7 @@ internal abstract class SubstDatabase : RoomDatabase() {
|
||||
foodInstance = Room.databaseBuilder(context.applicationContext,
|
||||
SubstDatabase::class.java,
|
||||
"food_database")
|
||||
.fallbackToDestructiveMigrationFrom(5, 6)
|
||||
.fallbackToDestructiveMigration()
|
||||
.build()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user