2020-09-23 22:47:45 -04:00
|
|
|
package com.geeksville.mesh.database
|
|
|
|
|
|
2022-07-29 21:28:09 -03:00
|
|
|
import android.content.Context
|
2020-09-23 22:47:45 -04:00
|
|
|
import androidx.room.Database
|
2022-07-29 21:28:09 -03:00
|
|
|
import androidx.room.Room
|
2020-09-23 22:47:45 -04:00
|
|
|
import androidx.room.RoomDatabase
|
|
|
|
|
import com.geeksville.mesh.database.dao.PacketDao
|
2022-08-11 16:43:26 +01:00
|
|
|
import com.geeksville.mesh.database.dao.QuickChatActionDao
|
2020-09-23 22:47:45 -04:00
|
|
|
import com.geeksville.mesh.database.entity.Packet
|
2022-08-11 16:43:26 +01:00
|
|
|
import com.geeksville.mesh.database.entity.QuickChatAction
|
2020-09-23 22:47:45 -04:00
|
|
|
|
2022-08-11 16:43:26 +01:00
|
|
|
@Database(entities = [Packet::class, QuickChatAction::class], version = 2, exportSchema = false)
|
2020-09-23 22:47:45 -04:00
|
|
|
abstract class MeshtasticDatabase : RoomDatabase() {
|
|
|
|
|
abstract fun packetDao(): PacketDao
|
2022-08-11 16:43:26 +01:00
|
|
|
abstract fun quickChatActionDao(): QuickChatActionDao
|
2022-07-29 21:28:09 -03:00
|
|
|
|
|
|
|
|
companion object {
|
|
|
|
|
fun getDatabase(context: Context): MeshtasticDatabase {
|
|
|
|
|
|
|
|
|
|
return Room.databaseBuilder(
|
|
|
|
|
context.applicationContext,
|
|
|
|
|
MeshtasticDatabase::class.java,
|
|
|
|
|
"meshtastic_database"
|
|
|
|
|
)
|
|
|
|
|
.fallbackToDestructiveMigration()
|
|
|
|
|
.build()
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-09-23 22:47:45 -04:00
|
|
|
}
|