+++ /dev/null
-# @tag: background_job_change_create_periodic_invoices_to_daily
-# @description: Hintergrundjob zum Erzeugen periodischer Rechnungen täglich ausführen
-# @depends: release_3_0_0
-package SL::DBUpgrade2::background_job_change_create_periodic_invoices_to_daily;
-
-use strict;
-use utf8;
-
-use parent qw(SL::DBUpgrade2::Base);
-
-use SL::DB::BackgroundJob;
-
-sub run {
- my ($self) = @_;
-
- foreach my $job (@{ SL::DB::Manager::BackgroundJob->get_all(where => [ package_name => 'CreatePeriodicInvoices' ]) }) {
- $job->update_attributes(cron_spec => '0 3 * * *', next_run_at => undef);
- }
-
- return 1;
-}
-
-1;
--- /dev/null
+-- @tag: background_job_change_create_periodic_invoices_to_daily
+-- @description: Hintergrundjob zum Erzeugen periodischer Rechnungen täglich ausführen
+-- @depends: release_3_0_0
+UPDATE background_jobs
+SET cron_spec = '0 3 * * *',
+ next_run_at = CAST(current_date AS timestamp) + CAST(
+ (CASE
+ WHEN extract('hour' FROM current_timestamp) < 3 THEN '3 hours'
+ ELSE '1 day 3 hours'
+ END) AS interval
+ )
+WHERE package_name = 'CreatePeriodicInvoices';
+++ /dev/null
-# @tag: background_jobs_3
-# @description: Backgroundjob Cleanup einrichten
-# @depends: emmvee_background_jobs_2
-package SL::DBUpgrade2::background_jobs_3;
-
-use strict;
-use utf8;
-
-use parent qw(SL::DBUpgrade2::Base);
-
-use SL::BackgroundJob::BackgroundJobCleanup;
-
-sub run {
- SL::BackgroundJob::BackgroundJobCleanup->create_job;
- return 1;
-}
-
-1;
--- /dev/null
+-- @tag: background_jobs_3
+-- @description: Backgroundjob Cleanup einrichten
+-- @depends: emmvee_background_jobs_2
+INSERT INTO background_jobs (type, package_name, active, cron_spec, next_run_at)
+VALUES ('interval', 'BackgroundJobCleanup', true, '0 3 * * *',
+ CAST(current_date AS timestamp) + CAST(
+ (CASE
+ WHEN extract('hour' FROM current_timestamp) < 3 THEN '3 hours'
+ ELSE '1 day 3 hours'
+ END) AS interval
+ )
+);
+++ /dev/null
-# @tag: background_jobs_clean_auth_sessions
-# @description: Hintergrundjob zum Löschen abgelaufener Sessions
-# @depends: release_3_1_0
-package SL::DBUpgrade2::background_jobs_clean_auth_sessions;
-
-use strict;
-use utf8;
-
-use parent qw(SL::DBUpgrade2::Base);
-
-use SL::BackgroundJob::CleanAuthSessions;
-
-sub run {
- my ($self) = @_;
-
- SL::BackgroundJob::CleanAuthSessions->create_job;
-
- return 1;
-}
-
-1;
--- /dev/null
+-- @tag: background_jobs_clean_auth_sessions
+-- @description: Hintergrundjob zum Löschen abgelaufener Sessions
+-- @depends: release_3_1_0
+INSERT INTO background_jobs (type, package_name, active, cron_spec, next_run_at)
+VALUES ('interval', 'CleanAuthSessions', true, '30 6 * * *',
+ CAST(current_date AS timestamp) + CAST(
+ (CASE
+ WHEN extract('hour' FROM current_timestamp) < 6 THEN '6 hours 30 minutes'
+ ELSE '1 day 6 hours 30 minutes'
+ END) AS interval
+ )
+);
+++ /dev/null
-# @tag: emmvee_background_jobs_2
-# @description: Hintergrundjobs einrichten
-# @depends: emmvee_background_jobs
-package SL::DBUpgrade2::emmvee_background_jobs_2;
-
-use strict;
-use utf8;
-
-use parent qw(SL::DBUpgrade2::Base);
-
-use SL::BackgroundJob::CleanBackgroundJobHistory;
-
-sub run {
- SL::BackgroundJob::CleanBackgroundJobHistory->create_job;
- return 1;
-}
-
-1;
--- /dev/null
+-- @tag: emmvee_background_jobs_2
+-- @description: Hintergrundjobs einrichten
+-- @depends: emmvee_background_jobs
+INSERT INTO background_jobs (type, package_name, active, cron_spec, next_run_at)
+VALUES ('interval', 'CleanBackgroundJobHistory', true, '0 3 * * *',
+ CAST(current_date AS timestamp) + CAST(
+ (CASE
+ WHEN extract('hour' FROM current_timestamp) < 3 THEN '3 hours'
+ ELSE '1 day 3 hours'
+ END) AS interval
+ )
+);
+++ /dev/null
-# @tag: periodic_invoices_background_job
-# @description: Hintergrundjob zum Erzeugen wiederkehrender Rechnungen
-# @depends: periodic_invoices
-package SL::DBUpgrade2::periodic_invoices_background_job;
-
-use strict;
-use utf8;
-
-use parent qw(SL::DBUpgrade2::Base);
-
-use SL::BackgroundJob::CreatePeriodicInvoices;
-
-sub run {
- SL::BackgroundJob::CreatePeriodicInvoices->create_job;
- return 1;
-}
-
-1;
--- /dev/null
+-- @tag: periodic_invoices_background_job
+-- @description: Hintergrundjob zum Erzeugen wiederkehrender Rechnungen
+-- @depends: periodic_invoices
+INSERT INTO background_jobs (type, package_name, active, cron_spec, next_run_at)
+VALUES ('interval', 'CreatePeriodicInvoices', true, '0 3 1 * *',
+ date_trunc('month', current_date) + CAST('1 month 3 hours' AS interval));
+++ /dev/null
-# @tag: self_test_background_job
-# @description: Hintergrundjob für tägliche Selbsttests
-# @depends: release_2_7_0
-package SL::DBUpgrade2::self_test_background_job;
-
-use strict;
-use utf8;
-
-use parent qw(SL::DBUpgrade2::Base);
-
-use SL::BackgroundJob::SelfTest;
-
-sub run {
- SL::BackgroundJob::SelfTest->create_job;
- return 1;
-}
-
-1;
--- /dev/null
+-- @tag: self_test_background_job
+-- @description: Hintergrundjob für tägliche Selbsttests
+-- @depends: release_2_7_0
+INSERT INTO background_jobs (type, package_name, active, cron_spec, next_run_at)
+VALUES ('interval', 'SelfTest', true, '20 2 * * *',
+ CAST(current_date AS timestamp) + CAST(
+ (CASE
+ WHEN extract('hour' FROM current_timestamp) < 2 THEN '2 hours 20 minutes'
+ ELSE '1 day 2 hours 20 minutes'
+ END) AS interval
+ )
+);