package com.example.quiz.data.database;

import android.content.Context;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

import com.example.quiz.data.dao.UserActivityLogDao;
import com.example.quiz.data.entity.Logs;

@Database(entities = {Logs.class}, version = 3, exportSchema = false)
public abstract class AppDataBase extends RoomDatabase {

    private static AppDataBase instance;

    public abstract UserActivityLogDao logsDao();

    public static synchronized AppDataBase getInstance(Context context) {
        if (instance == null) {
            instance = Room.databaseBuilder(
                            context.getApplicationContext(),
                            AppDataBase.class,
                            "app-db"
                    ).fallbackToDestructiveMigration() // optionnel
                    .build();
        }
        return instance;
    }
}
