using SWRIS.Migrations;
using System;
using System.Data.SQLite;
using System.IO;

namespace SWRIS.Core
{
    public class SqLiteBaseRepository
    {
        public static string Folder
        {
            get { return Environment.CurrentDirectory + "\\Data"; }
        }
        public static string DbFile
        {
            get { return Folder + "\\Db.sqlite"; }
        }

        public static SQLiteConnection DbConnection()
        {
            return new SQLiteConnection($"Data Source={DbFile};Version=3;");
        }
        public static void CreateDatabase()
        {
            if (!File.Exists(DbFile))
            {
                Directory.CreateDirectory(Folder);
                SQLiteConnection.CreateFile(DbFile);

                Initial_Migration.Excute();
            }
            Add_Table_Alarms.Excute();
        }
    }
}
