mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-02 16:23:48 +03:00
Merge pull request #985 from hydralauncher/fix/migration-to-fix-missing-columns
fix: migration to fix missing columns
This commit is contained in:
commit
613898b32d
6
build/installer.nsh
Normal file
6
build/installer.nsh
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
!macro customUnInstall
|
||||||
|
${ifNot} ${isUpdated}
|
||||||
|
RMDir /r "$APPDATA\${APP_PACKAGE_NAME}"
|
||||||
|
RMDir /r "$APPDATA\hydra"
|
||||||
|
${endIf}
|
||||||
|
!macroend
|
@ -27,6 +27,7 @@ nsis:
|
|||||||
createDesktopShortcut: always
|
createDesktopShortcut: always
|
||||||
oneClick: false
|
oneClick: false
|
||||||
allowToChangeInstallationDirectory: true
|
allowToChangeInstallationDirectory: true
|
||||||
|
include: installer.nsh
|
||||||
portable:
|
portable:
|
||||||
artifactName: ${name}-${version}-portable.${ext}
|
artifactName: ${name}-${version}-portable.${ext}
|
||||||
mac:
|
mac:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydralauncher",
|
"name": "hydralauncher",
|
||||||
"version": "2.1.4",
|
"version": "2.1.5",
|
||||||
"description": "Hydra",
|
"description": "Hydra",
|
||||||
"main": "./out/main/index.js",
|
"main": "./out/main/index.js",
|
||||||
"author": "Los Broxas",
|
"author": "Los Broxas",
|
||||||
|
@ -11,3 +11,5 @@ export const logsPath = path.join(app.getPath("appData"), "hydra", "logs");
|
|||||||
export const seedsPath = app.isPackaged
|
export const seedsPath = app.isPackaged
|
||||||
? path.join(process.resourcesPath, "seeds")
|
? path.join(process.resourcesPath, "seeds")
|
||||||
: path.join(__dirname, "..", "..", "seeds");
|
: path.join(__dirname, "..", "..", "seeds");
|
||||||
|
|
||||||
|
export const appVersion = app.getVersion();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { defaultDownloadsPath } from "@main/constants";
|
import { appVersion, defaultDownloadsPath } from "@main/constants";
|
||||||
import { app, ipcMain } from "electron";
|
import { ipcMain } from "electron";
|
||||||
|
|
||||||
import "./catalogue/get-catalogue";
|
import "./catalogue/get-catalogue";
|
||||||
import "./catalogue/get-game-shop-details";
|
import "./catalogue/get-game-shop-details";
|
||||||
@ -63,6 +63,6 @@ import "./profile/sync-friend-requests";
|
|||||||
import { isPortableVersion } from "@main/helpers";
|
import { isPortableVersion } from "@main/helpers";
|
||||||
|
|
||||||
ipcMain.handle("ping", () => "pong");
|
ipcMain.handle("ping", () => "pong");
|
||||||
ipcMain.handle("getVersion", () => app.getVersion());
|
ipcMain.handle("getVersion", () => appVersion);
|
||||||
ipcMain.handle("isPortableVersion", () => isPortableVersion());
|
ipcMain.handle("isPortableVersion", () => isPortableVersion());
|
||||||
ipcMain.handle("getDefaultDownloadsPath", () => defaultDownloadsPath);
|
ipcMain.handle("getDefaultDownloadsPath", () => defaultDownloadsPath);
|
||||||
|
@ -5,6 +5,7 @@ import { RepackUris } from "./migrations/20240830143906_RepackUris";
|
|||||||
import { UpdateUserLanguage } from "./migrations/20240913213944_update_user_language";
|
import { UpdateUserLanguage } from "./migrations/20240913213944_update_user_language";
|
||||||
import { EnsureRepackUris } from "./migrations/20240915035339_ensure_repack_uris";
|
import { EnsureRepackUris } from "./migrations/20240915035339_ensure_repack_uris";
|
||||||
import { app } from "electron";
|
import { app } from "electron";
|
||||||
|
import { FixMissingColumns } from "./migrations/20240918001920_FixMissingColumns";
|
||||||
|
|
||||||
export type HydraMigration = Knex.Migration & { name: string };
|
export type HydraMigration = Knex.Migration & { name: string };
|
||||||
|
|
||||||
@ -15,6 +16,7 @@ class MigrationSource implements Knex.MigrationSource<HydraMigration> {
|
|||||||
RepackUris,
|
RepackUris,
|
||||||
UpdateUserLanguage,
|
UpdateUserLanguage,
|
||||||
EnsureRepackUris,
|
EnsureRepackUris,
|
||||||
|
FixMissingColumns,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
getMigrationName(migration: HydraMigration): string {
|
getMigrationName(migration: HydraMigration): string {
|
||||||
|
41
src/main/migrations/20240918001920_FixMissingColumns.ts
Normal file
41
src/main/migrations/20240918001920_FixMissingColumns.ts
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import type { HydraMigration } from "@main/knex-client";
|
||||||
|
import type { Knex } from "knex";
|
||||||
|
|
||||||
|
export const FixMissingColumns: HydraMigration = {
|
||||||
|
name: "FixMissingColumns",
|
||||||
|
up: async (knex: Knex) => {
|
||||||
|
const timestamp = new Date().getTime();
|
||||||
|
await knex.schema
|
||||||
|
.hasColumn("repack", "downloadSourceId")
|
||||||
|
.then(async (exists) => {
|
||||||
|
if (!exists) {
|
||||||
|
await knex.schema.table("repack", (table) => {
|
||||||
|
table
|
||||||
|
.integer("downloadSourceId")
|
||||||
|
.references("download_source.id")
|
||||||
|
.onDelete("CASCADE");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
await knex.schema.hasColumn("game", "remoteId").then(async (exists) => {
|
||||||
|
if (!exists) {
|
||||||
|
await knex.schema.table("game", (table) => {
|
||||||
|
table
|
||||||
|
.text("remoteId")
|
||||||
|
.unique({ indexName: "game_remoteId_unique_" + timestamp });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
await knex.schema.hasColumn("game", "uri").then(async (exists) => {
|
||||||
|
if (!exists) {
|
||||||
|
await knex.schema.table("game", (table) => {
|
||||||
|
table.text("uri");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
down: async (_knex: Knex) => {},
|
||||||
|
};
|
@ -7,6 +7,7 @@ import { clearGamesRemoteIds } from "./library-sync/clear-games-remote-id";
|
|||||||
import { logger } from "./logger";
|
import { logger } from "./logger";
|
||||||
import { UserNotLoggedInError } from "@shared";
|
import { UserNotLoggedInError } from "@shared";
|
||||||
import { omit } from "lodash-es";
|
import { omit } from "lodash-es";
|
||||||
|
import { appVersion } from "@main/constants";
|
||||||
|
|
||||||
interface HydraApiOptions {
|
interface HydraApiOptions {
|
||||||
needsAuth: boolean;
|
needsAuth: boolean;
|
||||||
@ -80,12 +81,16 @@ export class HydraApi {
|
|||||||
static async setupApi() {
|
static async setupApi() {
|
||||||
this.instance = axios.create({
|
this.instance = axios.create({
|
||||||
baseURL: import.meta.env.MAIN_VITE_API_URL,
|
baseURL: import.meta.env.MAIN_VITE_API_URL,
|
||||||
|
headers: { "User-Agent": `Hydra Launcher v${appVersion}` },
|
||||||
});
|
});
|
||||||
|
|
||||||
this.instance.interceptors.request.use(
|
this.instance.interceptors.request.use(
|
||||||
(request) => {
|
(request) => {
|
||||||
logger.log(" ---- REQUEST -----");
|
logger.log(" ---- REQUEST -----");
|
||||||
logger.log(request.method, request.url, request.params, request.data);
|
const data = Array.isArray(request.data)
|
||||||
|
? request.data
|
||||||
|
: omit(request.data, ["refreshToken"]);
|
||||||
|
logger.log(request.method, request.url, request.params, data);
|
||||||
return request;
|
return request;
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user