DB paths working on mac now

This commit is contained in:
Will Chen
2025-04-11 10:21:05 -07:00
parent 43f67e0739
commit 4e577c1da8
4 changed files with 13 additions and 8 deletions

View File

@@ -1,13 +1,14 @@
import type { Config } from "drizzle-kit"; import type { Config } from "drizzle-kit";
import path from "path"; import path from "path";
import { getUserDataPath } from "./src/paths/paths";
const devDbPath = path.resolve("./userData/sqlite.db"); const dbPath = path.join(getUserDataPath(), "sqlite.db");
export default { export default {
schema: "./src/db/schema.ts", schema: "./src/db/schema.ts",
out: "./drizzle", out: "./drizzle",
dialect: "sqlite", dialect: "sqlite",
dbCredentials: { dbCredentials: {
url: devDbPath, url: dbPath,
}, },
} satisfies Config; } satisfies Config;

View File

@@ -62,7 +62,10 @@ export function initializeDatabase(): BetterSQLite3Database<typeof schema> & {
try { try {
// Run migrations programmatically // Run migrations programmatically
const migrationsFolder = path.join(process.cwd(), "drizzle");
const migrationsFolder = path.join(__dirname, "..", "..", "drizzle");
console.log("MIGRATIONS FOLDER INITIALIZE", migrationsFolder);
// Verify migrations folder exists // Verify migrations folder exists
if (!fs.existsSync(migrationsFolder)) { if (!fs.existsSync(migrationsFolder)) {

View File

@@ -50,9 +50,10 @@ const createWindow = () => {
path.join(__dirname, "../renderer/main_window/index.html") path.join(__dirname, "../renderer/main_window/index.html")
); );
} }
if (process.env.NODE_ENV === "development") {
// Open the DevTools. // Open the DevTools.
mainWindow.webContents.openDevTools(); mainWindow.webContents.openDevTools();
}
}; };
// This method will be called when Electron has finished // This method will be called when Electron has finished

View File

@@ -15,8 +15,8 @@ export function getUserDataPath(): string {
const electron = getElectron(); const electron = getElectron();
// When running in Electron and app is ready // When running in Electron and app is ready
if (electron?.app?.isReady() && process.env.NODE_ENV !== "development") { if (process.env.NODE_ENV !== "development") {
return electron.app.getPath("userData"); return electron!.app.getPath("userData");
} }
// For development or when the Electron app object isn't available // For development or when the Electron app object isn't available