fix(backups-schedule): missing null matching for last backup status

This commit is contained in:
Nicolas Meienberger 2026-02-01 15:57:36 +01:00
parent 1e04c763f0
commit 17f2178e36
4 changed files with 17 additions and 4 deletions

View file

@ -15,7 +15,11 @@ export const convertLegacyUserOnFirstLogin = async (ctx: AuthMiddlewareContext)
const legacyUser = await db.query.usersTable.findFirst({ const legacyUser = await db.query.usersTable.findFirst({
where: { where: {
AND: [{ username: body.username.trim().toLowerCase() }, { passwordHash: { NOT: "" } }], AND: [
{ username: body.username.trim().toLowerCase() },
{ passwordHash: { NOT: "" } },
{ passwordHash: { isNotNull: true } },
],
}, },
}); });

View file

@ -30,9 +30,14 @@ export const relations = defineRelations(schema, (r) => ({
}, },
backupSchedulesTable: { backupSchedulesTable: {
mirrors: r.many.repositoriesTable({ 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", 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({ organization: r.one.organization({
from: r.backupSchedulesTable.organizationId, from: r.backupSchedulesTable.organizationId,
to: r.organization.id, to: r.organization.id,

View file

@ -266,7 +266,7 @@ export const backupSchedulesTable = sqliteTable("backup_schedules_table", {
excludeIfPresent: text("exclude_if_present", { mode: "json" }).$type<string[]>().default([]), excludeIfPresent: text("exclude_if_present", { mode: "json" }).$type<string[]>().default([]),
includePatterns: text("include_patterns", { mode: "json" }).$type<string[]>().default([]), includePatterns: text("include_patterns", { mode: "json" }).$type<string[]>().default([]),
lastBackupAt: int("last_backup_at", { mode: "number" }), 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"), lastBackupError: text("last_backup_error"),
nextBackupAt: int("next_backup_at", { mode: "number" }), nextBackupAt: int("next_backup_at", { mode: "number" }),
oneFileSystem: int("one_file_system", { mode: "boolean" }).notNull().default(false), oneFileSystem: int("one_file_system", { mode: "boolean" }).notNull().default(false),

View file

@ -441,7 +441,11 @@ const getSchedulesToExecute = async () => {
const now = Date.now(); const now = Date.now();
const schedules = await db.query.backupSchedulesTable.findMany({ const schedules = await db.query.backupSchedulesTable.findMany({
where: { where: {
AND: [{ enabled: true }, { lastBackupStatus: { NOT: "in_progress" } }, { organizationId }], AND: [
{ enabled: true },
{ OR: [{ lastBackupStatus: { NOT: "in_progress" } }, { lastBackupStatus: { isNull: true } }] },
{ organizationId },
],
}, },
}); });