Skip to content

Commit 613898b

Browse files
authored
Merge pull request #985 from hydralauncher/fix/migration-to-fix-missing-columns
fix: migration to fix missing columns
2 parents b76441a + 2bc9831 commit 613898b

File tree

8 files changed

+62
-5
lines changed

8 files changed

+62
-5
lines changed

build/installer.nsh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
!macro customUnInstall
2+
${ifNot} ${isUpdated}
3+
RMDir /r "$APPDATA\${APP_PACKAGE_NAME}"
4+
RMDir /r "$APPDATA\hydra"
5+
${endIf}
6+
!macroend

electron-builder.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ nsis:
2727
createDesktopShortcut: always
2828
oneClick: false
2929
allowToChangeInstallationDirectory: true
30+
include: installer.nsh
3031
portable:
3132
artifactName: ${name}-${version}-portable.${ext}
3233
mac:

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hydralauncher",
3-
"version": "2.1.4",
3+
"version": "2.1.5",
44
"description": "Hydra",
55
"main": "./out/main/index.js",
66
"author": "Los Broxas",

src/main/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ export const logsPath = path.join(app.getPath("appData"), "hydra", "logs");
1111
export const seedsPath = app.isPackaged
1212
? path.join(process.resourcesPath, "seeds")
1313
: path.join(__dirname, "..", "..", "seeds");
14+
15+
export const appVersion = app.getVersion();

src/main/events/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { defaultDownloadsPath } from "@main/constants";
2-
import { app, ipcMain } from "electron";
1+
import { appVersion, defaultDownloadsPath } from "@main/constants";
2+
import { ipcMain } from "electron";
33

44
import "./catalogue/get-catalogue";
55
import "./catalogue/get-game-shop-details";
@@ -63,6 +63,6 @@ import "./profile/sync-friend-requests";
6363
import { isPortableVersion } from "@main/helpers";
6464

6565
ipcMain.handle("ping", () => "pong");
66-
ipcMain.handle("getVersion", () => app.getVersion());
66+
ipcMain.handle("getVersion", () => appVersion);
6767
ipcMain.handle("isPortableVersion", () => isPortableVersion());
6868
ipcMain.handle("getDefaultDownloadsPath", () => defaultDownloadsPath);

src/main/knex-client.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { RepackUris } from "./migrations/20240830143906_RepackUris";
55
import { UpdateUserLanguage } from "./migrations/20240913213944_update_user_language";
66
import { EnsureRepackUris } from "./migrations/20240915035339_ensure_repack_uris";
77
import { app } from "electron";
8+
import { FixMissingColumns } from "./migrations/20240918001920_FixMissingColumns";
89

910
export type HydraMigration = Knex.Migration & { name: string };
1011

@@ -15,6 +16,7 @@ class MigrationSource implements Knex.MigrationSource<HydraMigration> {
1516
RepackUris,
1617
UpdateUserLanguage,
1718
EnsureRepackUris,
19+
FixMissingColumns,
1820
]);
1921
}
2022
getMigrationName(migration: HydraMigration): string {
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import type { HydraMigration } from "@main/knex-client";
2+
import type { Knex } from "knex";
3+
4+
export const FixMissingColumns: HydraMigration = {
5+
name: "FixMissingColumns",
6+
up: async (knex: Knex) => {
7+
const timestamp = new Date().getTime();
8+
await knex.schema
9+
.hasColumn("repack", "downloadSourceId")
10+
.then(async (exists) => {
11+
if (!exists) {
12+
await knex.schema.table("repack", (table) => {
13+
table
14+
.integer("downloadSourceId")
15+
.references("download_source.id")
16+
.onDelete("CASCADE");
17+
});
18+
}
19+
});
20+
21+
await knex.schema.hasColumn("game", "remoteId").then(async (exists) => {
22+
if (!exists) {
23+
await knex.schema.table("game", (table) => {
24+
table
25+
.text("remoteId")
26+
.unique({ indexName: "game_remoteId_unique_" + timestamp });
27+
});
28+
}
29+
});
30+
31+
await knex.schema.hasColumn("game", "uri").then(async (exists) => {
32+
if (!exists) {
33+
await knex.schema.table("game", (table) => {
34+
table.text("uri");
35+
});
36+
}
37+
});
38+
},
39+
40+
down: async (_knex: Knex) => {},
41+
};

src/main/services/hydra-api.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { clearGamesRemoteIds } from "./library-sync/clear-games-remote-id";
77
import { logger } from "./logger";
88
import { UserNotLoggedInError } from "@shared";
99
import { omit } from "lodash-es";
10+
import { appVersion } from "@main/constants";
1011

1112
interface HydraApiOptions {
1213
needsAuth: boolean;
@@ -80,12 +81,16 @@ export class HydraApi {
8081
static async setupApi() {
8182
this.instance = axios.create({
8283
baseURL: import.meta.env.MAIN_VITE_API_URL,
84+
headers: { "User-Agent": `Hydra Launcher v${appVersion}` },
8385
});
8486

8587
this.instance.interceptors.request.use(
8688
(request) => {
8789
logger.log(" ---- REQUEST -----");
88-
logger.log(request.method, request.url, request.params, request.data);
90+
const data = Array.isArray(request.data)
91+
? request.data
92+
: omit(request.data, ["refreshToken"]);
93+
logger.log(request.method, request.url, request.params, data);
8994
return request;
9095
},
9196
(error) => {

0 commit comments

Comments
 (0)