diff --git a/src/main/constants.ts b/src/main/constants.ts index 850c9ada..c8cf182f 100644 --- a/src/main/constants.ts +++ b/src/main/constants.ts @@ -3,11 +3,8 @@ import path from "node:path"; export const defaultDownloadsPath = app.getPath("downloads"); -export const databasePath = path.join( - app.getPath("appData"), - "hydra", - "hydra.db" -); +export const databaseDirectory = path.join(app.getPath("appData"), "hydra"); +export const databasePath = path.join(databaseDirectory, "hydra.db"); export const logsPath = path.join(app.getPath("appData"), "hydra", "logs"); diff --git a/src/main/index.ts b/src/main/index.ts index 3c5cc254..00311b46 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -4,12 +4,14 @@ import updater from "electron-updater"; import i18n from "i18next"; import path from "node:path"; import url from "node:url"; +import fs from "node:fs"; import { electronApp, optimizer } from "@electron-toolkit/utils"; import { logger, PythonInstance, WindowManager } from "@main/services"; import { dataSource } from "@main/data-source"; import resources from "@locales"; import { userPreferencesRepository } from "@main/repository"; import { knexClient, migrationConfig } from "./knex-client"; +import { databaseDirectory } from "./constants"; const { autoUpdater } = updater; @@ -54,6 +56,10 @@ if (process.defaultApp) { } const runMigrations = async () => { + if (!fs.existsSync(databaseDirectory)) { + fs.mkdirSync(databaseDirectory, { recursive: true }); + } + await knexClient.migrate.list(migrationConfig).then((result) => { logger.log( "Migrations to run:", diff --git a/yarn.lock b/yarn.lock index 91d9977f..b4040484 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2879,10 +2879,10 @@ axe-core@=4.7.0: resolved "https://registry.npmjs.org/axe-core/-/axe-core-4.7.0.tgz" integrity sha512-M0JtH+hlOL5pLQwHOLNYZaXuhqmvS8oExsqB1SBYgA4Dk7u/xx+YdGHXaK5pyUfed5mYXdlYiphWq3G8cRi5JQ== -axios@^1.6.8: - version "1.6.8" - resolved "https://registry.npmjs.org/axios/-/axios-1.6.8.tgz" - integrity sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ== +axios@^1.7.7: + version "1.7.7" + resolved "https://registry.yarnpkg.com/axios/-/axios-1.7.7.tgz#2f554296f9892a72ac8d8e4c5b79c14a91d0a47f" + integrity sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q== dependencies: follow-redirects "^1.15.6" form-data "^4.0.0"