Merge pull request #985 from hydralauncher/fix/migration-to-fix-missing-columns
Some checks failed
Release / build (ubuntu-latest) (push) Has been cancelled
Release / build (windows-latest) (push) Has been cancelled

fix: migration to fix missing columns
This commit is contained in:
Zamitto 2024-09-18 07:35:27 -03:00 committed by GitHub
commit 613898b32d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 62 additions and 5 deletions

6
build/installer.nsh Normal file
View File

@ -0,0 +1,6 @@
!macro customUnInstall
${ifNot} ${isUpdated}
RMDir /r "$APPDATA\${APP_PACKAGE_NAME}"
RMDir /r "$APPDATA\hydra"
${endIf}
!macroend

View File

@ -27,6 +27,7 @@ nsis:
createDesktopShortcut: always
oneClick: false
allowToChangeInstallationDirectory: true
include: installer.nsh
portable:
artifactName: ${name}-${version}-portable.${ext}
mac:

View File

@ -1,6 +1,6 @@
{
"name": "hydralauncher",
"version": "2.1.4",
"version": "2.1.5",
"description": "Hydra",
"main": "./out/main/index.js",
"author": "Los Broxas",

View File

@ -11,3 +11,5 @@ export const logsPath = path.join(app.getPath("appData"), "hydra", "logs");
export const seedsPath = app.isPackaged
? path.join(process.resourcesPath, "seeds")
: path.join(__dirname, "..", "..", "seeds");
export const appVersion = app.getVersion();

View File

@ -1,5 +1,5 @@
import { defaultDownloadsPath } from "@main/constants";
import { app, ipcMain } from "electron";
import { appVersion, defaultDownloadsPath } from "@main/constants";
import { ipcMain } from "electron";
import "./catalogue/get-catalogue";
import "./catalogue/get-game-shop-details";
@ -63,6 +63,6 @@ import "./profile/sync-friend-requests";
import { isPortableVersion } from "@main/helpers";
ipcMain.handle("ping", () => "pong");
ipcMain.handle("getVersion", () => app.getVersion());
ipcMain.handle("getVersion", () => appVersion);
ipcMain.handle("isPortableVersion", () => isPortableVersion());
ipcMain.handle("getDefaultDownloadsPath", () => defaultDownloadsPath);

View File

@ -5,6 +5,7 @@ import { RepackUris } from "./migrations/20240830143906_RepackUris";
import { UpdateUserLanguage } from "./migrations/20240913213944_update_user_language";
import { EnsureRepackUris } from "./migrations/20240915035339_ensure_repack_uris";
import { app } from "electron";
import { FixMissingColumns } from "./migrations/20240918001920_FixMissingColumns";
export type HydraMigration = Knex.Migration & { name: string };
@ -15,6 +16,7 @@ class MigrationSource implements Knex.MigrationSource<HydraMigration> {
RepackUris,
UpdateUserLanguage,
EnsureRepackUris,
FixMissingColumns,
]);
}
getMigrationName(migration: HydraMigration): string {

View 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) => {},
};

View File

@ -7,6 +7,7 @@ import { clearGamesRemoteIds } from "./library-sync/clear-games-remote-id";
import { logger } from "./logger";
import { UserNotLoggedInError } from "@shared";
import { omit } from "lodash-es";
import { appVersion } from "@main/constants";
interface HydraApiOptions {
needsAuth: boolean;
@ -80,12 +81,16 @@ export class HydraApi {
static async setupApi() {
this.instance = axios.create({
baseURL: import.meta.env.MAIN_VITE_API_URL,
headers: { "User-Agent": `Hydra Launcher v${appVersion}` },
});
this.instance.interceptors.request.use(
(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;
},
(error) => {