Revision 89b0d175
Von Moritz Bunkus vor etwa 5 Jahren hinzugefügt
sql/Pg-upgrade2/background_job_change_create_periodic_invoices_to_daily.pl | ||
---|---|---|
1 |
# @tag: background_job_change_create_periodic_invoices_to_daily |
|
2 |
# @description: Hintergrundjob zum Erzeugen periodischer Rechnungen täglich ausführen |
|
3 |
# @depends: release_3_0_0 |
|
4 |
package SL::DBUpgrade2::background_job_change_create_periodic_invoices_to_daily; |
|
5 |
|
|
6 |
use strict; |
|
7 |
use utf8; |
|
8 |
|
|
9 |
use parent qw(SL::DBUpgrade2::Base); |
|
10 |
|
|
11 |
use SL::DB::BackgroundJob; |
|
12 |
|
|
13 |
sub run { |
|
14 |
my ($self) = @_; |
|
15 |
|
|
16 |
foreach my $job (@{ SL::DB::Manager::BackgroundJob->get_all(where => [ package_name => 'CreatePeriodicInvoices' ]) }) { |
|
17 |
$job->update_attributes(cron_spec => '0 3 * * *', next_run_at => undef); |
|
18 |
} |
|
19 |
|
|
20 |
return 1; |
|
21 |
} |
|
22 |
|
|
23 |
1; |
sql/Pg-upgrade2/background_job_change_create_periodic_invoices_to_daily.sql | ||
---|---|---|
1 |
-- @tag: background_job_change_create_periodic_invoices_to_daily |
|
2 |
-- @description: Hintergrundjob zum Erzeugen periodischer Rechnungen täglich ausführen |
|
3 |
-- @depends: release_3_0_0 |
|
4 |
UPDATE background_jobs |
|
5 |
SET cron_spec = '0 3 * * *', |
|
6 |
next_run_at = CAST(current_date AS timestamp) + CAST( |
|
7 |
(CASE |
|
8 |
WHEN extract('hour' FROM current_timestamp) < 3 THEN '3 hours' |
|
9 |
ELSE '1 day 3 hours' |
|
10 |
END) AS interval |
|
11 |
) |
|
12 |
WHERE package_name = 'CreatePeriodicInvoices'; |
sql/Pg-upgrade2/background_jobs_3.pl | ||
---|---|---|
1 |
# @tag: background_jobs_3 |
|
2 |
# @description: Backgroundjob Cleanup einrichten |
|
3 |
# @depends: emmvee_background_jobs_2 |
|
4 |
package SL::DBUpgrade2::background_jobs_3; |
|
5 |
|
|
6 |
use strict; |
|
7 |
use utf8; |
|
8 |
|
|
9 |
use parent qw(SL::DBUpgrade2::Base); |
|
10 |
|
|
11 |
use SL::BackgroundJob::BackgroundJobCleanup; |
|
12 |
|
|
13 |
sub run { |
|
14 |
SL::BackgroundJob::BackgroundJobCleanup->create_job; |
|
15 |
return 1; |
|
16 |
} |
|
17 |
|
|
18 |
1; |
sql/Pg-upgrade2/background_jobs_3.sql | ||
---|---|---|
1 |
-- @tag: background_jobs_3 |
|
2 |
-- @description: Backgroundjob Cleanup einrichten |
|
3 |
-- @depends: emmvee_background_jobs_2 |
|
4 |
INSERT INTO background_jobs (type, package_name, active, cron_spec, next_run_at) |
|
5 |
VALUES ('interval', 'BackgroundJobCleanup', true, '0 3 * * *', |
|
6 |
CAST(current_date AS timestamp) + CAST( |
|
7 |
(CASE |
|
8 |
WHEN extract('hour' FROM current_timestamp) < 3 THEN '3 hours' |
|
9 |
ELSE '1 day 3 hours' |
|
10 |
END) AS interval |
|
11 |
) |
|
12 |
); |
sql/Pg-upgrade2/background_jobs_clean_auth_sessions.pl | ||
---|---|---|
1 |
# @tag: background_jobs_clean_auth_sessions |
|
2 |
# @description: Hintergrundjob zum Löschen abgelaufener Sessions |
|
3 |
# @depends: release_3_1_0 |
|
4 |
package SL::DBUpgrade2::background_jobs_clean_auth_sessions; |
|
5 |
|
|
6 |
use strict; |
|
7 |
use utf8; |
|
8 |
|
|
9 |
use parent qw(SL::DBUpgrade2::Base); |
|
10 |
|
|
11 |
use SL::BackgroundJob::CleanAuthSessions; |
|
12 |
|
|
13 |
sub run { |
|
14 |
my ($self) = @_; |
|
15 |
|
|
16 |
SL::BackgroundJob::CleanAuthSessions->create_job; |
|
17 |
|
|
18 |
return 1; |
|
19 |
} |
|
20 |
|
|
21 |
1; |
sql/Pg-upgrade2/background_jobs_clean_auth_sessions.sql | ||
---|---|---|
1 |
-- @tag: background_jobs_clean_auth_sessions |
|
2 |
-- @description: Hintergrundjob zum Löschen abgelaufener Sessions |
|
3 |
-- @depends: release_3_1_0 |
|
4 |
INSERT INTO background_jobs (type, package_name, active, cron_spec, next_run_at) |
|
5 |
VALUES ('interval', 'CleanAuthSessions', true, '30 6 * * *', |
|
6 |
CAST(current_date AS timestamp) + CAST( |
|
7 |
(CASE |
|
8 |
WHEN extract('hour' FROM current_timestamp) < 6 THEN '6 hours 30 minutes' |
|
9 |
ELSE '1 day 6 hours 30 minutes' |
|
10 |
END) AS interval |
|
11 |
) |
|
12 |
); |
sql/Pg-upgrade2/emmvee_background_jobs_2.pl | ||
---|---|---|
1 |
# @tag: emmvee_background_jobs_2 |
|
2 |
# @description: Hintergrundjobs einrichten |
|
3 |
# @depends: emmvee_background_jobs |
|
4 |
package SL::DBUpgrade2::emmvee_background_jobs_2; |
|
5 |
|
|
6 |
use strict; |
|
7 |
use utf8; |
|
8 |
|
|
9 |
use parent qw(SL::DBUpgrade2::Base); |
|
10 |
|
|
11 |
use SL::BackgroundJob::CleanBackgroundJobHistory; |
|
12 |
|
|
13 |
sub run { |
|
14 |
SL::BackgroundJob::CleanBackgroundJobHistory->create_job; |
|
15 |
return 1; |
|
16 |
} |
|
17 |
|
|
18 |
1; |
sql/Pg-upgrade2/emmvee_background_jobs_2.sql | ||
---|---|---|
1 |
-- @tag: emmvee_background_jobs_2 |
|
2 |
-- @description: Hintergrundjobs einrichten |
|
3 |
-- @depends: emmvee_background_jobs |
|
4 |
INSERT INTO background_jobs (type, package_name, active, cron_spec, next_run_at) |
|
5 |
VALUES ('interval', 'CleanBackgroundJobHistory', true, '0 3 * * *', |
|
6 |
CAST(current_date AS timestamp) + CAST( |
|
7 |
(CASE |
|
8 |
WHEN extract('hour' FROM current_timestamp) < 3 THEN '3 hours' |
|
9 |
ELSE '1 day 3 hours' |
|
10 |
END) AS interval |
|
11 |
) |
|
12 |
); |
sql/Pg-upgrade2/periodic_invoices_background_job.pl | ||
---|---|---|
1 |
# @tag: periodic_invoices_background_job |
|
2 |
# @description: Hintergrundjob zum Erzeugen wiederkehrender Rechnungen |
|
3 |
# @depends: periodic_invoices |
|
4 |
package SL::DBUpgrade2::periodic_invoices_background_job; |
|
5 |
|
|
6 |
use strict; |
|
7 |
use utf8; |
|
8 |
|
|
9 |
use parent qw(SL::DBUpgrade2::Base); |
|
10 |
|
|
11 |
use SL::BackgroundJob::CreatePeriodicInvoices; |
|
12 |
|
|
13 |
sub run { |
|
14 |
SL::BackgroundJob::CreatePeriodicInvoices->create_job; |
|
15 |
return 1; |
|
16 |
} |
|
17 |
|
|
18 |
1; |
sql/Pg-upgrade2/periodic_invoices_background_job.sql | ||
---|---|---|
1 |
-- @tag: periodic_invoices_background_job |
|
2 |
-- @description: Hintergrundjob zum Erzeugen wiederkehrender Rechnungen |
|
3 |
-- @depends: periodic_invoices |
|
4 |
INSERT INTO background_jobs (type, package_name, active, cron_spec, next_run_at) |
|
5 |
VALUES ('interval', 'CreatePeriodicInvoices', true, '0 3 1 * *', |
|
6 |
date_trunc('month', current_date) + CAST('1 month 3 hours' AS interval)); |
sql/Pg-upgrade2/self_test_background_job.pl | ||
---|---|---|
1 |
# @tag: self_test_background_job |
|
2 |
# @description: Hintergrundjob für tägliche Selbsttests |
|
3 |
# @depends: release_2_7_0 |
|
4 |
package SL::DBUpgrade2::self_test_background_job; |
|
5 |
|
|
6 |
use strict; |
|
7 |
use utf8; |
|
8 |
|
|
9 |
use parent qw(SL::DBUpgrade2::Base); |
|
10 |
|
|
11 |
use SL::BackgroundJob::SelfTest; |
|
12 |
|
|
13 |
sub run { |
|
14 |
SL::BackgroundJob::SelfTest->create_job; |
|
15 |
return 1; |
|
16 |
} |
|
17 |
|
|
18 |
1; |
sql/Pg-upgrade2/self_test_background_job.sql | ||
---|---|---|
1 |
-- @tag: self_test_background_job |
|
2 |
-- @description: Hintergrundjob für tägliche Selbsttests |
|
3 |
-- @depends: release_2_7_0 |
|
4 |
INSERT INTO background_jobs (type, package_name, active, cron_spec, next_run_at) |
|
5 |
VALUES ('interval', 'SelfTest', true, '20 2 * * *', |
|
6 |
CAST(current_date AS timestamp) + CAST( |
|
7 |
(CASE |
|
8 |
WHEN extract('hour' FROM current_timestamp) < 2 THEN '2 hours 20 minutes' |
|
9 |
ELSE '1 day 2 hours 20 minutes' |
|
10 |
END) AS interval |
|
11 |
) |
|
12 |
); |
Auch abrufbar als: Unified diff
DB-Upgrades für Hintergrundjobs von Perl auf SQL umgestellt
Rose-Models dürfen in DB-Upgrade-Scripten nicht verwendet werden, weil
die Perl-Strukturdaten (MetaSetup) in dem Moment schon auf dem neuen
Stand, die Datenbankstrukturen aber auf dem alten Stand sind. Daher
schlagen bei Unterschieden (z.B. eine Spalte soll später noch angelegt
werden, sie existiert aber im neuen MetaSetup schon) halt sämliche
Operationen fehl.