package cz.muni.sutralog.database

import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import androidx.room.TypeConverters

@Database(
    entities = [CategoryEntity::class, RockEntity::class],
    version = 3
)
@TypeConverters(Converters::class)
abstract class SutralogDatabase : RoomDatabase() {

    companion object {
        private const val NAME = "sutralog.db"

        fun create(context: Context): SutralogDatabase =
            Room.databaseBuilder(context, SutralogDatabase::class.java, NAME)
                .allowMainThreadQueries()
                .fallbackToDestructiveMigration()
                .build()
    }

    abstract fun categoryDao(): CategoryDao
    abstract fun rockDao(): RockDao
}
