From 17f2178e365486a081467cff468d69f303399c95 Mon Sep 17 00:00:00 2001 From: Nicolas Meienberger Date: Sun, 1 Feb 2026 15:57:36 +0100 Subject: [PATCH] fix(backups-schedule): missing null matching for last backup status --- app/lib/auth-middlewares/convert-legacy-user.ts | 6 +++++- app/server/db/relations.ts | 7 ++++++- app/server/db/schema.ts | 2 +- app/server/modules/backups/backups.service.ts | 6 +++++- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/lib/auth-middlewares/convert-legacy-user.ts b/app/lib/auth-middlewares/convert-legacy-user.ts index 759d7109..f3c2d236 100644 --- a/app/lib/auth-middlewares/convert-legacy-user.ts +++ b/app/lib/auth-middlewares/convert-legacy-user.ts @@ -15,7 +15,11 @@ export const convertLegacyUserOnFirstLogin = async (ctx: AuthMiddlewareContext) const legacyUser = await db.query.usersTable.findFirst({ where: { - AND: [{ username: body.username.trim().toLowerCase() }, { passwordHash: { NOT: "" } }], + AND: [ + { username: body.username.trim().toLowerCase() }, + { passwordHash: { NOT: "" } }, + { passwordHash: { isNotNull: true } }, + ], }, }); diff --git a/app/server/db/relations.ts b/app/server/db/relations.ts index 14448e7c..091e6625 100644 --- a/app/server/db/relations.ts +++ b/app/server/db/relations.ts @@ -30,9 +30,14 @@ export const relations = defineRelations(schema, (r) => ({ }, backupSchedulesTable: { mirrors: r.many.repositoriesTable({ + from: r.backupSchedulesTable.id.through(r.backupScheduleMirrorsTable.scheduleId), + to: r.repositoriesTable.id.through(r.backupScheduleMirrorsTable.repositoryId), alias: "repositoriesTable_id_backupSchedulesTable_id_via_backupScheduleMirrorsTable", }), - notificationDestinationsTables: r.many.notificationDestinationsTable(), + notificationDestinationsTables: r.many.notificationDestinationsTable({ + from: r.backupSchedulesTable.id.through(r.backupScheduleNotificationsTable.scheduleId), + to: r.notificationDestinationsTable.id.through(r.backupScheduleNotificationsTable.destinationId), + }), organization: r.one.organization({ from: r.backupSchedulesTable.organizationId, to: r.organization.id, diff --git a/app/server/db/schema.ts b/app/server/db/schema.ts index ecdce860..e6336e0d 100644 --- a/app/server/db/schema.ts +++ b/app/server/db/schema.ts @@ -266,7 +266,7 @@ export const backupSchedulesTable = sqliteTable("backup_schedules_table", { excludeIfPresent: text("exclude_if_present", { mode: "json" }).$type().default([]), includePatterns: text("include_patterns", { mode: "json" }).$type().default([]), lastBackupAt: int("last_backup_at", { mode: "number" }), - lastBackupStatus: text("last_backup_status").$type<"success" | "error" | "in_progress" | "warning">(), + lastBackupStatus: text("last_backup_status").$type<"success" | "error" | "in_progress" | "warning" | null>(), lastBackupError: text("last_backup_error"), nextBackupAt: int("next_backup_at", { mode: "number" }), oneFileSystem: int("one_file_system", { mode: "boolean" }).notNull().default(false), diff --git a/app/server/modules/backups/backups.service.ts b/app/server/modules/backups/backups.service.ts index 5661b52e..d7402e47 100644 --- a/app/server/modules/backups/backups.service.ts +++ b/app/server/modules/backups/backups.service.ts @@ -441,7 +441,11 @@ const getSchedulesToExecute = async () => { const now = Date.now(); const schedules = await db.query.backupSchedulesTable.findMany({ where: { - AND: [{ enabled: true }, { lastBackupStatus: { NOT: "in_progress" } }, { organizationId }], + AND: [ + { enabled: true }, + { OR: [{ lastBackupStatus: { NOT: "in_progress" } }, { lastBackupStatus: { isNull: true } }] }, + { organizationId }, + ], }, });