import { product } from '@schemas/@exports'
import { app } from 'electron'
import * as fs from 'fs'
import { join } from 'path'
// Get the path to the folder where the app data (userData) is stored
const userDataPath = app.getPath('userData')
// Create the 'Database' folder inside the 'userData' folder if it does not exist
const appDataPath = join(userDataPath, 'Database')
if (!fs.existsSync(appDataPath)) {
fs.mkdirSync(appDataPath)
}
// Define the paths for the database and migrations
const dbPath = join(appDataPath, 'sqlite.db')
const migrationsPath = join(userDataPath, 'Migrations')
// Create a new Database instance in the dynamic userData path
const betterSqlite = new Database(dbPath)
const db = drizzle(betterSqlite, { schema: { product } })
// Create the 'Migrations' folder using the dynamic path ?????
// Perform migrations using the specified dynamic Migrations path
migrate(db, { migrationsFolder: migrationsPath })
export { db }