From aa0a01b5c8a8cc63a1d45a7a040d20579706d230 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 18 Oct 2024 17:58:51 +1300 Subject: [PATCH] Set default pro plan policy schedule to midnight local time instead of UTC --- src/lib/helpers/backups.ts | 6 ++++-- .../databases/database-[database]/backups/store.ts | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib/helpers/backups.ts b/src/lib/helpers/backups.ts index 0921b15a4..8100f40a7 100644 --- a/src/lib/helpers/backups.ts +++ b/src/lib/helpers/backups.ts @@ -29,8 +29,10 @@ export const cronExpression = (policy: UserBackupPolicy) => { let cronExpression = ''; if (policy.default) { - // default should use utc. - cronExpression = policy.schedule; + now.setHours(0, 0, 0); + const utcHour = now.getUTCHours(); + + cronExpression = policy.schedule.replace('{time}', `0 ${utcHour}`); } else { const [localHour, localMinute] = policy.selectedTime.split(':'); now.setHours(parseInt(localHour), parseInt(localMinute), 0); diff --git a/src/routes/(console)/project-[project]/databases/database-[database]/backups/store.ts b/src/routes/(console)/project-[project]/databases/database-[database]/backups/store.ts index 2036a8e93..1c2b3da2f 100644 --- a/src/routes/(console)/project-[project]/databases/database-[database]/backups/store.ts +++ b/src/routes/(console)/project-[project]/databases/database-[database]/backups/store.ts @@ -21,7 +21,7 @@ export const presetPolicies = writable([ retained: 7, default: true, checked: false, - schedule: '0 0 * * *', + schedule: '{time} * * *', selectedTime: '00:00', plainTextFrequency: 'daily', description: 'Runs every day and is retained for 7 days'