DT
Drizzle TeamVitorAndrey

Can I generate migrations folder at runtime?

I'm using Electron to build my app, and I'd like to generate the migrations folder at runtime so that I can use the Electron path for userData, as I'm doing with the Database folder.
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 }
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 }