VitorAndrey
VitorAndrey
DTDrizzle Team
Created by VitorAndrey on 3/6/2024 in #help
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 }
1 replies
DTDrizzle Team
Created by VitorAndrey on 2/14/2024 in #help
Do drizzle migrations work in Electron?
Hello! I would like to learn more about the support for Drizzle with Electron after the build. I'm encountering errors that have led me to believe they might be related to migrations. https://discordapp.com/channels/1043890932593987624/1205153107231772683
1 replies
DTDrizzle Team
Created by VitorAndrey on 2/8/2024 in #help
Migration Error after building with Electron
No description
9 replies