2023-04-08 17:30:05 +02:00
|
|
|
package com.denizk0461.studip.db
|
|
|
|
|
|
|
|
|
|
import android.content.Context
|
|
|
|
|
import androidx.room.Database
|
|
|
|
|
import androidx.room.Room
|
|
|
|
|
import androidx.room.RoomDatabase
|
2023-04-16 18:19:06 +02:00
|
|
|
import com.denizk0461.studip.model.CanteenOffer
|
2023-04-08 18:53:51 +02:00
|
|
|
import com.denizk0461.studip.model.StudIPEvent
|
2023-04-08 17:30:05 +02:00
|
|
|
|
2023-04-16 21:41:46 +02:00
|
|
|
@Database(entities = [StudIPEvent::class, CanteenOffer::class], version = 7)
|
2023-04-08 17:30:05 +02:00
|
|
|
abstract class EventDatabase : RoomDatabase() {
|
|
|
|
|
|
|
|
|
|
abstract fun dao(): EventDAO
|
|
|
|
|
|
|
|
|
|
companion object {
|
|
|
|
|
private var instance: EventDatabase? = null
|
|
|
|
|
|
|
|
|
|
fun getInstance(context: Context): EventDatabase {
|
|
|
|
|
if (instance == null) {
|
|
|
|
|
synchronized(EventDatabase::class) {
|
|
|
|
|
instance = Room.databaseBuilder(
|
|
|
|
|
context.applicationContext,
|
|
|
|
|
EventDatabase::class.java,
|
|
|
|
|
"event_db"
|
2023-04-10 20:54:15 +02:00
|
|
|
).fallbackToDestructiveMigration().build()
|
2023-04-08 17:30:05 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return instance!!
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|